This repository was archived by the owner on Jan 20, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 24
Expand file tree
/
Copy pathtg-annihilate.sh
More file actions
53 lines (41 loc) · 1.4 KB
/
Copy pathtg-annihilate.sh
File metadata and controls
53 lines (41 loc) · 1.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#!/bin/sh
# TopGit - A different patch queue manager
# (c) Petr Baudis <[email protected]> 2008
# (c) Per Cederqvist <[email protected]> 2010
# GPLv2
force= # Whether to annihilate non-empty branch, or branch where only the base is left.
## Parse options
while [ -n "$1" ]; do
arg="$1"; shift
case "$arg" in
-f)
force=1;;
*)
echo "Usage: tg [...] annihilate [-f]" >&2
exit 1;;
esac
done
## Sanity checks
name="$(git symbolic-ref HEAD | sed 's#^refs/heads/##')"
branchrev="$(git rev-parse --verify "$name" 2>/dev/null)" ||
die "invalid branch name: $name"
baserev="$(git rev-parse --verify "refs/top-bases/$name" 2>/dev/null)" ||
die "not a TopGit topic branch: $name"
[ -z "$force" ] && { branch_empty "$name" || die "branch is non-empty: $name"; }
## Annihilate
mb="$(git merge-base "refs/top-bases/$name" "$name")"
git read-tree "$mb^{tree}"
# Need to pass --no-verify in order to inhibit TopGit's pre-commit hook to run,
# which would bark upon missing .top* files.
git commit --no-verify -m"TopGit branch $name annihilated."
# Propagate the dependencies through to dependents (if any), if they don't already have them
dependencies="$(tg prev -w)"
tg next | while read dependent; do
git checkout -f $dependent
for dependency in $dependencies; do
tg depend add "$dependency" 2>/dev/null
done
done
info "If you have shared your work, you might want to run tg push $name now."
git status
# vim:noet