2 # TopGit - A different patch queue manager
3 # (c) Petr Baudis <pasky@suse.cz> 2008
23 echo "Usage: tg [...] summary [-t | --sort | --graphviz]" >&2
28 curname
="$(git symbolic-ref HEAD | sed 's#^refs/\(heads\|top-bases\)/##')"
30 ! [ -n "$terse" -a -n "$graphviz" ] ||
31 die
"-t and --graphviz options are mutual exclusive"
33 ! [ -n "$sort" -a -n "$graphviz" ] ||
34 die
"--sort and --graphviz options are mutual exclusive"
36 ! [ -n "$sort" -a -n "$terse" ] ||
37 die
"-t and --sort options are mutual exclusive"
39 if [ -n "$graphviz" ]; then
41 # GraphViz output; pipe to:
42 # | dot -Tpng -o <ouput>
50 label="TopGit Layout\n\n\n"
59 if [ -n "$sort" ]; then
68 git for-each-ref refs
/top-bases |
69 while read rev type ref
; do
70 name
="${ref#refs/top-bases/}"
71 if branch_annihilated
"$name"; then
75 if [ -n "$terse" ]; then
79 if [ -n "$graphviz" ] ||
[ -n "$sort" ]; then
80 git cat-file blob
"$name:.topdeps" |
while read dep
; do
82 ref_exists
"refs/top-bases/$dep" ||
84 if ! "$dep_is_tgish" ||
! branch_annihilated
$dep; then
85 if [ -n "$graphviz" ]; then
86 echo "\"$name\" -> \"$dep\";"
98 [ "$name" != "$curname" ] || current
='>'
100 ! branch_empty
"$name" || nonempty
='0'
102 [ -z "$base_remote" ] || remote
='l'
103 ! has_remote
"$name" || remote
='r'
105 [ "$remote" != 'r' ] ||
! ref_exists
"refs/remotes/$base_remote/top-bases/$name" ||
{
106 branch_contains
"refs/top-bases/$name" "refs/remotes/$base_remote/top-bases/$name" &&
107 branch_contains
"$name" "refs/remotes/$base_remote/$name"
109 [ "$rem_update" = 'R' ] || branch_contains
"refs/remotes/$base_remote/$name" "$name" 2>/dev
/null ||
112 needs_update
"$name" >/dev
/null || deps_update
='D'
114 [ -z "$missing_deps" ] || deps_missing
='!'
116 branch_contains
"$name" "refs/top-bases/$name" || base_update
='B'
118 if [ "$(git rev-parse "$name")" != "$rev" ]; then
119 subject
="$(git cat-file blob "$name:.topmsg
" | sed -n 's/^Subject: //p')"
122 subject
="(No commits)"
125 printf '%s\t%-31s\t%s\n' "$current$nonempty$remote$rem_update$deps_update$deps_missing$base_update" \
129 if [ -n "$graphviz" ]; then
133 if [ -n "$sort" ]; then