From 254e1f09f97bfdf5e117a95103dad3fcd8b3eb5e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karel=20Ko=C4=8D=C3=AD?= Date: Thu, 26 Nov 2020 12:24:29 +0100 Subject: git: protect against self-merge --- shellrc.d/git | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'shellrc.d') diff --git a/shellrc.d/git b/shellrc.d/git index 3cf6117..7c34846 100644 --- a/shellrc.d/git +++ b/shellrc.d/git @@ -13,11 +13,15 @@ _gitbworktree() { gitbmerge() ( set -e [ -z "$(git log --grep="^fixup\!" HEAD.."$1")" ] || { - echo "First squash fixups!" + echo "First squash fixups!" >&2 return 1 } [ -z "$(git log --grep="^Apply .* suggestion(s) to " HEAD.."$1")" ] || { - echo "First squash suggestions!" + echo "First squash suggestions!" >&2 + return 1 + } + [ "$(git rev-parse HEAD)" != "$(git rev-parse "$1")" ] || { + echo "Nothing to merge! 🤷" >&2 return 1 } local wt -- cgit v1.2.3