From: Jacob Keller Date: Mon, 18 Apr 2016 22:04:18 GMT Subject: Re: [PATCH 2/2] xdiff: implement empty line chunk heuristic Message-ID: In-Reply-To: <1461013950-12503-3-git-send-email-sbeller@google.com> On Mon, Apr 18, 2016 at 2:12 PM, Stefan Beller wrote: > In order to produce the smallest possible diff and combine several diff > hunks together, we implement a heuristic from GNU Diff which moves diff > hunks forward as far as possible when we find common context above and > below a diff hunk. This sometimes produces less readable diffs when > writing C, Shell, or other programming languages, ie: > > ... > /* > + * > + * > + */ > + > +/* > ... > > instead of the more readable equivalent of > > ... > +/* > + * > + * > + */ > + > /* > ... > > Implement the following heuristic to (optionally) produce the desired > output. > > If there are diff chunks which can be shifted around, shift each hunk > such that the last common empty line is below the chunk with the rest > of the context above. > > This heuristic appears to resolve the above example and several other > common issues without producing significantly weird results. However, as > with any heuristic it is not really known whether this will always be > more optimal. Thus, it can be disabled via diff.compactionHeuristic. > > Signed-off-by: Stefan Beller > Signed-off-by: Jacob Keller > Signed-off-by: Stefan Beller > --- Thanks Stephan and Junio, this looks pretty good. I think before it's merged we'd probably want to implement some sort of attributes which allows per-path configuration, incase it needs to be configured at all. I've got it applied to my local git, and I'm going to try to run a diff between enabled vs disabled on a large section of the Linux kernel history and a few other projects to see if I spot anything odd. Thanks, Jake