Merge branch 'jk/add-i-diff-filter'

The "interactive.diffFilter" used by "git add -i" must retain
one-to-one correspondence between its input and output, but it was
not enforced and caused end-user confusion.  We now at least make
sure the filtered result has the same number of lines as its input
to detect a broken filter.

* jk/add-i-diff-filter:
  add--interactive: detect bogus diffFilter output
  t3701: add a test for interactive.diffFilter
This commit is contained in:
Junio C Hamano
2018-03-14 12:01:05 -07:00
2 changed files with 28 additions and 0 deletions

View File

@ -705,6 +705,14 @@ sub parse_diff {
}
my (@hunk) = { TEXT => [], DISPLAY => [], TYPE => 'header' };
if (@colored && @colored != @diff) {
print STDERR
"fatal: mismatched output from interactive.diffFilter\n",
"hint: Your filter must maintain a one-to-one correspondence\n",
"hint: between its input and output lines.\n";
exit 1;
}
for (my $i = 0; $i < @diff; $i++) {
if ($diff[$i] =~ /^@@ /) {
push @hunk, { TEXT => [], DISPLAY => [],