Merge commit 'index-wt~2' of git://repo.or.cz/topgit/bertw
[topgit/bertw.git] / tg-prev.sh
blob1f1e0c16df055812274316cadfce49bcafe2df84
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: 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 --abbrev-ref=loose HEAD)"
29 [ -n "$name" ] ||
30 name="$head"
31 base_rev="$(git rev-parse --short --verify "refs/top-bases/$name" 2>/dev/null)" ||
32 die "not a TopGit-controlled branch"
34 # select .topdeps source for HEAD branch
35 [ "x$name" = "x$head" ] ||
36 head_from=
38 cat_file "$name:.topdeps" $head_from