2 # TopGit - A different patch queue manager
3 # (C) Petr Baudis <pasky@suse.cz> 2008
4 # (C) Per Cederqvist <ceder@lysator.liu.se> 2010
5 # (C) Kyle J. McKay <mackyle@gmail.com> 2017
9 force
= # Whether to annihilate non-empty branch, or branch where only the base is left.
10 update
=1 # Whether to run tg update on affected branches
25 echo "Usage: ${tgname:-tg} [...] annihilate [-f] [--no-update]" >&2
33 name
="$(verify_topgit_branch HEAD)"
35 [ -z "$force" ] && { branch_empty
"$name" || die
"branch is non-empty: $name"; }
39 ensure_ident_available
40 mb
="$(git merge-base "refs
/$topbases/$name" "refs
/heads
/$name")"
41 git read-tree
"$mb^{tree}"
42 # Need to pass --no-verify in order to inhibit TopGit's pre-commit hook to run,
43 # which would bark upon missing .top* files.
44 git commit
--no-verify -m"TopGit branch $name annihilated."
46 # Propagate the dependencies through to dependents (if any), if they don't already have them
47 dependencies
="$(tg prev -w)"
49 while read dependent
&& [ -n "$dependent" ]; do
50 # to avoid ambiguity with checkout -f we must use symbolic-ref + reset
51 git symbolic-ref HEAD
"refs/heads/$dependent"
54 while read dependency
&& [ -n "$dependency" ]; do
55 ! $tg depend add
--no-update "$dependency" >/dev
/null
2>&1 || needupdate
=1
59 [ -z "$needupdate" ] || updatelist
="${updatelist:+$updatelist }$dependent"
64 info
"branch successfully annihilated: $name"
66 if [ -n "$updatelist" ]; then
67 if [ -n "$update" ]; then
68 now
="after the update completes"
70 info
"skipping update because --no-update given"
71 info
"be sure to update affected branches: $updatelist"
75 info
"If you have shared your work, you might want to run ${tgname:-tg} push $name $now."
76 if [ -n "$updatelist" ] && [ -n "$update" ]; then
77 info
"now updating affected branches: $updatelist"
79 .
"$TG_INST_CMDDIR"/tg-update