diff options
author | Stefan Beller <sbeller@google.com> | 2016-04-19 17:21:30 +0200 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2016-04-19 19:53:34 +0200 |
commit | d634d61ed6c5f19948937012b5e3a0ed2d631d3f (patch) | |
tree | f5c443c8ae8a4def49ffd7f147ccc82ab1420805 /Documentation | |
parent | xdiff: add recs_match helper function (diff) | |
download | git-d634d61ed6c5f19948937012b5e3a0ed2d631d3f.tar.xz git-d634d61ed6c5f19948937012b5e3a0ed2d631d3f.zip |
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 'Documentation')
-rw-r--r-- | Documentation/diff-config.txt | 5 | ||||
-rw-r--r-- | Documentation/diff-options.txt | 6 |
2 files changed, 11 insertions, 0 deletions
diff --git a/Documentation/diff-config.txt b/Documentation/diff-config.txt index 6eaa45271c..9bf3e923cf 100644 --- a/Documentation/diff-config.txt +++ b/Documentation/diff-config.txt @@ -166,6 +166,11 @@ diff.tool:: include::mergetools-diff.txt[] +diff.compactionHeuristic:: + Set this option to enable an experimental heuristic that + shifts the hunk boundary in an attempt to make the resulting + patch easier to read. + diff.algorithm:: Choose a diff algorithm. The variants are as follows: + diff --git a/Documentation/diff-options.txt b/Documentation/diff-options.txt index 3ad6404dbc..b513023cd7 100644 --- a/Documentation/diff-options.txt +++ b/Documentation/diff-options.txt @@ -63,6 +63,12 @@ ifndef::git-format-patch[] Synonym for `-p --raw`. endif::git-format-patch[] +--compaction-heuristic:: +--no-compaction-heuristic:: + These are to help debugging and tuning an experimental + heuristic that shifts the hunk boundary in an attempt to + make the resulting patch easier to read. + --minimal:: Spend extra time to make sure the smallest possible diff is produced. |