"GOT", but the "O" is a cute, smiling pufferfish. Index | Thread | Search

From:
Stefan Sperling <stsp@stsp.name>
Subject:
Re: got patch: add flag to ignore whitespace?
To:
Omar Polo <op@omarpolo.com>
Cc:
Mark Jamsek <mark@jamsek.com>, Christian Weisgerber <naddy@mips.inka.de>, gameoftrees@openbsd.org
Date:
Sun, 3 Jul 2022 16:39:01 +0200

Download raw body.

Thread
On Sun, Jul 03, 2022 at 03:28:55PM +0200, Omar Polo wrote:
> I have something in mind for applying diffs with fuzz (i.e. ignoring up
> to N lines of context) and I was thinking of doing some changes in the
> patch machinery to accomodate multiple passes on the same file.  With
> that we could move this whitespace-loose matching so it's only done in a
> second pass.  The idea could be:
> 
>  first pass: try to apply the patch, eventually at offset
>  second pass: try again with a whitespace loose matching
>  third pass: whitespaces + fuzz
> 
> ideas?  (note that it'll take still a while for this changes, can't
> provide an eta as i haven't started working on it yet :-)

That sounds like a good plan.

We might still want to provide options later to force 'got patch' to
skip a specific heuristic. But you could first go with the three-pass
approach you outlined above, without any options to control this
behaviour. We will see what to do next when someone runs into a problem.

Some things are still a bit unclear to me:

Will the 3 passes execute per-patch, or per-hunk?

You'll probably want to report progress only once a pass was successful?
Or will we see things like this, where it tries multiple passes in
sequence (here assuming a pass-per-hunk model, because output for
pass-per-patch would be even longer):

M foo.c
@@ hunk a,b c,d @@ failed to apply        <-- pass 1 fail
@@ hunk a,b c,d @@ has mangled whitespace <-- pass 2 ok
@@ hunk e,f g,h @@ failed to apply        <-- pass 1 fail
@@ hunk e,f g,h @@ failed to apply        <-- pass 2 fail
@@ hunk e,f g,h @@ has mangled whitespace <-- pass 3 ok
@@ hunk e,f g,h @@ applied with offset N  <-- pass 3 ok

Compare hidden progress reporting for failed passes:

M foo.c
@@ hunk a,b c,d @@ has mangled whitespace <-- pass 2 ok
@@ hunk e,f g,h @@ has mangled whitespace <-- pass 3 ok
@@ hunk e,f g,h @@ applied with offset N  <-- pass 3 ok