git/xdiff
Stefan Beller d634d61ed6 xdiff: implement empty line chunk heuristic
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 <sbeller@google.com>
Signed-off-by: Jacob Keller <jacob.e.keller@intel.com>
Signed-off-by: Stefan Beller <sbeller@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2016-04-19 10:53:34 -07:00
..
xdiff.h xdiff: implement empty line chunk heuristic 2016-04-19 10:53:34 -07:00
xdiffi.c xdiff: implement empty line chunk heuristic 2016-04-19 10:53:34 -07:00
xdiffi.h diff: add --ignore-blank-lines option 2013-06-19 15:17:45 -07:00
xemit.c C: have space around && and || operators 2013-10-16 10:26:39 -07:00
xemit.h diff: add --ignore-blank-lines option 2013-06-19 15:17:45 -07:00
xhistogram.c Correct common spelling mistakes in comments and tests 2013-04-12 13:38:40 -07:00
xinclude.h War on whitespace 2007-06-07 00:04:01 -07:00
xmacros.h xdiff: cast arguments for ctype functions to unsigned char 2010-10-06 10:46:45 -07:00
xmerge.c git-merge-file: do not add LF at EOF while applying unrelated change 2014-06-30 14:07:58 -07:00
xpatience.c xdiff: PATIENCE/HISTOGRAM are not independent option bits 2012-02-19 15:36:55 -08:00
xprepare.c xdiff: PATIENCE/HISTOGRAM are not independent option bits 2012-02-19 15:36:55 -08:00
xprepare.h War on whitespace 2007-06-07 00:04:01 -07:00
xtypes.h War on whitespace 2007-06-07 00:04:01 -07:00
xutils.c diff: add --ignore-blank-lines option 2013-06-19 15:17:45 -07:00
xutils.h diff: add --ignore-blank-lines option 2013-06-19 15:17:45 -07:00