chiark / gitweb /
list_deps: accept -i/-w
authorBert Wesarg <bert.wesarg@googlemail.com>
Tue, 26 Oct 2010 21:15:55 +0000 (23:15 +0200)
committerBert Wesarg <bert.wesarg@googlemail.com>
Mon, 8 Nov 2010 07:27:29 +0000 (08:27 +0100)
Signed-off-by: Bert Wesarg <bert.wesarg@googlemail.com>
tg.sh

diff --git a/tg.sh b/tg.sh
index caf7d2836cc1db2e0269415aa224b3377c01d38c..9082d88910569af146dde388332bedd0b555ffc1 100644 (file)
--- a/tg.sh
+++ b/tg.sh
@@ -290,9 +290,17 @@ branch_empty()
        [ "$(pretty_tree "$1" -b)" = "$(pretty_tree "$1" ${2-})" ]
 }
 
-# list_deps
+# list_deps [-i | -w]
+# -i/-w apply only to HEAD
 list_deps()
 {
+       local head
+       local head_from
+       local from
+       head_from=${1-}
+       head="$(git symbolic-ref -q HEAD)" ||
+               head="..detached.."
+
        git for-each-ref refs/top-bases |
                while read rev type ref; do
                        name="${ref#refs/top-bases/}"
@@ -300,7 +308,10 @@ list_deps()
                                continue;
                        fi
 
-                       git cat-file blob "$name:.topdeps" | while read dep; do
+                       from=$head_from
+                       [ "refs/heads/$name" = "$head" ] ||
+                               from=
+                       cat_file "$name:.topdeps" $from | while read dep; do
                                dep_is_tgish=true
                                ref_exists "refs/top-bases/$dep"  ||
                                        dep_is_tgish=false