2 # TopGit - A different patch queue manager
3 # (c) Petr Baudis <pasky@suse.cz> 2008
4 # (c) Per Cederqvist <ceder@lysator.liu.se> 2010
7 force
= # Whether to annihilate non-empty branch, or branch where only the base is left.
18 echo "Usage: tg [...] annihilate [-f]" >&2
26 name
="$(git symbolic-ref HEAD | sed 's#^refs/heads/##')"
27 branchrev
="$(git rev-parse --verify "$name" 2>/dev/null)" ||
28 die
"invalid branch name: $name"
29 baserev
="$(git rev-parse --verify "refs
/top-bases
/$name" 2>/dev/null)" ||
30 die
"not a TopGit topic branch: $name"
32 [ -z "$force" ] && { branch_empty
"$name" || die
"branch is non-empty: $name"; }
35 mb
="$(git merge-base "refs
/top-bases
/$name" "$name")"
36 git read-tree
"$mb^{tree}"
37 # Need to pass --no-verify in order to inhibit TopGit's pre-commit hook to run,
38 # which would bark upon missing .top* files.
39 git commit
--no-verify -m"TopGit branch $name annihilated."
41 # Propagate the dependencies through to dependents (if any), if they don't already have them
42 dependencies
="$(tg prev -w)"
43 tg next |
while read dependent
; do
44 git checkout
-f $dependent
45 for dependency
in $dependencies; do
46 tg depend add
"$dependency" 2>/dev
/null
50 info
"If you have shared your work, you might want to run tg push $name now."