summaryrefslogtreecommitdiff
path: root/git-add--interactive.perl
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2018-03-14 12:01:05 -0700
committerJunio C Hamano <gitster@pobox.com>2018-03-14 12:01:05 -0700
commitc5e2df04ac9dd731c729c6159d58c2288d794858 (patch)
treeb6db0972487a8a00694e6477deeea245888c6bf7 /git-add--interactive.perl
parentbd0f794342d5b3921f2d5d4bffce87ec7b7e4d96 (diff)
parent42f7d45428e260acf535ba0d55ecc91ee81e21da (diff)
downloadgit-c5e2df04ac9dd731c729c6159d58c2288d794858.tar.gz
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
Diffstat (limited to 'git-add--interactive.perl')
-rwxr-xr-xgit-add--interactive.perl8
1 files changed, 8 insertions, 0 deletions
diff --git a/git-add--interactive.perl b/git-add--interactive.perl
index 7a0c95fd0d..d190469cd8 100755
--- a/git-add--interactive.perl
+++ b/git-add--interactive.perl
@@ -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 => [],