From: Per Cederqvist Date: Sun, 3 Oct 2010 21:37:52 +0000 (+0200) Subject: Implement "tg summary --deps" as a shell function. X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ian/git?p=topgit.git;a=commitdiff_plain;h=83d44c01a9494fdd1935012f3bad5ed805c750a3 Implement "tg summary --deps" as a shell function. This avoids running "$tg summary --deps" from all commands that need that information internally. Signed-off-by: Per Cederqvist Signed-off-by: Uwe Kleine-König --- diff --git a/tg-summary.sh b/tg-summary.sh index 32bb697..75ef4e3 100644 --- a/tg-summary.sh +++ b/tg-summary.sh @@ -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 9d08d63..b848f78 100644 --- 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() {