2 # TopGit - A different patch queue manager
3 # (c) Petr Baudis <pasky@suse.cz> 2008
6 force
= # Whether to delete non-empty branch, or branch where only the base is left.
18 echo "Usage: ${tgname:-tg} [...] delete [-f] <name>" >&2
21 [ -z "$name" ] || die
"name already specified ($name)"
29 [ -n "$name" ] || die
"no branch name specified"
30 branchrev
="$(git rev-parse --verify "$name" -- 2>/dev/null)" ||
31 if [ -n "$force" ]; then
32 info
"invalid branch name: $name; assuming it has been deleted already"
34 die
"invalid branch name: $name"
36 baserev
="$(git rev-parse --verify "refs
/top-bases
/$name" -- 2>/dev/null)" ||
37 die
"not a TopGit topic branch: $name"
38 ! git symbolic-ref HEAD
>/dev
/null ||
[ "$(git symbolic-ref HEAD)" != "refs/heads/$name" ] ||
39 die
"cannot delete your current branch"
41 [ -z "$force" ] && { branch_empty
"$name" || die
"branch is non-empty: $name"; }
43 # Quick'n'dirty check whether branch is required
44 [ -z "$force" ] && { $tg summary
--deps | cut
-d' ' -f2- |
tr ' ' '\n' | fgrep
-xq -- "$name" && die
"some branch depends on $name"; }
48 git update-ref
-d "refs/top-bases/$name" "$baserev"
49 [ -z "$branchrev" ] || git update-ref
-d "refs/heads/$name" "$branchrev"