chiark / gitweb /
Merge branch 'fixes/independent-help' into refs/top-bases/i/basis-merge
[topgit.git] / tg-next.sh
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
6
7 name=
8 head_from=
9
10
11 ## Parse options
12
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: tg next [-i | -w] [NAME]" >&2
21                 exit 1;;
22         *)
23                 [ -z "$name" ] || die "name already specified ($name)"
24                 name="$arg";;
25         esac
26 done
27
28 head="$(git rev-parse --abbrev-ref=loose HEAD)"
29 [ -n "$name" ] ||
30         name="$head"
31
32 git for-each-ref --format='%(refname)' refs/top-bases |
33         while read ref; do
34                 parent="${ref#refs/top-bases/}"
35
36                 from=$head_from
37                 # select .topdeps source for HEAD branch
38                 [ "x$parent" = "x$head" ] ||
39                         from=
40
41                 cat_file "$parent:.topdeps" $from | fgrep -qx "$name" ||
42                         continue
43
44                 echo "$parent"
45         done