git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] apply: when -R, also reverse list of sections

From
Junio C Hamano <gitster@pobox.com>
Date
Oct 20, 2020, 20:06 UTC
Message-ID
<xmqqeelsbr2c.fsf@gitster.c.googlers.com>
In-Reply-To
<20201020191206.104924-1-jonathantanmy@google.com>
Jonathan Tan <jonathantanmy@google.com> writes:
Show 15 quoted lines
>> But I have to wonder if it breaks the support for (arguably outside
>> the Git usecase) input that has more than one patch that touches the
>> same path to blindly reverse the order of all patches
>
> Sorry for getting back to this so late.
>
> The only other case I can think of (besides symlink<->file) is
> directory<->file, and even in that case, I think blindly reversing the
> order still works.
>
> If a more sophisticated rearrangement was needed, I would think that
> even applying the patches in the forward direction (that is, without
> "-R") wouldn't work, since Git is sensitive to the order of the patches.
> So I don't think we need to support such input (since they wouldn't work
> in the forward direction anyway).

I wish you told that to those who added fn_table kludge to apply.c back when they did so. They apparently wanted to have a patch that has more than one "diff --git a/hello.c b/hello.c" that talks about the same file applied with a single invocation of "git apply". Perhaps what they did is already broken with "apply -R", and blind reversal of everything magically makes it work? Or what they did already works with "apply -R" and your blind reversal would break, unless you undo what they did?

Show 8 quoted lines
>> (instead of
>> the obvious implementation of the fix for the above stated problem
>> --- i.e. make sure the first patch is a deletion of a symlink and
>> what immediately follows is a creation of a regular file, and swap
>> them only in such a case).
>
> This would make patch application more robust, but I still appreciate
> the relative simplicity of the existing approach

I'd rather want to see that we keep the normal cases simple, i.e. majority parts of a patch with "apply -R" that did *not* have to futz with the application order will keep what we do, and if there are tricky cases like typechange diff, only special case them.

Thanks.
Previous: Jonathan TanNext: Junio C Hamano
Message 4 of 8 in “apply: when -R, also reverse list of sections”
  1. apply: when -R, also reverse list of sectionsJonathan Tan, Sep 28, 2020
  2. Junio C HamanoSep 28, 2020
  3. Jonathan TanOct 20, 2020
  4. Junio C HamanoOct 20, 2020
  5. Junio C HamanoOct 20, 2020
  6. Jonathan TanOct 20, 2020
  7. Junio C HamanoOct 20, 2020
  8. apply: when -R, also reverse list of sectionsJonathan Tan, Oct 20, 2020

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.