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

Re: Patch (apply) vs. Pull

From
Linus Torvalds <torvalds@osdl.org>
Date
Jun 23, 2005, 06:09 UTC
Message-ID
<Pine.LNX.4.58.0506222258290.11175@ppc970.osdl.org>
In-Reply-To
<Pine.LNX.4.21.0506230025420.30848-100000@iabervon.org>
On Thu, 23 Jun 2005, Daniel Barkalow wrote:
Show 5 quoted lines
> 
> I bet I'm misunderstanding fuzz; what I actually mean is that, if a patch
> applies after moving it, then regenerating it from the result would give
> the a patch with different line numbers; if these affect the hash, the
> author's tools will be sad.

What GNU patch calls "fuzz" is how badly the context can "not match". A "fuzz factor" of one allows the patch to apply even if the "outermost" of the context lines don't match up. See "man patch".

What you talk about is what they (and I) call "offset", and yes, you must ignore the line numbers when considering two patches identical, exactly because other patches may change their offsets.

So "git-apply" does apply patches that are offset from where the patch claims (and the "claimed position" is really nothing more than a "start searching here" parameter), but git-apply does not allow any fuzz.

Show 9 quoted lines
> > In fact, you could probably replace every run of contiguous whitespace
> > with a single space, and then you'd not have to worry about whitespace
> > differences either. That would be very simple to do, and quite workable: I
> > certainly think it sounds more reliable than just hoping that people
> > always pass on a "patch ID" in their emails..
> 
> That's actually quite plausible. The only case it wouldn't handle is when
> you actually discard parts, and I'm not sure at this point what other
> people should see there.

Yes. One small note of warning: different "diff" algorithms may under some (mostly unlikely) circumstances result in different patches for the difference between the same two files. So when comparin SHA1's of diffs this way, you should also hopefully have the same diff generation algorithm.

That's not likely to be a problem in practice, but it migh be something to keep in mind as a _possible_ source of confusion, where a patch isn't recognized only because it was generated differently from the one that we compare against.

In practice, this can happen today with the "-C" and "-M" flags to diff, of course: two patches look different (and get different SHA1 values) just because one was generated with "rename logic" turned on and the other wasn't..

Show 6 quoted lines
> > Yeah. It probably works well in 99% of the cases to just do a simple
> > "export as patch" + "apply on top with old commit message, author and
> > author-date".
> 
> I think that you'll get better results out of "merge with top" + "commit
> with old commit info, but not listing old commit as a parent".

If I understand you correctly, that assumes that you followed the whole chain, though, and that there was no cherry-picking.

I'd like to keep the door open here for cherry-picking or other transformations ("recreate tree _without_ that one commit"), because it would seem to also be a potentially good way to clean up history, not just move it forward, no?

		Linus
Previous: Daniel BarkalowNext: Daniel Barkalow
Message 17 of 33 in “Patch (apply) vs. Pull”
  1. Darrin ThompsonJun 20, 2005
  2. Junio C HamanoJun 20, 2005
  3. Darrin ThompsonJun 20, 2005
  4. Daniel BarkalowJun 21, 2005
  5. Junio C HamanoJun 22, 2005
  6. Catalin MarinasJun 22, 2005
  7. Linus TorvaldsJun 21, 2005
  8. Junio C HamanoJun 22, 2005
  9. Linus TorvaldsJun 22, 2005
  10. Daniel BarkalowJun 22, 2005
  11. Linus TorvaldsJun 22, 2005
  12. Daniel BarkalowJun 22, 2005
  13. Linus TorvaldsJun 22, 2005
  14. Daniel BarkalowJun 23, 2005
  15. Linus TorvaldsJun 23, 2005
  16. Daniel BarkalowJun 23, 2005
  17. Linus TorvaldsJun 23, 2005
  18. Daniel BarkalowJun 23, 2005
  19. Linus TorvaldsJun 23, 2005
  20. Daniel BarkalowJun 23, 2005
  21. Linus TorvaldsJun 23, 2005
  22. Linus TorvaldsJun 23, 2005
  23. Catalin MarinasJun 23, 2005
  24. Daniel BarkalowJun 23, 2005
  25. Catalin MarinasJun 24, 2005
  26. Martin LanghoffJun 23, 2005
  27. Darrin ThompsonJun 22, 2005
  28. Martin LanghoffJun 23, 2005
  29. 0/3 Rebasing for "individual developer" usageJunio C Hamano, Jun 23, 2005
  30. 1/3 git-commit-script: get commit message from an existing one.Junio C Hamano, Jun 23, 2005
  31. 2/3 git-cherry: find commits not merged upstream.Junio C Hamano, Jun 23, 2005
  32. 3/3 git-rebase-script: rebase local commits to new upstream head.Junio C Hamano, Jun 23, 2005
  33. Catalin MarinasJun 22, 2005

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.