2 # TopGit - A different patch queue manager
3 # (c) Petr Baudis <pasky@suse.cz> 2008
11 echo "Usage: tg [...] depend add NAME" >&2
17 subcmd
="$1"; shift ||
:
24 die
"unknown subcommand ($subcmd)";;
33 [ -z "$name" ] || die
"name already specified ($name)"
41 [ -n "$name" ] || die
"no branch name specified"
42 branchrev
="$(git rev-parse --verify "$name" 2>/dev/null)" ||
43 die
"invalid branch name: $name"
45 # Check that we are on a TopGit branch.
46 current_name
="$(git symbolic-ref HEAD | sed 's#^refs/\(heads\|top-bases\)/##')"
47 current_base_rev
="$(git rev-parse --short --verify "refs
/top-bases
/$current_name" 2>/dev/null)" ||
48 die
"not a TopGit-controlled branch"
50 ## Record new dependency
53 [ "$name" = "$current_name" ] &&
54 die
"$name cannot depend on itself."
56 { $tg summary
--deps; echo "$current_name" "$name"; } |
58 die
"tg: that dependency would introduce a dependency loop"
60 grep -F -x -e "$name" "$root_dir/.topdeps" >/dev
/null
&&
61 die
"tg: $current_name already depends on $name"
63 echo "$name" >>"$root_dir/.topdeps"
64 git add
-f "$root_dir/.topdeps"
65 git commit
-m"New TopGit dependency: $name"