chiark / gitweb /
tg.sh: Runtime tg-* command check
[topgit.git] / tg-summary.sh
1 #!/bin/sh
2 # TopGit - A different patch queue manager
3 # (c) Petr Baudis <pasky@suse.cz>  2008
4 # GPLv2
5
6
7 ## Parse options
8
9 if [ -n "$1" ]; then
10         echo "Usage: tg summary" >&2
11         exit 1
12 fi
13
14
15 ## List branches
16
17 git for-each-ref refs/top-bases |
18         while read rev name ref; do
19                 name="${ref#refs/top-bases/}"
20                 missing_deps=
21
22                 nonempty=' '
23                 ! branch_empty "$name" || nonempty='0'
24                 deps_update=' '
25                 needs_update "$name" >/dev/null || deps_update='D'
26                 deps_missing=' '
27                 [ -z "$missing_deps" ] || deps_missing='!'
28                 base_update=' '
29                 branch_contains "$name" "refs/top-bases/$name" || base_update='B'
30
31                 if [ "$(git rev-parse "$name")" != "$rev" ]; then
32                         subject="$(git cat-file blob "$name:.topmsg" | sed -n 's/^Subject: //p')"
33                 else
34                         # No commits yet
35                         subject="(No commits)"
36                 fi
37
38                 printf '%s\t%-31s\t%s\n' "$nonempty$deps_update$deps_missing$base_update" \
39                         "$name" "$subject"
40         done