Print out the newly created commitid at the end, for use in other scripts.
authorAvery Pennarun <apenwarr@gmail.com>
Fri, 24 Apr 2009 18:52:27 +0000 (14:52 -0400)
committerAvery Pennarun <apenwarr@gmail.com>
Fri, 24 Apr 2009 18:52:27 +0000 (14:52 -0400)
git-subtree.sh

index 256946b0de8dfe268f278d32cbd3d6f269fbc5f4..5f8b0f6c598601756a68fe9df5cc065b791627d9 100755 (executable)
@@ -93,7 +93,7 @@ cache_set()
 {
        oldrev="$1"
        newrev="$2"
-       if [ -e "$cachedir/$oldrev" ]; then
+       if [ "$oldrev" != "latest" -a -e "$cachedir/$oldrev" ]; then
                die "cache for $oldrev already exists!"
        fi
        echo "$newrev" >"$cachedir/$oldrev"
@@ -140,9 +140,14 @@ cmd_split()
                        newrev=$(copy_commit $rev $tree "$p") || exit $?
                        debug "  newrev is: $newrev"
                        cache_set $rev $newrev
+                       cache_set latest $newrev
                done || exit $?
        done || exit $?
-       
+       latest=$(cache_get latest)
+       if [ -z "$latest" ]; then
+               die "No new revisions were found"
+       fi
+       echo $latest
        exit 0
 }