X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ian/git?p=topgit.git;a=blobdiff_plain;f=tg-summary.sh;h=50ee8832090c6646c9bd114d6f5926657dcc07db;hp=3905bdce7dc1d934a7862c025c4fb772c52660d6;hb=HEAD;hpb=f5e3413132a2403ab97833bac4644d3d7ee3253e diff --git a/tg-summary.sh b/tg-summary.sh index 3905bdc..50ee883 100644 --- a/tg-summary.sh +++ b/tg-summary.sh @@ -4,6 +4,7 @@ # GPLv2 terse= +graphviz= ## Parse options @@ -13,24 +14,64 @@ while [ -n "$1" ]; do case "$arg" in -t) terse=1;; + --graphviz) + graphviz=1;; *) - echo "Usage: tg [...] summary [-t]" >&2 + echo "Usage: tg [...] summary [-t | --graphviz]" >&2 exit 1;; esac done curname="$(git symbolic-ref HEAD | sed 's#^refs/\(heads\|top-bases\)/##')" +! [ -n "$terse" -a -n "$graphviz" ] || + die "-t and --graphviz options are mutual exclusive" + +if [ -n "$graphviz" ]; then + cat < +# or +# | dot -Txlib + +digraph G { + +graph [ + rankdir = "TB" + label="TopGit Layout\n\n\n" + fontsize = 14 + labelloc=top + pad = "0.5,0.5" +]; + +EOT +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 + 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 + continue + fi missing_deps= @@ -65,3 +106,9 @@ git for-each-ref refs/top-bases | printf '%s\t%-31s\t%s\n' "$current$nonempty$remote$rem_update$deps_update$deps_missing$base_update" \ "$name" "$subject" done + +if [ -n "$graphviz" ]; then + echo '}' +fi + +# vim:noet