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"; }
38 ensure_ident_available
39 mb
="$(git merge-base "refs
/$topbases/$name" "refs
/heads
/$name")"
40 git read-tree
"$mb^{tree}"
41 # Need to pass --no-verify in order to inhibit TopGit's pre-commit hook to run,
42 # which would bark upon missing .top* files.
43 git commit
--no-verify -m"TopGit branch $name annihilated."
45 # Propagate the dependencies through to dependents (if any), if they don't already have them
46 dependencies
="$(tg prev -w)"
48 while read dependent
&& [ -n "$dependent" ]; do
49 git checkout
-f "refs/heads/$dependent"
51 while read dependency
&& [ -n "$dependency" ]; do
52 ! $tg depend add
--no-update "$dependency" >/dev
/null
2>&1 || needupdate
=1
56 [ -z "$needupdate" ] || updatelist
="${updatelist:+$updatelist }$dependent"
61 info
"branch successfully annihilated: $name"
63 if [ -n "$updatelist" ]; then
64 if [ -n "$update" ]; then
65 info
"now updating affected branches: $updatelist"
66 while read dependent
&& [ -n "$dependent" ]; do
67 $tg update
"$dependent"
69 $(sed 'y/ /\n/' <<-LIST
75 info
"skipping update because --no-update given"
76 info
"be sure to update affected branches: $updatelist"
81 info
"If you have shared your work, you might want to run ${tgname:-tg} push $name $now."