chiark / gitweb /
[TOPGIT] allow working with annihilated branches
authorUwe Kleine-König <u.kleine-koenig@pengutronix.de>
Wed, 25 Feb 2009 19:44:11 +0000 (20:44 +0100)
committerUwe Kleine-König <u.kleine-koenig@pengutronix.de>
Wed, 25 Feb 2009 19:49:28 +0000 (20:49 +0100)
If you decide that you want to drop a patch, you can just merge in its
base with strategy "theirs".  Then you have base=topic and so no .top*
files any more.  This patch fixes tg summary and the helper function
recurse_deps() to handle these annihilated branches as if they don't
exist and don't show up in .topdeps files.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
tg-summary.sh
tg.sh

index 842d95ad34d11228203b437fa4e487ecac254071..50ee8832090c6646c9bd114d6f5926657dcc07db 100644 (file)
@@ -53,13 +53,22 @@ fi
 git for-each-ref refs/top-bases |
        while read rev type ref; do
                name="${ref#refs/top-bases/}"
+               if branch_annihilated "$name"; then
+                       continue;
+               fi;
+
                if [ -n "$terse" ]; then
                        echo "$name"
                        continue
                fi
                if [ -n "$graphviz" ]; then
                        git cat-file blob "$name:.topdeps" | while read dep; do
-                               echo "\"$name\" -> \"$dep\";"
+                               dep_is_tgish=true
+                               ref_exists "refs/top-bases/$dep"  ||
+                                       dep_is_tgish=false
+                               if ! "$dep_is_tgish" || ! branch_annihilated $dep; then
+                                       echo "\"$name\" -> \"$dep\";"
+                               fi
                        done
                        continue
                fi
diff --git a/tg.sh b/tg.sh
index ccb40cdea444c7d77d58c86fbeb275335e0da372..5bb2d0cd123f09b1b038b04ed3b9a17bc4495a5d 100644 (file)
--- a/tg.sh
+++ b/tg.sh
@@ -94,6 +94,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,
@@ -116,7 +126,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