summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarlos Martín Nieto <cmn@dwim.me>2017-11-03 13:25:04 +0100
committerCarlos Martín Nieto <cmn@dwim.me>2017-11-03 13:28:33 +0100
commit7de843f49a79cc396f86147c80d542b1c3fd4608 (patch)
treeb9dbbd4911431093c2c77dd634f8054f5308764e
parent9601f7efda180a78c02f89a69a5cfad43cd8bd36 (diff)
downloadlibgit2-7de843f49a79cc396f86147c80d542b1c3fd4608.tar.gz
diff: enable the indent heuristic by default
The diff option is now reversed and can be used to get back to the previous form.
-rw-r--r--CHANGELOG.md9
-rw-r--r--include/git2/diff.h8
-rw-r--r--src/diff_xdiff.c6
3 files changed, 14 insertions, 9 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index dc8f87c0c..3aa785222 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -10,9 +10,12 @@ v0.26 + 1
caller for the case-insensitive portions of the key (existing sections are
used even if they don't match).
-* There is a new diff option, `GIT_DIFF_INDENT_HEURISTIC` which activates a
- heuristic which takes into account whitespace and indentation in order to
- produce better diffs when dealing with ambiguous diff hunks.
+* We now default to using the new diff heuristic (from the git tool) which takes
+ into account whitespace and indentation in order to produce better diffs when
+ dealing with ambiguous diff hunks.
+
+* There is a new diff option, `GIT_DIFF_DISABLE_INDENT_HEURISTIC` which disables
+ the indent-based heuristic to get back to the previous behaviour.
### API additions
diff --git a/include/git2/diff.h b/include/git2/diff.h
index 99a94bb6d..93f9cb0f7 100644
--- a/include/git2/diff.h
+++ b/include/git2/diff.h
@@ -207,11 +207,11 @@ typedef enum {
*/
GIT_DIFF_SHOW_BINARY = (1 << 30),
- /** Use a heuristic that takes indentation and whitespace into account
- * which generally can produce better diffs when dealing with ambiguous
- * diff hunks.
+ /** Disable the use of a heuristic that takes indentation and whitespace
+ * into account which generally can produce better diffs when dealing
+ * with ambiguous diff hunks.
*/
- GIT_DIFF_INDENT_HEURISTIC = (1 << 31),
+ GIT_DIFF_DISABLE_INDENT_HEURISTIC = (1 << 31),
} git_diff_option_t;
/**
diff --git a/src/diff_xdiff.c b/src/diff_xdiff.c
index 701eb1b5f..b101b0741 100644
--- a/src/diff_xdiff.c
+++ b/src/diff_xdiff.c
@@ -233,14 +233,16 @@ void git_xdiff_init(git_xdiff_output *xo, const git_diff_options *opts)
xo->config.ctxlen = opts ? opts->context_lines : 3;
xo->config.interhunkctxlen = opts ? opts->interhunk_lines : 0;
+ xo->params.flags |= XDF_INDENT_HEURISTIC;
+
if (flags & GIT_DIFF_IGNORE_WHITESPACE)
xo->params.flags |= XDF_WHITESPACE_FLAGS;
if (flags & GIT_DIFF_IGNORE_WHITESPACE_CHANGE)
xo->params.flags |= XDF_IGNORE_WHITESPACE_CHANGE;
if (flags & GIT_DIFF_IGNORE_WHITESPACE_EOL)
xo->params.flags |= XDF_IGNORE_WHITESPACE_AT_EOL;
- if (flags & GIT_DIFF_INDENT_HEURISTIC)
- xo->params.flags |= XDF_INDENT_HEURISTIC;
+ if (flags & GIT_DIFF_DISABLE_INDENT_HEURISTIC)
+ xo->params.flags &= ~XDF_INDENT_HEURISTIC;
if (flags & GIT_DIFF_PATIENCE)
xo->params.flags |= XDF_PATIENCE_DIFF;