X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ian/git?p=topgit.git;a=blobdiff_plain;f=tg.sh;fp=tg.sh;h=f0496f1b6ade99b1f9290f3cc5fe7096fc4373ba;hp=7c6c09f2eaa709933dc4631495c7b440556882db;hb=2f7cb405238120a51ab113427d25488ef87ef14b;hpb=d0fd65c3d26419ec9f21310c7aaea73610b058d8 diff --git a/tg.sh b/tg.sh index 7c6c09f..f0496f1 100644 --- a/tg.sh +++ b/tg.sh @@ -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