Patches with fuzz

3,370 views
Skip to first unread message

Jeroen Demeyer

unread,
Aug 1, 2011, 6:08:28 AM8/1/11
to sage-devel
Sometimes, it can happen that a patch only applies with "fuzz", for example:

$ hg import
http://trac.sagemath.org/sage_trac/raw-attachment/ticket/11298/trac11298_singular_standard_options.rebase4.7.1.a1.patch
patching file doc/en/reference/misc.rst
Hunk #1 succeeded at 10 with fuzz 2 (offset 0 lines).

My personal opinion on applying patches with fuzz is that I allow
patches with fuzz 1 but not with fuzz 2. I have seen at least two cases
where a "fuzz 2" patch was actually wrongly merged (I don't remember
which tickets).

Volker Braun

unread,
Aug 1, 2011, 6:24:24 AM8/1/11
to sage-...@googlegroups.com
On Monday, August 1, 2011 11:08:28 AM UTC+1, Jeroen Demeyer wrote:

My personal opinion on applying patches with fuzz is that I allow
patches with fuzz 1 but not with fuzz 2.


There is no guaranteed safe way of dealing with fuzzy patches. I think your position is reasonable. Ideally, the patch author would notice the fuzz and replace the patch on trac with a rediffed version. 


Simon King

unread,
Aug 1, 2011, 7:23:50 AM8/1/11
to sage-devel
Hi!

On 1 Aug., 12:08, Jeroen Demeyer <jdeme...@cage.ugent.be> wrote:
> Sometimes, it can happen that a patch only applies with "fuzz", for example:
>
> $ hg importhttp://trac.sagemath.org/sage_trac/raw-attachment/ticket/11298/trac11...
> patching file doc/en/reference/misc.rst
> Hunk #1 succeeded at 10 with fuzz 2 (offset 0 lines).

If a patch is rejected, then a file bla.py.rej is created, that shows
why the patch failed to apply.

Is there a tool that points out why there was a fuzz? I mean, it says
"Hunk #1", but it would be nice to have a line number as well.

Best regards,
Simon

Jason Grout

unread,
Aug 1, 2011, 11:12:12 AM8/1/11
to sage-...@googlegroups.com

Pardon my ignorance, but what does "fuzz n" mean and how is it different
for different values of n?

Thanks,

Jason


Volker Braun

unread,
Aug 1, 2011, 4:48:15 PM8/1/11
to sage-...@googlegroups.com
On Monday, August 1, 2011 4:12:12 PM UTC+1, jason wrote:

Pardon my ignorance, but what does "fuzz n" mean and how is it different
for different values of n?


Let me quote "man patch":

       With context diffs, and to a lesser extent  with  normal  diffs,  patch  can
       detect  when  the  line  numbers  mentioned  in the patch are incorrect, and
       attempts to find the correct place to apply each hunk of the  patch.   As  a
       first  guess, it takes the line number mentioned for the hunk, plus or minus
       any offset used in applying the previous hunk.  If that is not  the  correct
       place,  patch  scans both forwards and backwards for a set of lines matching
       the context given in the hunk.  First patch looks  for  a  place  where  all
       lines  of  the context match.  If no such place is found, and it's a context
       diff, and the maximum fuzz factor is set to 1 or  more,  then  another  scan
       takes place ignoring the first and last line of context.  If that fails, and
       the maximum fuzz factor is set to 2 or more, the  first  two  and  last  two
       lines  of context are ignored, and another scan is made.  (The default maxi‐
       mum fuzz factor is 2.)

So fuzz==n means that context matches only after removing the first and last n lines.
 
Reply all
Reply to author
Forward
0 new messages