chiark / gitweb /
tg-create.sh: Fix several bugs when resuming after conflicts
[topgit.git] / tg-info.sh
1 #!/bin/sh
2 # TopGit - A different patch queue manager
3 # (c) Petr Baudis <pasky@suse.cz>  2008
4 # GPLv2
5
6 name=
7
8
9 ## Parse options
10
11 while [ -n "$1" ]; do
12         arg="$1"; shift
13         case "$arg" in
14         -*)
15                 echo "Usage: tg info [NAME]" >&2
16                 exit 1;;
17         *)
18                 [ -z "$name" ] || die "name already specified ($name)"
19                 name="$arg";;
20         esac
21 done
22
23 [ -n "$name" ] || name="$(git symbolic-ref HEAD | sed 's#^refs/heads/##')"
24 base_rev="$(git rev-parse --short --verify "refs/top-bases/$name" 2>/dev/null)" ||
25         die "not a TopGit-controlled branch"
26
27 measure="$(measure_branch "$name" "$base_rev")"
28
29 echo "Topic Branch: $name ($measure)"
30 if [ "$(git rev-parse --short "$name")" = "$base_rev" ]; then
31         echo "No commits."
32         exit 0
33 fi
34
35 git cat-file blob "$name:.topmsg" | grep ^Subject:
36
37 echo "Base: $base_rev"
38 branch_contains "$name" "$base_rev" ||
39         echo "Base is newer than head! Please run \`tg update\`."
40
41 deps="$(git cat-file blob "$name:.topdeps")"
42 echo "Depends: $deps"
43
44 depcheck="$(mktemp)"
45 needs_update "$name" >"$depcheck"
46 if [ -s "$depcheck" ]; then
47         echo "Needs update from:"
48         cat "$depcheck" |
49                 sed 's/ [^ ]* *$//' | # last is $name
50                 sed 's/^: //' | # don't distinguish base updates
51                 while read dep chain; do
52                         echo -n "$dep "
53                         [ -n "$chain" ] && echo -n "(<= $(echo "$chain" | sed 's/ / <= /')) "
54                         dep_parent="${chain%% *}"
55                         echo -n "($(measure_branch "$dep" "${dep2:-$name}"))"
56                         echo
57                 done | sed 's/^/\t/'
58 else
59         echo "Up-to-date."
60 fi
61 rm "$depcheck"