diff options
author | Karel Kočí <cynerd@email.cz> | 2018-08-12 18:37:31 +0200 |
---|---|---|
committer | Karel Kočí <cynerd@email.cz> | 2018-08-12 18:37:31 +0200 |
commit | a55cffa8b3cbc02e2b021ed25e67203d337c36bb (patch) | |
tree | 8ccc7d7fd3a8423af46a77c488511589142fc08b /shellrc.d/git | |
parent | 8720b8f7bb072a861dcc5b4be1c97b02f0912a9e (diff) | |
download | shellrc-a55cffa8b3cbc02e2b021ed25e67203d337c36bb.tar.gz shellrc-a55cffa8b3cbc02e2b021ed25e67203d337c36bb.tar.bz2 shellrc-a55cffa8b3cbc02e2b021ed25e67203d337c36bb.zip |
Move some definitions around and add --desktop optionv0.5.2
Diffstat (limited to 'shellrc.d/git')
-rw-r--r-- | shellrc.d/git | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/shellrc.d/git b/shellrc.d/git new file mode 100644 index 0000000..47edae5 --- /dev/null +++ b/shellrc.d/git @@ -0,0 +1,29 @@ +# vim: ft=sh: + +# 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. +gitbmerge() { + ( + set -e + if [ -n "$(git log --grep="^fixup\!" HEAD.."$1")" ]; then + 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" + git worktree prune + fi + git merge --ff-only "$1" && git push && git branch -d "$1" && git push origin :"$1" + ) +} + +# Create new branch from HEAD +gitbnew() { + git branch "$1" HEAD + local NW="$(git rev-parse --show-toplevel)-$1" + git worktree add "$NW" $1 + cd "$NW" + git submodule update --init --recursive +} |