tg import -d: Explicitly specify base dependency of the created branches
[topgit/fonseca.git] / tg-depend.sh
blobeeb76cd1202dc82fc34c2448821a11d6364cab68
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" >>.topdeps
47 git add .topdeps
48 git commit -m"New TopGit dependency: $name"
49 $tg update