From df2dca01f2353638f124fe21246e99d34226e8d3 Mon Sep 17 00:00:00 2001 From: Egor Tensin Date: Tue, 8 May 2018 01:08:24 +0200 Subject: .gitconfig: smarter alias.fixup --- %HOME%/.gitconfig | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to '%HOME%') diff --git a/%HOME%/.gitconfig b/%HOME%/.gitconfig index eaaf0e8..8e60aa8 100644 --- a/%HOME%/.gitconfig +++ b/%HOME%/.gitconfig @@ -36,8 +36,13 @@ f() { \ return 1 ; \ fi ; \ \ - has_staged_changes=-a ; \ - git diff --cached --quiet --exit-code || has_staged_changes= ; \ + add=-a ; \ + git diff --cached --quiet --exit-code || add= ; \ +\ + if [ -z \"${add}\" ] ; then \ + echo \"There're unstaged changes, can't rebase.\" >&2 ; \ + return 1 ; \ + fi ; \ \ numof_parents=`git rev-list --parents -n 1 HEAD | wc --words` ; \ if [ \"$numof_parents\" -eq 1 ] ; then \ @@ -49,7 +54,7 @@ f() { \ return 1 ; \ fi ; \ \ - git commit $has_staged_changes --fixup=HEAD && GIT_EDITOR=true git rebase -i --autosquash \"$dest_ref\" ; \ + git commit $add --fixup=HEAD && GIT_EDITOR=true git rebase -i --autosquash \"$dest_ref\" ; \ } ; \ f ; \ " -- cgit v1.2.3