[TOPGIT] allow working with annihilated branches
[topgit/greenrd.git] / tg-depend.sh
blobef5f94ff2919c605f268ff7b12f702b1f63e5e5d
1 #!/bin/sh
2 # TopGit - A different patch queue manager
3 # (c) Petr Baudis <pasky@suse.cz> 2008
4 # GPLv2
6 name=
9 ## Parse options
11 subcmd="$1"; shift || :
12 case "$subcmd" in
13 -h|"")
14 echo "Usage: tg [...] depend add NAME" >&2
15 exit 1;;
16 add)
19 die "unknown subcommand ($subcmd)";;
20 esac
22 while [ -n "$1" ]; do
23 arg="$1"; shift
24 case "$arg" in
25 -*)
26 echo "Usage: tg [...] depend add NAME" >&2
27 exit 1;;
29 [ -z "$name" ] || die "name already specified ($name)"
30 name="$arg";;
31 esac
32 done
35 ## Sanity checks
37 [ -n "$name" ] || die "no branch name specified"
38 branchrev="$(git rev-parse --verify "$name" 2>/dev/null)" ||
39 die "invalid branch name: $name"
40 baserev="$(git rev-parse --verify "refs/top-bases/$name" 2>/dev/null)" ||
41 die "not a TopGit topic branch: $name"
44 ## Record new dependency
46 echo "$name" >>"$root_dir/.topdeps"
47 git add -f "$root_dir/.topdeps"
48 git commit -m"New TopGit dependency: $name"
49 $tg update
51 # vim:noet