fromupstream: pause again if a conflict isn't resolved

Typically this happens when the user forgets to run `git am --continue`
or similar, like so:

    $ fromupstream pw://12345 --bug chromium:123 --test "not really"
    Please resolve the conflicts and restart the shell job when done. …
    $ (fix the conflicts)
    $ git add
    $ fg

Previously, this would add TEST=, BUG=, etc. to whatever was at HEAD
before, which is quite annoying and not immediately obvious. Now it'll
show an error and pause the script again.

TEST=`fromupstream msgid:// --buganizer 14987353 --test TODO`
     then `fg` immediately (multiple times if you like). Then run `git
     am --continue` and run `fg` one last time; it should then succeed.

Change-Id: Iaf28883ef4fbd58db812ffc7ce7ed4c7158dd1dc
Commit-Queue: Harry Cutts <>
Tested-by: Harry Cutts <>
Reviewed-by: Douglas Anderson <>
diff --git a/contrib/ b/contrib/
index f235d24..b5b89f1 100755
--- a/contrib/
+++ b/contrib/
@@ -109,6 +109,7 @@
     """Pause and go in the background till user resolves the conflicts."""
     git_root = _git(['rev-parse', '--show-toplevel'])
+    previous_head_hash = _git(['rev-parse', 'HEAD'])
     paths = (
         os.path.join(git_root, '.git', 'rebase-apply'),
@@ -122,9 +123,15 @@
                      'shell job when done. Kill this job if you '
                      'aborted the conflict.')
             os.kill(os.getpid(), signal.SIGTSTP)
-    # TODO: figure out what the state is after the merging, and go based on
-    # that (should we abort? skip? continue?)
-    # Perhaps check last commit message to see if it's the one we were using.
+    # Check the conflicts actually got resolved. Otherwise we'll end up
+    # modifying the wrong commit message and probably confusing people.
+    while previous_head_hash == _git(['rev-parse', 'HEAD']):
+        errprint('Error: no new commit has been made. Did you forget to run '
+                 '`git am --continue` or `git cherry-pick --continue`?')
+        errprint('Please create a new commit and restart the shell job (or kill'
+                 ' it if you aborted the conflict).')
+        os.kill(os.getpid(), signal.SIGTSTP)
 def _get_pw_url(project):
     """Retrieve the patchwork server URL from .pwclientrc.