X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ian/git?p=topgit.git;a=blobdiff_plain;f=tg.sh;h=3af2cd8bbbfa78b0f7826192cffab929b4b54586;hp=b15571ec6bee92541a6631a7267d215bf28e6c6f;hb=ba38e22d0e2c039c086c2d446304fa55c091ef1f;hpb=6a504cea9289f5f896ba516c6095595e1c0e6345 diff --git a/tg.sh b/tg.sh index b15571e..3af2cd8 100644 --- a/tg.sh +++ b/tg.sh @@ -3,7 +3,7 @@ # (c) Petr Baudis 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