chiark / gitweb /
Implement "tg summary --deps" as a shell function.
authorPer Cederqvist <ceder@lysator.liu.se>
Sun, 3 Oct 2010 21:37:52 +0000 (23:37 +0200)
committerUwe Kleine-König <u.kleine-koenig@pengutronix.de>
Sun, 3 Oct 2010 21:43:59 +0000 (23:43 +0200)
This avoids running "$tg summary --deps" from all commands that need
that information internally.

Signed-off-by: Per Cederqvist <ceder@lysator.liu.se>
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
tg-summary.sh
tg.sh

index 32bb6976037ce28b1174a25a0dabe67af95f8b97..75ef4e3cc2c5fc77058565245fc737d3bdc21252 100644 (file)
@@ -99,18 +99,21 @@ process_branch()
                "$name" "$subject"
 }
 
+if [ -n "$deps" ]; then
+       list_deps
+       exit 0
+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;
+               fi
 
                if [ -n "$terse" ]; then
                        echo "$name"
-                       continue
-               fi
-               if [ -n "$graphviz$sort$deps" ]; then
+               elif [ -n "$graphviz$sort" ]; then
                        git cat-file blob "$name:.topdeps" | while read dep; do
                                dep_is_tgish=true
                                ref_exists "refs/top-bases/$dep"  ||
@@ -118,17 +121,14 @@ git for-each-ref refs/top-bases |
                                if ! "$dep_is_tgish" || ! branch_annihilated $dep; then
                                        if [ -n "$graphviz" ]; then
                                                echo "\"$name\" -> \"$dep\";"
-                                       elif [ -n "$deps" ]; then
-                                               echo "$name $dep"
                                        else
                                                echo "$name $dep" >&4
                                        fi
                                fi
                        done
-                       continue
+               else
+                       process_branch
                fi
-
-               process_branch
        done
 
 if [ -n "$graphviz" ]; then
diff --git a/tg.sh b/tg.sh
index 9d08d636af97b6b4f3ad574b7fa486cca119f7aa..b848f7863ae6f482dd7d37d4df9ebd07e91dc509 100644 (file)
--- a/tg.sh
+++ b/tg.sh
@@ -239,6 +239,27 @@ branch_empty()
        [ -z "$(git diff-tree "refs/top-bases/$1" "$1" -- | fgrep -v "  .top")" ]
 }
 
+# list_deps
+list_deps()
+{
+       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
+
+                       git cat-file blob "$name:.topdeps" | while read dep; do
+                               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
+               done
+}
+
 # switch_to_base NAME [SEED]
 switch_to_base()
 {