chiark / gitweb /
Notify when a patch was modified during a push operation
authorCatalin Marinas <catalin.marinas@gmail.com>
Thu, 27 Oct 2005 19:47:24 +0000 (20:47 +0100)
committerCatalin Marinas <catalin.marinas@gmail.com>
Thu, 27 Oct 2005 19:47:24 +0000 (20:47 +0100)
The logic of this is that when a "git-diff | git-apply" succeeds, the patch
is reported as unmodified. If the the above operation fails and the command
falls back to a three-way merge, the patch will be reported as modified.

Signed-off-by: Catalin Marinas <catalin.marinas@gmail.com>
stgit/commands/push.py
stgit/stack.py

index f6f4003330cdb2b11d53a4b913deb8cbca53c9a4..9924a782b3439afc61ec2dbdc982357579cc14b1 100644 (file)
@@ -35,8 +35,8 @@ conflicts, the '--undo' option can be used to revert the patch and the
 tree to the state before the operation. Conflicts raised during the
 push operation have to be fixed and the 'resolved' command run.
 
-The 'push' command also notifies when the patch becomes empty after
-the merge operation (i.e. it was fully merged upstream)."""
+The command also notifies when the patch becomes empty (fully merged
+upstream) or is modified (three-way merged) by the 'push' operation."""
 
 options = [make_option('-a', '--all',
                        help = 'push all the unapplied patches',
@@ -140,10 +140,12 @@ def func(parser, options, args):
         print 'Pushing patch "%s"...' % p,
         sys.stdout.flush()
 
-        crt_series.push_patch(p)
+        modified = crt_series.push_patch(p)
 
         if crt_series.empty_patch(p):
             print 'done (empty patch)'
+        elif modified:
+            print 'done (modified)'
         else:
             print 'done'
     print_crt_patch()
index b6cab0a11f057c68f2859834d61b7fbc18637f9f..cd7677bcbd1483d1c5cfcd11d5da4e4a70d0bc95 100644 (file)
@@ -638,6 +638,7 @@ class Series:
         top = patch.get_top()
 
         ex = None
+        modified = False
 
         # top != bottom always since we have a commit for each patch
         if head == bottom:
@@ -655,6 +656,10 @@ class Series:
             # Try the fast applying first. If this fails, fall back to the
             # three-way merge
             if not git.apply_diff(bottom, top):
+                # if git.apply_diff() fails, the patch requires a diff3
+                # merge and can be reported as modified
+                modified = True
+
                 # merge can fail but the patch needs to be pushed
                 try:
                     git.merge(bottom, head, top)
@@ -681,6 +686,8 @@ class Series:
             else:
                 raise StackException, str(ex)
 
+        return modified
+
     def undo_push(self):
         name = self.get_current()
         assert(name)