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

Re: git-apply that handles rejects like merge conflicts

From
Jeff King <peff@peff.net>
Date
Nov 8, 2011, 05:46 UTC
Message-ID
<20111108054643.GC29643@sigill.intra.peff.net>
In-Reply-To
<7v4nyf1opf.fsf@alter.siamese.dyndns.org>
On Mon, Nov 07, 2011 at 03:45:48PM -0800, Junio C Hamano wrote:
Show 12 quoted lines
> Jeff King <peff@peff.net> writes:
> 
> > In the general case, you can't represent all failed hunks with conflict
> > markers, can you?
> 
> Conflict markers come from the use of a 3-way merge, and if you were to do
> a 3-way merge, by definition, you would need some way to tell where the
> preimage of the patch and the target tree you are attempting to apply the
> patch forked from. That's done by fall-back-3way in "am -3".
> 
> You _could_ lift that logic out of "am -3", but I do not think it is worth
> the effort to do so (IOW, I do not see a reason to avoid "am -3").

I think it would purely be "I have a patch produced by git diff, not by git format-patch". If you want to use "am -3", you would have to dress up your patch with mail headers.

In practice, this doesn't come up much for me. I think I was using "git diff >patch" as a poor-man's stash (and I did just stick some fake headers in, and "git reset HEAD^" afterwards). But maybe other workflows deal with this more.

But I think there are two questions:
  1. Should am's 3-way fallback be made more easily available to users
     of regular "apply"?
  2. Short of doing a 3-way merge, are there better ways to represent
     failed hunks in the patch target itself, rather than saving ".rej"
     files?
I'm actually not sure which one Ori was asking about.
-Peff
Previous: Junio C HamanoNext: Junio C Hamano
Message 5 of 10 in “git-apply that handles rejects like merge conflicts”
  1. Ori AvtalionNov 7, 2011
  2. Jeff KingNov 7, 2011
  3. Ori AvtalionNov 7, 2011
  4. Junio C HamanoNov 7, 2011
  5. Jeff KingNov 8, 2011
  6. Junio C HamanoNov 8, 2011
  7. Ori AvtalionNov 8, 2011
  8. Jeff KingNov 8, 2011
  9. Bert WesargNov 8, 2011
  10. Jeff KingNov 8, 2011

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.