git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* fuzzy patch application
@ 2017-02-10 19:20 Nick Desaulniers
  2017-02-10 19:38 ` Junio C Hamano
  2017-02-10 20:57 ` Jeff King
  0 siblings, 2 replies; 9+ messages in thread
From: Nick Desaulniers @ 2017-02-10 19:20 UTC (permalink / raw)
  To: git

I frequently need to backport patches from the Linux kernel to older
kernel versions (Android Security).  My usual workflow for simple
patches is:

1. try `git am patch.txt`.
2. if that fails try `git apply -v patch.txt` then add commit message
manually.
3. if that fails try `patch -p1 < patch.txt` then add commit message
manually.
4. if that fails, manually fix bug based on patch.

My question is, why does `patch` seem to do a better job at applying
patches than `git am`?  It's almost like the `git` tools don't try to fuzz
the offsets.  Is there a way to tell git to try fuzzing offsets when
applying patches?

From the output of `patch` I ran recently (for a patch that
`git apply` would not apply):

patching file <filename.c>
Hunk #1 succeeded at 113 (offset -1 lines).
Hunk #2 succeeded at 435 (offset -3 lines).
Hunk #3 succeeded at 693 (offset 2 lines).
Hunk #4 succeeded at 1535 (offset -41 lines).
Hunk #5 succeeded at 1551 (offset -41 lines).
Hunk #6 succeeded at 1574 with fuzz 2 (offset -42 lines).
Hunk #7 succeeded at 1614 (offset -42 lines).

In fact, `git apply -v` errors for hunk #6.

I would guess maybe that there's an upper limit on the offset searched?
Also, I'm not sure what the `fuzz 2` part means exactly, but it seems like
`git apply` chokes when fuzzing is needed to properly apply a patch.

http://stackoverflow.com/q/6336440/1027966

-- 
Thanks,
~Nick Desaulniers

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2017-02-11  3:10 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-02-10 19:20 fuzzy patch application Nick Desaulniers
2017-02-10 19:38 ` Junio C Hamano
2017-02-10 20:57 ` Jeff King
2017-02-10 21:37   ` Stefan Beller
2017-02-10 21:48     ` Jeff King
2017-02-10 22:31       ` Junio C Hamano
2017-02-10 22:53         ` Junio C Hamano
2017-02-10 22:56           ` Nick Desaulniers
2017-02-11  3:09             ` Junio C Hamano

Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).