chiark / gitweb /
Merge branch 'master' into refs/top-bases/debian/locations
[topgit.git] / tg.sh
diff --git a/tg.sh b/tg.sh
index b15571ec6bee92541a6631a7267d215bf28e6c6f..3af2cd8bbbfa78b0f7826192cffab929b4b54586 100644 (file)
--- a/tg.sh
+++ b/tg.sh
@@ -3,7 +3,7 @@
 # (c) Petr Baudis <pasky@suse.cz>  2008
 # GPLv2
 
-TG_VERSION=0.5
+TG_VERSION=0.7
 
 ## Auxiliary functions
 
@@ -99,7 +99,7 @@ measure_branch()
 # Whether B1 is a superset of B2.
 branch_contains()
 {
-       [ -z "$(git rev-list ^"$1" "$2" --)" ]
+       [ -z "$(git rev-list --max-count=1 ^"$1" "$2" --)" ]
 }
 
 # ref_exists REF
@@ -116,6 +116,16 @@ has_remote()
        [ -n "$base_remote" ] && ref_exists "remotes/$base_remote/$1"
 }
 
+branch_annihilated()
+{
+       _name="$1";
+
+       # use the merge base in case the base is ahead.
+       mb="$(git merge-base "refs/top-bases/$_name" "$_name")";
+
+       test "$(git rev-parse "$mb^{tree}")" = "$(git rev-parse "$_name^{tree}")";
+}
+
 # recurse_deps CMD NAME [BRANCHPATH...]
 # Recursively eval CMD on all dependencies of NAME.
 # CMD can refer to $_name for queried branch name,
@@ -138,7 +148,12 @@ recurse_deps()
        if has_remote "top-bases/$_name"; then
                echo "refs/remotes/$base_remote/top-bases/$_name" >>"$_depsfile"
        fi
-       git cat-file blob "$_name:.topdeps" >>"$_depsfile"
+
+       # if the branch was annihilated, there exists no .topdeps file
+       if ! branch_annihilated "$_name"; then
+               #TODO: handle nonexisting .topdeps?
+               git cat-file blob "$_name:.topdeps" >>"$_depsfile";
+       fi;
 
        _ret=0
        while read _dep; do