summaryrefslogtreecommitdiff
path: root/git-add--interactive.perl
diff options
context:
space:
mode:
authorJeff King <peff@peff.net>2018-03-03 05:58:49 (GMT)
committerJunio C Hamano <gitster@pobox.com>2018-03-05 20:49:45 (GMT)
commit42f7d45428e260acf535ba0d55ecc91ee81e21da (patch)
treec2f3d0af9f1037c0f97bcaaa1c178caaeea43ffa /git-add--interactive.perl
parentaf3570ed6ca97605d62ebe1836fc893014ae844b (diff)
downloadgit-42f7d45428e260acf535ba0d55ecc91ee81e21da.zip
git-42f7d45428e260acf535ba0d55ecc91ee81e21da.tar.gz
git-42f7d45428e260acf535ba0d55ecc91ee81e21da.tar.bz2
add--interactive: detect bogus diffFilter output
It's important that the diff-filter only filter the individual lines, and that there remain a one-to-one mapping between the input and output lines. Otherwise, things like hunk-splitting will behave quite unexpectedly (e.g., you think you are splitting at one point, but it has a different effect in the text patch we apply). We can't detect all problematic cases, but we can at least catch the obvious case where we don't even have the correct number of lines. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
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 964c3a7..ff02008 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 => [],