diff --git a/treeid.sh b/treeid.sh
index e4a6794668f045896c83575900157b7d8cb0b952..d7ddc2553e60f736411d6fa830c85aceb6ef06b3 100755
--- a/treeid.sh
+++ b/treeid.sh
@@ -3,7 +3,7 @@
 # Attempt to identify the Android tree in use.  On success one or more
 # tree identifiers are output to stdout.
 #
-# Copyright (c) 2012-2014, The Linux Foundation. All rights reserved.
+# Copyright (c) 2012-2015, The Linux Foundation. All rights reserved.
 #
 # Redistribution and use in source and binary forms, with or without
 # modification, are permitted provided that the following conditions are
@@ -39,7 +39,7 @@ fi
 TREEID=
 if [[ -f .repo/manifest.xml ]] ; then
    # Tokenize <default revision="x_y_z"/> by '_'
-   TOKENS=$(repo info -l .repo/manifest 2>/dev/null | sed -e '/merge/!d ; s/^.*branch:// ; s/.*b2g_//g;')
+   TOKENS=$(repo info -l .repo/manifest 2>/dev/null | sed -e '/merge/!d ; s/^.*branch:// ; s/.*\///; s/.*b2g_//g;')
 
    MANIFEST_ID=
    for T in $TOKENS; do