chiark / gitweb /
tg-summary: accept -i/-w
authorBert Wesarg <bert.wesarg@googlemail.com>
Thu, 7 Oct 2010 21:05:08 +0000 (23:05 +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>
README
contrib/tg-completion.bash
tg-summary.sh

diff --git a/README b/README
index 48db36a08f5566f709e68560ad0667be9290becd..fa9d63f74dcb97bf3e4c4ca1a6470be9de0a9676 100644 (file)
--- a/README
+++ b/README
@@ -370,6 +370,10 @@ tg summary
        branches in a machine-readable format.  Feed this to "tsort"
        to get the output from --sort.
 
+       Options:
+         -i            Use TopGit meta data from the index instead of branch
+         -w            Use TopGit meta data from the working tree instead of branch
+
        TODO: Speed up by an order of magnitude
        TODO: Text graph view
 
index 48e47c7047c3c7308cd10b5a0327a63e94cd6fb1..eff85ee2b14034409e1a033886cfa40e2c0dd4c6 100755 (executable)
@@ -426,7 +426,11 @@ _tg_summary ()
        *)
                __tgcomp "
                        --graphviz
+                       --sort
+                       --deps
                        -t
+                       -i
+                       -w
                "
        esac
 }
index 612bd27443779266de3385dfce6b2812be81f85a..1c99e2225c61a2a4c9a07ec6bd64ee82558ddda7 100644 (file)
@@ -7,13 +7,16 @@ terse=
 graphviz=
 sort=
 deps=
-
+head_from=
 
 ## Parse options
 
 while [ -n "$1" ]; do
        arg="$1"; shift
        case "$arg" in
+       -i|-w)
+               [ -z "$head_from" ] || die "-i and -w are mutually exclusive"
+               head_from="$arg";;
        -t)
                terse=1;;
        --graphviz)
@@ -23,7 +26,7 @@ while [ -n "$1" ]; do
        --deps)
                deps=1;;
        *)
-               echo "Usage: tg [...] summary [-t | --sort | --deps | --graphviz]" >&2
+               echo "Usage: tg [...] summary [-t | --sort | --deps | --graphviz] [-i | -w]" >&2
                exit 1;;
        esac
 done
@@ -68,8 +71,11 @@ process_branch()
 
        current=' '
        [ "$name" != "$curname" ] || current='>'
+       from=$head_from
+       [ "$name" = "$curname" ] ||
+               from=
        nonempty=' '
-       ! branch_empty "$name" || nonempty='0'
+       ! branch_empty "$name" $from || nonempty='0'
        remote=' '
        [ -z "$base_remote" ] || remote='l'
        ! has_remote "$name" || remote='r'
@@ -88,7 +94,7 @@ process_branch()
        branch_contains "$name" "refs/top-bases/$name" || base_update='B'
 
        if [ "$(git rev-parse "$name")" != "$rev" ]; then
-               subject="$(git cat-file blob "$name:.topmsg" | sed -n 's/^Subject: //p')"
+               subject="$(cat_file "$name:.topmsg" $from | sed -n 's/^Subject: //p')"
        else
                # No commits yet
                subject="(No commits)"
@@ -99,7 +105,7 @@ process_branch()
 }
 
 if [ -n "$deps" ]; then
-       list_deps
+       list_deps $head_from
        exit 0
 fi
 
@@ -113,7 +119,10 @@ git for-each-ref refs/top-bases |
                if [ -n "$terse" ]; then
                        echo "$name"
                elif [ -n "$graphviz$sort" ]; then
-                       git cat-file blob "$name:.topdeps" | while read dep; do
+                       from=$head_from
+                       [ "$name" = "$curname" ] ||
+                               from=
+                       cat_file "$name:.topdeps" $from | while read dep; do
                                dep_is_tgish=true
                                ref_exists "refs/top-bases/$dep"  ||
                                        dep_is_tgish=false