]> www.infradead.org Git - users/dedekind/aiaiai.git/commitdiff
git-find-base: add detection for possible duplicate patches
authorJacob Keller <jacob.e.keller@intel.com>
Mon, 31 Mar 2014 22:24:02 +0000 (15:24 -0700)
committerArtem Bityutskiy <artem.bityutskiy@linux.intel.com>
Thu, 3 Apr 2014 08:21:34 +0000 (11:21 +0300)
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@intel.com>
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
helpers/git-find-base

index bac6128b865784659c400c84c983e4a7f504289b..648b3a1ba598f5ffc8d451ccbb78d406b55c3b2b 100755 (executable)
@@ -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