[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [bug-patch] patch cannot handle >3 lines of context

From: Jörn Engel
Subject: Re: [bug-patch] patch cannot handle >3 lines of context
Date: Sat, 18 Jul 2015 17:46:17 -0700
User-agent: Mutt/1.5.23 (2014-03-12)

Hello Andreas!

On Sat, Jul 18, 2015 at 10:25:52PM +0200, Andreas Grünbacher wrote:
> I have tried removing this heuristic in the past. The result was lots
> of misapplied patches. I couldn't think of a better heuristic either.
> Changing these kinds of things is difficult: for example, distributions
> are using patch for applying hundreds of thousands of patches
> automatically during package builds. These kinds of mis-applied
> patches are relatively likely not to not lead to subsequent errors
> (like syntax errors in a C file).

I agree it is hard.  Another weird effect we saw was with repetitive
code.  The context for a patch existed twice in the same C file.  Git
picked one of them, patch the other.  Because some of us use git
quiltimport and other use quilt we eventually noticed the problem.  And
only because we had a compiler error - backtracking from runtime
failures to misapplied patches would be a nightmare.

Not sure if git-apply actually solves your problem with misapplied
patches or just cheats.  The problem for git is easier because git tends
to apply patches only once, while patch (through quilt, etc.) reapplies
the same patches hundreds of time onto a changing codebase.  Patch needs
to be 100x more reliable than git just for parity.

One option to solve my problem would be to disable the heuristic if you
have enough context.  By default patch could require three lines of
context on both sides to disable the heuristic.  Any less and it better
be near the beginning or end.

If we do that, we might also add a -C parameter similar to git-apply.
Thinking about these problems I am very tempted to use 5-line context
instead of 3-line context by default.  That will reduce the rate of
misapplied patches.  And patch -C5 would require 5-line context to
disable the heuristic.

Not sure.  This is a harder problem than I thought.


Logic can convince but only emotion can motivate.
-- Jonathan Alter

reply via email to

[Prev in Thread] Current Thread [Next in Thread]