mirror of
https://github.com/git/git
synced 2024-08-28 12:09:19 +00:00
Merge branch 'jm/maint-diff-words-with-sbe'
* jm/maint-diff-words-with-sbe: do not read beyond end of malloc'd buffer
This commit is contained in:
commit
34ad5a52b4
12
diff.c
12
diff.c
|
@ -1117,8 +1117,16 @@ static void fn_out_consume(void *priv, char *line, unsigned long len)
|
|||
emit_line(ecbdata->opt, plain, reset, line, len);
|
||||
fputs("~\n", ecbdata->opt->file);
|
||||
} else {
|
||||
/* don't print the prefix character */
|
||||
emit_line(ecbdata->opt, plain, reset, line+1, len-1);
|
||||
/*
|
||||
* Skip the prefix character, if any. With
|
||||
* diff_suppress_blank_empty, there may be
|
||||
* none.
|
||||
*/
|
||||
if (line[0] != '\n') {
|
||||
line++;
|
||||
len--;
|
||||
}
|
||||
emit_line(ecbdata->opt, plain, reset, line, len);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -307,4 +307,30 @@ test_language_driver python
|
|||
test_language_driver ruby
|
||||
test_language_driver tex
|
||||
|
||||
test_expect_success 'word-diff with diff.sbe' '
|
||||
cat >expect <<-\EOF &&
|
||||
diff --git a/pre b/post
|
||||
index a1a53b5..bc8fe6d 100644
|
||||
--- a/pre
|
||||
+++ b/post
|
||||
@@ -1,3 +1,3 @@
|
||||
a
|
||||
|
||||
[-b-]{+c+}
|
||||
EOF
|
||||
cat >pre <<-\EOF &&
|
||||
a
|
||||
|
||||
b
|
||||
EOF
|
||||
cat >post <<-\EOF &&
|
||||
a
|
||||
|
||||
c
|
||||
EOF
|
||||
test_when_finished "git config --unset diff.suppress-blank-empty" &&
|
||||
git config diff.suppress-blank-empty true &&
|
||||
word_diff --word-diff=plain
|
||||
'
|
||||
|
||||
test_done
|
||||
|
|
Loading…
Reference in a new issue