X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ian/git?a=blobdiff_plain;f=tg-summary.sh;h=a92480ff38f0f13444909c5d3895ae2543b7765e;hb=5aed7e7bad8c23080139b452adac75d2571b6dfa;hp=870fcf4ddbfe9b988b5d2e35822558ff961fcda4;hpb=c4c57a55aa1b825109f0ce0547994ad394812902;p=topgit.git diff --git a/tg-summary.sh b/tg-summary.sh index 870fcf4..a92480f 100644 --- a/tg-summary.sh +++ b/tg-summary.sh @@ -5,6 +5,8 @@ terse= graphviz= +sort= +deps= ## Parse options @@ -16,14 +18,22 @@ while [ -n "$1" ]; do terse=1;; --graphviz) graphviz=1;; + --sort) + sort=1;; + --deps) + deps=1;; *) - echo "Usage: tg [...] summary [-t | --graphviz]" >&2 + echo "Usage: tg [...] summary [-t | --sort | --deps | --graphviz]" >&2 exit 1;; esac done curname="$(git symbolic-ref HEAD | sed 's#^refs/\(heads\|top-bases\)/##')" +[ "$terse$graphviz$sort$deps" = "" ] || + [ "$terse$graphviz$sort$deps" = "1" ] || + die "mutually exclusive options given" + if [ -n "$graphviz" ]; then cat <$tsort_input + exec 5<$tsort_input + rm $tsort_input +fi ## List branches 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 + if [ -n "$graphviz$sort$deps" ]; 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 + if [ -n "$graphviz" ]; then + echo "\"$name\" -> \"$dep\";" + elif [ -n "$deps" ]; then + echo "$name $dep" + else + echo "$name $dep" >&4 + fi + fi done continue fi @@ -99,4 +130,9 @@ if [ -n "$graphviz" ]; then echo '}' fi +if [ -n "$sort" ]; then + tsort <&5 +fi + + # vim:noet