From: Stephen Rothwell Date: Tue, 2 Feb 2010 23:14:02 +0000 (+1100) Subject: merge_fix: cope with fixup patches no longer applying X-Git-Url: https://git.ozlabs.org/?a=commitdiff_plain;h=319e8f0a1323c7a7bb9af1df9b22b39f226acde2;p=next-scripts merge_fix: cope with fixup patches no longer applying --- diff --git a/merge_fix b/merge_fix index 96c0a4f..e0bb7ad 100755 --- a/merge_fix +++ b/merge_fix @@ -29,10 +29,21 @@ execute() return ${PIPESTATUS[0]} } +old_head=$(git rev-parse HEAD) execute git am -3 "$patch" || { echo "git am failed" 1>&2 bash -i || exit } +new_head=$(git rev-parse HEAD) +[ "$old_head" = "$new_head" ] && { + echo "hmmm, looks like the patch was already applied or is unneeded" + exit 0 +} +[ "$(git diff ${old_head}.. | wc -c)" -eq 0 ] && { + echo "hmmm, committed soemthing, but diff is empty" 1>&2 + bash -i || exit +} + GIT_EDITOR=: execute git reset 'HEAD^' || { echo "git reset failed" 1>&2 bash -i || exit