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

From:
Omar Polo <op@omarpolo.com>
Subject:
Re: rework the patch parser a bit
To:
gameoftrees@openbsd.org
Date:
Tue, 28 Jun 2022 00:21:46 +0200

Download raw body.

Thread
Omar Polo <op@omarpolo.com> wrote:
> At a higher level, the patch parser works like this:
> 
> 	while (find_patch()) {
> 		while (parse_hunk())
> 			;
> 		end_of_patch();
> 	}
> 
> this works for plain diffs and "git diffs", because each patch has a
> header.  However, "got diff" is different: it prints some info only at
> the top, like the "diff" and "commit -/+" headers.  It's fine IMHO, as
> it avoids some noise, but got patch needs to be tweaked.
> 
> Currently "got patch" will read the commit from the first patch, but if
> there is a second (or third, ...) patched file it forgets the commit and
> only read the "blob -" line.  This matter because if the diff3 merge
> ends up with a conflict we use a less-useful "blob abc" label instead of
> "commit xyz".  (In the future we may also want to use the commit info
> for other things.)
> 
> While here it'd be also nice to start making the patch parser a little
> bit strictier.
> 
> The following patch splits the parser and introduces a `patch_start'
> routine that finds the "diff" header (if there is).  This way, we can
> persist some state (commit id and wether it's a "git diff") while
> processing the content of the diff.

forgot one thing: the diff currently drops the support for reading the
"old style" got-diff with the commit id after the "diff" line and only
looks at "commit -".  It's not the end of the world, a diff generated
with a previous version of got can still be applied, just not with the
merge magic :)

(it's easy to take it back eventually, but now that we have a better
output format I'd like to support only that)