Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/diff.c
diff options
context:
space:
mode:
Diffstat (limited to 'diff.c')
-rw-r--r--diff.c36
1 files changed, 29 insertions, 7 deletions
diff --git a/diff.c b/diff.c
index c6da383c56..dc5ab8b4fb 100644
--- a/diff.c
+++ b/diff.c
@@ -27,6 +27,7 @@
#endif
static int diff_detect_rename_default;
+static int diff_indent_heuristic; /* experimental */
static int diff_compaction_heuristic; /* experimental */
static int diff_rename_limit_default = 400;
static int diff_suppress_blank_empty;
@@ -177,6 +178,21 @@ void init_diff_ui_defaults(void)
diff_detect_rename_default = 1;
}
+int git_diff_heuristic_config(const char *var, const char *value, void *cb)
+{
+ if (!strcmp(var, "diff.indentheuristic")) {
+ diff_indent_heuristic = git_config_bool(var, value);
+ if (diff_indent_heuristic)
+ diff_compaction_heuristic = 0;
+ }
+ if (!strcmp(var, "diff.compactionheuristic")) {
+ diff_compaction_heuristic = git_config_bool(var, value);
+ if (diff_compaction_heuristic)
+ diff_indent_heuristic = 0;
+ }
+ return 0;
+}
+
int git_diff_ui_config(const char *var, const char *value, void *cb)
{
if (!strcmp(var, "diff.color") || !strcmp(var, "color.diff")) {
@@ -193,10 +209,6 @@ int git_diff_ui_config(const char *var, const char *value, void *cb)
diff_detect_rename_default = git_config_rename(var, value);
return 0;
}
- if (!strcmp(var, "diff.compactionheuristic")) {
- diff_compaction_heuristic = git_config_bool(var, value);
- return 0;
- }
if (!strcmp(var, "diff.autorefreshindex")) {
diff_auto_refresh_index = git_config_bool(var, value);
return 0;
@@ -237,6 +249,8 @@ int git_diff_ui_config(const char *var, const char *value, void *cb)
return 0;
}
+ if (git_diff_heuristic_config(var, value, cb) < 0)
+ return -1;
if (git_color_config(var, value, cb) < 0)
return -1;
@@ -3296,7 +3310,9 @@ void diff_setup(struct diff_options *options)
options->use_color = diff_use_color_default;
options->detect_rename = diff_detect_rename_default;
options->xdl_opts |= diff_algorithm;
- if (diff_compaction_heuristic)
+ if (diff_indent_heuristic)
+ DIFF_XDL_SET(options, INDENT_HEURISTIC);
+ else if (diff_compaction_heuristic)
DIFF_XDL_SET(options, COMPACTION_HEURISTIC);
options->orderfile = diff_order_file_cfg;
@@ -3818,9 +3834,15 @@ int diff_opt_parse(struct diff_options *options,
DIFF_XDL_SET(options, IGNORE_WHITESPACE_AT_EOL);
else if (!strcmp(arg, "--ignore-blank-lines"))
DIFF_XDL_SET(options, IGNORE_BLANK_LINES);
- else if (!strcmp(arg, "--compaction-heuristic"))
+ else if (!strcmp(arg, "--indent-heuristic")) {
+ DIFF_XDL_SET(options, INDENT_HEURISTIC);
+ DIFF_XDL_CLR(options, COMPACTION_HEURISTIC);
+ } else if (!strcmp(arg, "--no-indent-heuristic"))
+ DIFF_XDL_CLR(options, INDENT_HEURISTIC);
+ else if (!strcmp(arg, "--compaction-heuristic")) {
DIFF_XDL_SET(options, COMPACTION_HEURISTIC);
- else if (!strcmp(arg, "--no-compaction-heuristic"))
+ DIFF_XDL_CLR(options, INDENT_HEURISTIC);
+ } else if (!strcmp(arg, "--no-compaction-heuristic"))
DIFF_XDL_CLR(options, COMPACTION_HEURISTIC);
else if (!strcmp(arg, "--patience"))
options->xdl_opts = DIFF_WITH_ALG(options, PATIENCE_DIFF);