From: Phillip Wood Date: Tue, 30 Aug 2022 13:17:49 GMT Subject: Re: [PATCH v3 1/5] t3701: redefine what is "bogus" output of a diff filter Message-ID: <9261de42-3287-6ccb-6cf5-21c0a8ee1f17@gmail.com> In-Reply-To: Hi Dscho On 29/08/2022 16:11, Johannes Schindelin via GitGitGadget wrote: > From: Johannes Schindelin > > When parsing the colored version of a diff, the interactive `add` > command really relies on the colored version having the same number of > lines as the non-colored version. That is an invariant. > > However, in the 'detect bogus diffFilter output' test case in t3701, we > essentially required a hunk header that contains parseable `@@ ... @@` > hunk headers, and called all colored diffs without such hunks bogus. > > The reason for this is that we would like to show the users the adjusted > hunk headers _including_ the extra part after the `@@ ... @@` > information, which usually contains things like the function name or > soms such. > > Now, there is a _very_ popular diff colorizer called `diff-so-fancy` > that does not produce such colored diffs as the built-in `add` command > expects. Nevertheless, the Perl variant of the `add` command handles > those nicely, essentially by ignoring the hunk header and saying "there > is nothing else we can show except the original hunk header, even if we > had to adjust the line range and the original hunk header might get that > wrong". > > In preparation for teaching the built-in interactive `add` to be a bit > more lenient, let's change the 'detect bogus diffFilter output' test > case so that it verifies that a mismatched number of lines causes the > command to error out, but not an unparseable hunk header. The existing test deletes the first line of the diff[1] - so it is removing the "diff --git ..." header not the hunk header. This patch changes the filter to delete everything except the diff header which seems like a less realistic test. Best Wishes Phillip [1] To verify this I changed the filter to "sed 1d | tee filtered-diff". filtered diff-contains index 0889435..d95f3ad 100644 --- a/test +++ b/test @@ -1,6 +1 @@ -10 -20 -30 -40 -50 -60 +content > Signed-off-by: Johannes Schindelin > --- > t/t3701-add-interactive.sh | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/t/t3701-add-interactive.sh b/t/t3701-add-interactive.sh > index 3b7df9bed5a..88d8133f38f 100755 > --- a/t/t3701-add-interactive.sh > +++ b/t/t3701-add-interactive.sh > @@ -761,7 +761,7 @@ test_expect_success 'detect bogus diffFilter output' ' > git reset --hard && > > echo content >test && > - test_config interactive.diffFilter "sed 1d" && > + test_config interactive.diffFilter "sed q" && > printf y >y && > force_color test_must_fail git add -p '