diff options
author | Stefan Beller <sbeller@google.com> | 2016-04-19 08:21:30 -0700 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2016-04-19 10:53:34 -0700 |
commit | d634d61ed6c5f19948937012b5e3a0ed2d631d3f (patch) | |
tree | f5c443c8ae8a4def49ffd7f147ccc82ab1420805 /xdiff/xdiff.h | |
parent | 92e5b62fec0e9b647429e8d3736c571c434dd375 (diff) | |
download | git-d634d61ed6c5f19948937012b5e3a0ed2d631d3f.tar.gz |
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>
Diffstat (limited to 'xdiff/xdiff.h')
-rw-r--r-- | xdiff/xdiff.h | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/xdiff/xdiff.h b/xdiff/xdiff.h index c0339919cc..d1dbb2750a 100644 --- a/xdiff/xdiff.h +++ b/xdiff/xdiff.h @@ -41,6 +41,8 @@ extern "C" { #define XDF_IGNORE_BLANK_LINES (1 << 7) +#define XDF_COMPACTION_HEURISTIC (1 << 8) + #define XDL_EMIT_FUNCNAMES (1 << 0) #define XDL_EMIT_COMMON (1 << 1) #define XDL_EMIT_FUNCCONTEXT (1 << 2) |