aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/%HOME%
diff options
context:
space:
mode:
authorEgor Tensin <Egor.Tensin@gmail.com>2018-05-05 17:47:31 +0200
committerEgor Tensin <Egor.Tensin@gmail.com>2018-05-05 18:07:40 +0200
commit23d7043a4734933cd5d6a8d30aa025bdbd5a2d25 (patch)
tree8e067cae0714bfb917523ef0a51c28c60c17b300 /%HOME%
parentmysql.sh: `mysql --no-auto-rehash` (diff)
downloadlinux-home-23d7043a4734933cd5d6a8d30aa025bdbd5a2d25.tar.gz
linux-home-23d7043a4734933cd5d6a8d30aa025bdbd5a2d25.zip
.gitconfig: smarter alias.fixup
Diffstat (limited to '%HOME%')
-rw-r--r--%HOME%/.gitconfig26
1 files changed, 25 insertions, 1 deletions
diff --git a/%HOME%/.gitconfig b/%HOME%/.gitconfig
index 0758758..eaaf0e8 100644
--- a/%HOME%/.gitconfig
+++ b/%HOME%/.gitconfig
@@ -28,7 +28,31 @@
unhide = update-index --no-skip-worktree
hidden = !git ls-files -v | grep --basic-regexp \"^\\([[:lower:]]\\|S\\)\"
- fixup = !git commit -a --fixup=HEAD && GIT_EDITOR=true git rebase -i --autosquash HEAD~2
+ # I heard git might use sh for aliases, so I tried to keep that in
+ # mind. Didn't want to bother with an external script.
+ fixup = "! \
+f() { \
+ if ! git rev-parse --is-inside-work-tree >/dev/null ; then \
+ return 1 ; \
+ fi ; \
+\
+ has_staged_changes=-a ; \
+ git diff --cached --quiet --exit-code || has_staged_changes= ; \
+\
+ numof_parents=`git rev-list --parents -n 1 HEAD | wc --words` ; \
+ if [ \"$numof_parents\" -eq 1 ] ; then \
+ dest_ref=--root ; \
+ elif [ \"$numof_parents\" -eq 2 ] ; then \
+ dest_ref=HEAD^^ ; \
+ else \
+ echo \"Sure you want to fixup a merge commit?\" >&2 ; \
+ return 1 ; \
+ fi ; \
+\
+ git commit $has_staged_changes --fixup=HEAD && GIT_EDITOR=true git rebase -i --autosquash \"$dest_ref\" ; \
+} ; \
+f ; \
+"
[fetch]
prune = true
[log]