2 # TopGit - A different patch queue manager
3 # (c) Petr Baudis <pasky@suse.cz> 2008
26 echo "Usage: tg [...] summary [-t | --sort | --deps | --graphviz]" >&2
31 curname
="$(git symbolic-ref HEAD | sed 's#^refs/\(heads\|top-bases\)/##')"
33 [ "$terse$graphviz$sort$deps" = "" ] ||
34 [ "$terse$graphviz$sort$deps" = "1" ] ||
35 die
"mutually exclusive options given"
37 if [ -n "$graphviz" ]; then
39 # GraphViz output; pipe to:
40 # | dot -Tpng -o <ouput>
48 label="TopGit Layout\n\n\n"
57 if [ -n "$sort" ]; then
58 tsort_input
="$(get_temp tg-summary-sort)"
70 [ "$name" != "$curname" ] || current
='>'
72 ! branch_empty
"$name" || nonempty
='0'
74 [ -z "$base_remote" ] || remote
='l'
75 ! has_remote
"$name" || remote
='r'
77 [ "$remote" != 'r' ] ||
! ref_exists
"refs/remotes/$base_remote/top-bases/$name" ||
{
78 branch_contains
"refs/top-bases/$name" "refs/remotes/$base_remote/top-bases/$name" &&
79 branch_contains
"$name" "refs/remotes/$base_remote/$name"
81 [ "$rem_update" = 'R' ] || branch_contains
"refs/remotes/$base_remote/$name" "$name" 2>/dev
/null ||
84 needs_update
"$name" >/dev
/null || deps_update
='D'
86 [ -z "$missing_deps" ] || deps_missing
='!'
88 branch_contains
"$name" "refs/top-bases/$name" || base_update
='B'
90 if [ "$(git rev-parse "$name")" != "$rev" ]; then
91 subject
="$(git cat-file blob "$name:.topmsg
" | sed -n 's/^Subject: //p')"
94 subject
="(No commits)"
97 printf '%s\t%-31s\t%s\n' "$current$nonempty$remote$rem_update$deps_update$deps_missing$base_update" \
101 if [ -n "$deps" ]; then
106 git for-each-ref refs
/top-bases |
107 while read rev type ref
; do
108 name
="${ref#refs/top-bases/}"
109 if branch_annihilated
"$name"; then
113 if [ -n "$terse" ]; then
115 elif [ -n "$graphviz$sort" ]; then
116 git cat-file blob
"$name:.topdeps" |
while read dep
; do
118 ref_exists
"refs/top-bases/$dep" ||
120 if ! "$dep_is_tgish" ||
! branch_annihilated
$dep; then
121 if [ -n "$graphviz" ]; then
122 echo "\"$name\" -> \"$dep\";"
123 if [ "$name" = "$curname" ] ||
[ "$dep" = "$curname" ]; then
124 echo "\"$curname\" [style=filled,fillcolor=yellow];"
127 echo "$name $dep" >&4
136 if [ -n "$graphviz" ]; then
140 if [ -n "$sort" ]; then