tg import: Fix up process_commit() progress reporting
[topgit.git] / tg-summary.sh
blob409f45622910caf29b5f6d68a2930b3f76b6a274
1 #!/bin/sh
2 # TopGit - A different patch queue manager
3 # (c) Petr Baudis <pasky@suse.cz> 2008
4 # GPLv2
7 ## Parse options
9 if [ -n "$1" ]; then
10 echo "Usage: tg [...] summary" >&2
11 exit 1
14 curname="$(git symbolic-ref HEAD | sed 's#^refs/\(heads\|top-bases\)/##')"
17 ## List branches
19 git for-each-ref refs/top-bases |
20 while read rev type ref; do
21 name="${ref#refs/top-bases/}"
22 missing_deps=
24 current=' '
25 [ "$name" != "$curname" ] || current='>'
26 nonempty=' '
27 ! branch_empty "$name" || nonempty='0'
28 remote=' '
29 [ -z "$base_remote" ] || remote='l'
30 ! has_remote "$name" || remote='r'
31 rem_update=' '
32 [ "$remote" != 'r' ] || ! ref_exists "refs/remotes/$base_remote/top-bases/$name" || {
33 branch_contains "refs/top-bases/$name" "refs/remotes/$base_remote/top-bases/$name" &&
34 branch_contains "$name" "refs/remotes/$base_remote/$name"
35 } || rem_update='R'
36 [ "$rem_update" = 'R' ] || branch_contains "refs/remotes/$base_remote/$name" "$name" 2>/dev/null ||
37 rem_update='L'
38 deps_update=' '
39 needs_update "$name" >/dev/null || deps_update='D'
40 deps_missing=' '
41 [ -z "$missing_deps" ] || deps_missing='!'
42 base_update=' '
43 branch_contains "$name" "refs/top-bases/$name" || base_update='B'
45 if [ "$(git rev-parse "$name")" != "$rev" ]; then
46 subject="$(git cat-file blob "$name:.topmsg" | sed -n 's/^Subject: //p')"
47 else
48 # No commits yet
49 subject="(No commits)"
52 printf '%s\t%-31s\t%s\n' "$current$nonempty$remote$rem_update$deps_update$deps_missing$base_update" \
53 "$name" "$subject"
54 done