git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Giuseppe Bilotta <giuseppe.bilotta@gmail.com>
To: Junio C Hamano <gitster@pobox.com>
Cc: git@vger.kernel.org,
	Felipe Contreras <felipe.contreras@gmail.com>,
	Nanako Shiraishi <nanako3@lavabit.com>
Subject: Re: [PATCHv4] git apply: option to ignore whitespace differences
Date: Tue, 4 Aug 2009 09:33:39 +0200	[thread overview]
Message-ID: <cb7bb73a0908040033u418169bbtcddbe1524d8f70ae@mail.gmail.com> (raw)
In-Reply-To: <7v8wi03usx.fsf@alter.siamese.dyndns.org>

On Tue, Aug 4, 2009 at 9:25 AM, Junio C Hamano<gitster@pobox.com> wrote:
> Giuseppe Bilotta <giuseppe.bilotta@gmail.com> writes:
>
>> diff --git a/t/t4107-apply-ignore-whitespace.sh b/t/t4107-apply-ignore-whitespace.sh
>> new file mode 100755
>> index 0000000..8e3fce3
>> --- /dev/null
>> +++ b/t/t4107-apply-ignore-whitespace.sh
>> @@ -0,0 +1,149 @@
>> ...
>> +cat > patch3.patch <<\EOF
>> +diff --git a/main.c b/main.c
>> +--- a/main.c
>> ++++ b/main.c
>> +@@ -10,1 +10,1 @@
>> +             print_int(func(i));
>> +EOF
>
> This part is triply troublesome in that:
>
>  (1) the payload ends with trailing whitespace which can be eaten by MUAs
>     (and I almost always use "git am" with --whitespace=fix);

This is also a problem with some other parts of that patch. I'll apply
the suggestion you mention below to all of them.

>  (2) even if we apply your patch correctly, it is very unobvious that you
>     are testing the case where the line has an unwanted trailing
>     whitespace; and

I'll add a comment for that that.

>  (3) a hunk without any added/deleted lines is an obviously artificial
>     test input that would not appear in real life, something one would
>     never think of doing unless one knows how "git apply" internally
>     works.  It makes the test too knowledgable about the implementation.

Right. I'll make it do something else too.

> You can fix the first two issues by doing:
>
>        sed -e 's/Z/ /g' >patch3.patch <<\EOF
>        ...
>        +Z      print_int(func(i));Z
>        EOF
>
> to make invisible SP stand out more for the benefit of people reading the
> test script (I know you did not have leading SP before HT in yours, but
> the above illustrates the visibility issues).  For other tests with test
> vector patches, visibility of whitespace is not much an issue, but this
> script is _all about_ whitespace, so anything that clarifies what is going
> on better would help.

Indeed.

>> +test_expect_success "S = patch1" \
>> +    'git-apply patch1.patch'
>> +
>> +test_expect_failure "F = patch2" \
>> +    'git-apply patch2.patch'
>
> Please say
>
>        test_expect_success "whitespace corrupted patch does not apply" '
>                test_must_fail git apply patch2.patch
>        '
>
> instead.
>
> "test_expect_failure" is a declaration that the command being tested (in
> this case "git apply") is faulty.  It also is a request for somebody
> interested to later fix it (again, in this case "git apply") to make this
> test pass.
>
> But you do _not_ want this to pass without an explicit ignore option, so
> test_expect_failure is inappropriate here.

Ah, interesting. This was the first test I wrote (mostly copied from
the original patch) and I didn't have a clear idea of the difference
between the expected failures (although the comment about  'fixing'
that the test printed when some failing case didn't should have put me
on the right track).

I'll resend with a fixed test.

-- 
Giuseppe "Oblomov" Bilotta

  reply	other threads:[~2009-08-04  7:34 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-07-31 20:40 [PATCHv4] git apply: option to ignore whitespace differences Giuseppe Bilotta
2009-08-04  7:25 ` Junio C Hamano
2009-08-04  7:33   ` Giuseppe Bilotta [this message]
  -- strict thread matches above, loose matches on Subject: below --
2009-08-04 11:16 Giuseppe Bilotta
2009-09-01  9:17 ` Junio C Hamano
2009-09-01  9:53   ` Giuseppe Bilotta

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=cb7bb73a0908040033u418169bbtcddbe1524d8f70ae@mail.gmail.com \
    --to=giuseppe.bilotta@gmail.com \
    --cc=felipe.contreras@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=nanako3@lavabit.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).