aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKarel Kočí <karel.koci@nic.cz>2019-12-04 15:32:10 +0100
committerKarel Kočí <karel.koci@nic.cz>2019-12-04 15:32:10 +0100
commite0949a2d329b434999fdb285c2461ad880c7f337 (patch)
tree6514823112a38285993052c6a40e95d37448ed41
parent69d76eb5bcbe2b03ce781d95ff416fb189c363a6 (diff)
downloadshellrc-0.7.5.tar.gz
shellrc-0.7.5.tar.bz2
shellrc-0.7.5.zip
shellrc.d/git: fix problem with / in gitbmergev0.7.5
-rw-r--r--shellrc.d/git14
1 files changed, 11 insertions, 3 deletions
diff --git a/shellrc.d/git b/shellrc.d/git
index 2dac8bb..1c1de0a 100644
--- a/shellrc.d/git
+++ b/shellrc.d/git
@@ -1,5 +1,12 @@
# vim: ft=sh:
+# Get path to worktree for git branch
+_gitbworktree() {
+ git worktree list --porcelain | \
+ awk -v ref="refs/heads/$1" \
+ '/^worktree / { worktree = $2 }; /^branch / { if ($2 == ref) { print worktree }}'
+}
+
# Automatic branch merger (merge branch, push it to server and remove branch)
# Expects name of the branch as argument
# It fails if it's not fast forward merge and if there is fixup! commit.
@@ -9,9 +16,10 @@ gitbmerge() (
echo "First squash fixups!"
exit 1
fi
- local WT="$(git worktree list | sed -nE "/\[$1\]/{s/([^ ]+) .*/\1/p}")"
- if [ -n "$WT" ]; then
- rm -r "$WT"
+ local wt
+ wt="$(_gitbworktree "$1")"
+ if [ -n "$wt" ]; then
+ rm -r "$wt"
git worktree prune
fi
git merge --ff-only "$1" && git push && git branch -d "$1" && git push origin :"$1"