From e640a47db331c9b61f417359e01f3e7d1c706472 Mon Sep 17 00:00:00 2001 From: Jacob Keller Date: Mon, 31 Mar 2014 15:24:02 -0700 Subject: [PATCH] git-find-base: add detection for possible duplicate patches 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 Signed-off-by: Artem Bityutskiy --- 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 bac6128..648b3a1 100755 --- a/helpers/git-find-base +++ b/helpers/git-find-base @@ -73,15 +73,17 @@ while ($mbox =~ /^diff --git [iwcoab]\/(?\S+) [iwcoab]\/(?\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]\/(?\S+) [iwcoab]\/(?\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 -- 2.49.0