On Wed, Nov 18, 2009 at 08:47:51AM +0200, Alan Barrett wrote: > On Mon, 16 Nov 2009, Stefan Sperling wrote: > > 5) Hunks are only applied if they do not overlap with any other hunk. > > Other patch implementations are able to deal with overlapping hunks. > > For example, consider this pair of hunks on the left, and a > corresponding single hunk on the right: > > @@ -1,5 +1,5 @@ @@ -1,9 +1,9 @@ > one one > two two > -three -three > +3 +3 > four four > five five > @@ -5,5 +5,5 @@ six > five -seven > six +7 > -seven eight > +7 nine > eight > nine > > Even though line 5 appears in both hunks on the left, I think the > intent is clear. I think that the only difference between the left > hand pair of hunks and the right hand single hunk is that, with > the pair of hunks, it should be possible for one hunk to fail while > the other succeeds, but with a single hunk there is no possibility > of partial success. >
I can see that applying overlapping hunks could be made to work in theory. But when do people use such patches in practice? Would gnu diff or svn diff ever produce anything like the example on the left? > An interactive patch assistant or conflict resolution tool might > want to offer the option of splitting a hunk into two or more > smaller hunks and re-trying each smaller hunk. "git add --patch" > offers something like this in a different context (getting ready > to commit a subset of the changes to a file). Right now I'm aiming for basic, but solid, patch support. Nothing fancy. This would clearly fall under "advanced" functionality, and there are more important "advanced" things to add first (such as support for git diff extensions to represent moves and copies, which are also supported by hg). Stefan