]> git.ozlabs.org Git - next-scripts/commitdiff
merge_fix: cope with fixup patches no longer applying
authorStephen Rothwell <sfr@canb.auug.org.au>
Tue, 2 Feb 2010 23:14:02 +0000 (10:14 +1100)
committerStephen Rothwell <sfr@canb.auug.org.au>
Tue, 2 Feb 2010 23:14:02 +0000 (10:14 +1100)
merge_fix

index 96c0a4fcd8662dba21687673bcd4d11c1bd728ee..e0bb7adbc453717058c03e563623243fc1e1d201 100755 (executable)
--- 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