]> git.ipfire.org Git - thirdparty/git.git/commitdiff
Merge branch 'js/add-p-diff-parsing-fix'
authorJunio C Hamano <gitster@pobox.com>
Fri, 9 Sep 2022 19:02:24 +0000 (12:02 -0700)
committerJunio C Hamano <gitster@pobox.com>
Fri, 9 Sep 2022 19:02:24 +0000 (12:02 -0700)
Those who use diff-so-fancy as the diff-filter noticed a regression
or two in the code that parses the diff output in the built-in
version of "add -p", which has been corrected.

* js/add-p-diff-parsing-fix:
  add -p: ignore dirty submodules
  add -p: gracefully handle unparseable hunk headers in colored diffs
  add -p: detect more mismatches between plain vs colored diffs

1  2 
t/t3701-add-interactive.sh

index 3b7df9bed5ad3e740090e2dc9b3fecb40479a65f,b6b309414ee99132d49d3a8b5dfb2059171eba87..5a7a0ea7e8319918ad98f9e5995c6ccd882cea06
@@@ -761,24 -761,22 +761,35 @@@ test_expect_success 'detect bogus diffF
        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 'handle iffy colored hunk headers' '
+       git reset --hard &&
+       echo content >test &&
+       printf n >n &&
+       force_color git -c interactive.diffFilter="sed s/.*@@.*/XX/" \
+               add -p >output 2>&1 <n &&
+       grep "^XX$" output
  '
  
 +test_expect_success 'handle very large filtered diff' '
 +      git reset --hard &&
 +      # The specific number here is not important, but it must
 +      # be large enough that the output of "git diff --color"
 +      # fills up the pipe buffer. 10,000 results in ~200k of
 +      # colored output.
 +      test_seq 10000 >test &&
 +      test_config interactive.diffFilter cat &&
 +      printf y >y &&
 +      force_color git add -p >output 2>&1 <y &&
 +      git diff-files --exit-code -- test
 +'
 +
  test_expect_success 'diff.algorithm is passed to `git diff-files`' '
        git reset --hard &&