[PATCH aiaiai 4/5] git-find-base: add detection for possible duplicate patches

Jacob Keller jacob.e.keller at intel.com
Mon Mar 31 15:24:02 PDT 2014


Some users send a patch which includes both an attachment and inline of
the diff. This confuses git-find-base, because it will see equivalent
patch blobs. If we see the same diff hunk with identical git-index
information, print a warning, and ignore it.

This patch also rewords some of the other warnings to be more consistent
and always show the intial -> modified blobs for possible debugging.

Signed-off-by: Jacob Keller <jacob.e.keller at intel.com>
---
 helpers/git-find-base | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/helpers/git-find-base b/helpers/git-find-base
index bac6128b8657..648b3a1ba598 100755
--- a/helpers/git-find-base
+++ b/helpers/git-find-base
@@ -73,15 +73,17 @@ while ($mbox =~ /^diff --git [iwcoab]\/(?<oldfile>\S+) [iwcoab]\/(?<newfile>\S+)
     if (exists $files{$file}) {
         # Check if the blob matches the last known result of the file
         if (match_index($initialshortblob, $files{$file}{"modified"})) {
-            print STDERR "Found further modification of $file from $initialshortblob to $modifiedshortblob\n";
+            print STDERR "Found further modification of $file, ($initialshortblob -> $modifiedshortblob).\n";
             $files{$file}{"modified"} = $modifiedshortblob;
             next;
-        } else{
-            die "Found futher modification of $file that does not match expected index. Is the patch sequence out of order?";
+        } elsif (match_index($modifiedshortblob, $files{$file}{"modified"}) and match_index($initialshortblob, $files{$file}{"initial"})) {
+            print STDERR "Found duplicate modification of $file. Possible duplicate patch blob, or an incorrect patch format? Ignoring for now.\n";
+        } else {
+            die "Found futher modification of $file that does not match expected index, ($initialshortblob -> $modifiedshortblob). Is the patch sequence out of order?";
         }
     }
 
-    print STDERR "Found $file modified from $initialshortblob to $modifiedshortblob\n";
+    print STDERR "Found modification to $file, ($initialshortblob -> $modifiedshortblob).\n";
 
     # We have to process the short blob index into a full index value using
     # git-rev-parse, otherwise the lookup will fail.
@@ -89,7 +91,7 @@ while ($mbox =~ /^diff --git [iwcoab]\/(?<oldfile>\S+) [iwcoab]\/(?<newfile>\S+)
         or die "Couldn't open pipe to git-rev-parse: ", $!;
 
     my $initialblob = <$rev_parse>;
-    close $rev_parse or die"Couldn't expand the blob index: ", $? >> 8;
+    close $rev_parse or die "Couldn't expand the blob index: ", $? >> 8;
     chomp $initialblob;
 
     # Store the initial blob, as well as the index after modification
-- 
1.8.3.1




More information about the aiaiai mailing list