From: Stefan Sperling Subject: Re: got patch vs git diff with renames To: Omar Polo Cc: gameoftrees@openbsd.org Date: Fri, 29 Apr 2022 12:18:32 +0200 On Fri, Apr 29, 2022 at 11:08:41AM +0200, Omar Polo wrote: > A recent mail on ports@ (the net/znc diff) reminded me that there's > still a corner case of git-style rename diffs that I forgot to handle: > renames without edits. Such diffs looks like this > > > diff --git a/net/znc/pkg/DESCR b/net/znc/pkg/DESCR-main > > similarity index 100% > > rename from net/znc/pkg/DESCR > > rename to net/znc/pkg/DESCR-main > > and don't have any hunks. I don't have any idea why they decided to > avoid the +++/--- syntax and include a "@@ -0,0 +0,0 @@" since > compatibility doesn't seem to be a concern... > > Here's a straightforward diff to handle this situation. I intend to > rename that "ok" variable in read_patch in a follow-up diff (needs the > same rename also in parse_hunk and parse_hdr.) I've also simplified the > test_patch_rename function other than adding a test case for this. > > comments/ok? Makes sense, ok. No idea yet what kind of output 'got diff' will eventually produce for renames. But we need to handle Git-style diffs in any case. > P.S.: i forgot that we supported the rename with an empty hunk "@@ -0,0 > +0,0 @@". Since git doesn't seem to handle it, and neither patch(1), I > intend to remove the support for it, but again, in a follow-up commit :) Agreed. If nobody else uses such empty hunks as a rename marker, then we shouldn't rely on this either.