X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ian/git?p=topgit.git;a=blobdiff_plain;f=tg-summary.sh;h=3c90a6b5952e526bac9da80e84386d6abf6246a8;hp=55e9764001ea23c82f38eb0f3f1f1813cdedbf0a;hb=9f5917da92ab8c32ab765a331ebcaf227b3e2f85;hpb=1dbf47b55529c1d7a6266b2b32f01e067f32a72e diff --git a/tg-summary.sh b/tg-summary.sh index 55e9764..3c90a6b 100644 --- a/tg-summary.sh +++ b/tg-summary.sh @@ -3,25 +3,84 @@ # (c) Petr Baudis 2008 # GPLv2 +terse= +graphviz= + ## Parse options -if [ -n "$1" ]; then - echo "Usage: tg summary" >&2 - exit 1 +while [ -n "$1" ]; do + arg="$1"; shift + case "$arg" in + -t) + terse=1;; + --graphviz) + graphviz=1;; + *) + echo "Usage: tg [...] summary [-t | --graphviz]" >&2 + exit 1;; + esac +done + +curname="$(git symbolic-ref HEAD | sed 's#^refs/\(heads\|top-bases\)/##')" + +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 name ref; do + while read rev type ref; do name="${ref#refs/top-bases/}" + if [ -n "$terse" ]; then + echo "$name" + continue + fi + if [ -n "$graphviz" ]; then + git cat-file blob "$name:.topdeps" | while read dep; do + echo "\"$name\" -> \"$dep\";" + done + continue + fi + + missing_deps= - nonempty= + current=' ' + [ "$name" != "$curname" ] || current='>' + nonempty=' ' ! branch_empty "$name" || nonempty='0' + remote=' ' + [ -z "$base_remote" ] || remote='l' + ! has_remote "$name" || remote='r' + rem_update=' ' + [ "$remote" != 'r' ] || ! ref_exists "refs/remotes/$base_remote/top-bases/$name" || { + branch_contains "refs/top-bases/$name" "refs/remotes/$base_remote/top-bases/$name" && + branch_contains "$name" "refs/remotes/$base_remote/$name" + } || rem_update='R' + [ "$rem_update" = 'R' ] || branch_contains "refs/remotes/$base_remote/$name" "$name" 2>/dev/null || + rem_update='L' deps_update=' ' - [ -z "$(needs_update "$name")" ] || deps_update='D' + needs_update "$name" >/dev/null || deps_update='D' + deps_missing=' ' + [ -z "$missing_deps" ] || deps_missing='!' base_update=' ' branch_contains "$name" "refs/top-bases/$name" || base_update='B' @@ -32,6 +91,10 @@ git for-each-ref refs/top-bases | subject="(No commits)" fi - printf '%s%s%s\t%-31s\t%s\n' "$nonempty" "$deps_update" "$base_update" \ + 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