tg.sh: work around broken git rev-parse --git-common-dir
[topgit/pro.git] / tg-next.sh
blob1d00897857fa389ca484cab08fd68440a7442d27
1 #!/bin/sh
2 # TopGit - A different patch queue manager
3 # (c) Petr Baudis <pasky@suse.cz> 2008
4 # (c) Bert Wesarg <Bert.Wesarg@googlemail.com> 2009
5 # GPLv2
7 name=
8 head_from=
11 ## Parse options
13 while [ -n "$1" ]; do
14 arg="$1"; shift
15 case "$arg" in
16 -i|-w)
17 [ -z "$head_from" ] || die "-i and -w are mutually exclusive"
18 head_from="$arg";;
19 -*)
20 echo "Usage: ${tgname:-tg} [...] next [-i | -w] [<name>]" >&2
21 exit 1;;
23 [ -z "$name" ] || die "name already specified ($name)"
24 name="$arg";;
25 esac
26 done
28 head="$(git rev-parse --revs-only --abbrev-ref=loose HEAD --)"
29 [ -n "$name" ] ||
30 name="$head"
32 non_annihilated_branches |
33 while read parent; do
34 from=$head_from
35 # select .topdeps source for HEAD branch
36 [ "x$parent" = "x$head" ] ||
37 from=
39 cat_file "refs/heads/$parent:.topdeps" $from 2>/dev/null | LC_ALL=C grep -Fqx "$name" ||
40 continue
42 echol "$parent"
43 done