diff options
-rw-r--r-- | add-patch.c | 5 | ||||
-rwxr-xr-x | t/t3701-add-interactive.sh | 5 |
2 files changed, 7 insertions, 3 deletions
diff --git a/add-patch.c b/add-patch.c index 509ca04456..34f3807ff3 100644 --- a/add-patch.c +++ b/add-patch.c @@ -592,7 +592,10 @@ static int parse_diff(struct add_p_state *s, const struct pathspec *ps) if (colored_eol) colored_p = colored_eol + 1; else if (p != pend) - /* colored shorter than non-colored? */ + /* non-colored has more lines? */ + goto mismatched_output; + else if (colored_p == colored_pend) + /* last line has no matching colored one? */ goto mismatched_output; else colored_p = colored_pend; diff --git a/t/t3701-add-interactive.sh b/t/t3701-add-interactive.sh index b354fb39de..6b1137e7c9 100755 --- a/t/t3701-add-interactive.sh +++ b/t/t3701-add-interactive.sh @@ -761,9 +761,10 @@ test_expect_success 'detect bogus diffFilter output' ' git reset --hard && echo content >test && - test_config interactive.diffFilter "sed 1d" && + test_config interactive.diffFilter "sed 6d" && printf y >y && - force_color test_must_fail git add -p <y + force_color test_must_fail git add -p <y >output 2>&1 && + grep "mismatched output" output ' test_expect_success 'diff.algorithm is passed to `git diff-files`' ' |