@@ -44,6 +44,7 @@
#include "repository.h"
#include "pretty.h"
#include "wrapper.h"
+#include "xdiff-interface.h"
/**
* Returns the length of the first line of msg.
@@ -2433,7 +2434,7 @@ int cmd_am(int argc, const char **argv, const char *prefix)
if (argc == 2 && !strcmp(argv[1], "-h"))
usage_with_options(usage, options);
- git_config(git_default_config, NULL);
+ git_config(git_xmerge_config, NULL);
am_state_init(&state);
@@ -46,6 +46,7 @@
#include "tmp-objdir.h"
#include "tree.h"
#include "write-or-die.h"
+#include "xdiff-interface.h"
#define MAIL_DEFAULT_WRAP 72
#define COVER_FROM_AUTO_MAX_SUBJECT_LEN 100
@@ -567,6 +568,7 @@ static int cmd_log_walk(struct rev_info *rev)
static int git_log_config(const char *var, const char *value, void *cb)
{
const char *slot_name;
+ int status;
if (!strcmp(var, "format.pretty"))
return git_config_string(&fmt_pretty, var, value);
@@ -613,6 +615,9 @@ static int git_log_config(const char *var, const char *value, void *cb)
return 0;
}
+ status = git_xmerge_config(var, value, NULL);
+ if (status)
+ return status;
return git_diff_ui_config(var, value, cb);
}
@@ -9,6 +9,7 @@
#include "object-name.h"
#include "repository.h"
#include "xdiff-interface.h"
+#include "config.h"
static const char builtin_merge_recursive_usage[] =
"git %s <base>... -- <head> <remote> ...";
@@ -35,6 +36,8 @@ int cmd_merge_recursive(int argc, const char **argv, const char *prefix UNUSED)
char *better1, *better2;
struct commit *result;
+ git_config(git_xmerge_config, NULL);
+
init_merge_options(&o, the_repository);
if (argv[0] && ends_with(argv[0], "-subtree"))
o.subtree_shift = "";
@@ -17,6 +17,8 @@
#include "merge-blobs.h"
#include "quote.h"
#include "tree.h"
+#include "config.h"
+#include "xdiff-interface.h"
static int line_termination = '\n';
@@ -548,6 +550,8 @@ int cmd_merge_tree(int argc, const char **argv, const char *prefix)
OPT_END()
};
+ git_config(git_xmerge_config, NULL);
+
/* Parse arguments */
original_argc = argc - 1; /* ignoring argv[0] */
argc = parse_options(argc, argv, prefix, mt_options,
@@ -53,6 +53,7 @@
#include "wt-status.h"
#include "commit-graph.h"
#include "wrapper.h"
+#include "xdiff-interface.h"
#define DEFAULT_TWOHEAD (1<<0)
#define DEFAULT_OCTOPUS (1<<1)
@@ -669,6 +670,9 @@ static int git_merge_config(const char *k, const char *v, void *cb)
}
status = fmt_merge_msg_config(k, v, cb);
+ if (status)
+ return status;
+ status = git_xmerge_config(k, v, NULL);
if (status)
return status;
return git_diff_ui_config(k, v, cb);
@@ -25,6 +25,7 @@
#include "exec-cmd.h"
#include "reflog.h"
#include "add-interactive.h"
+#include "xdiff-interface.h"
#define INCLUDE_ALL_FILES 2
@@ -839,6 +840,7 @@ static int show_include_untracked;
static int git_stash_config(const char *var, const char *value, void *cb)
{
+ int status;
if (!strcmp(var, "stash.showstat")) {
show_stat = git_config_bool(var, value);
return 0;
@@ -851,6 +853,9 @@ static int git_stash_config(const char *var, const char *value, void *cb)
show_include_untracked = git_config_bool(var, value);
return 0;
}
+ status = git_xmerge_config(var, value, NULL);
+ if (status)
+ return status;
return git_diff_basic_config(var, value, cb);
}
@@ -3881,7 +3881,6 @@ static void merge_recursive_config(struct merge_options *opt)
} /* avoid erroring on values from future versions of git */
free(value);
}
- git_config(git_xmerge_config, NULL);
}
void init_merge_options(struct merge_options *opt,
@@ -47,6 +47,7 @@
#include "reset.h"
#include "branch.h"
#include "wrapper.h"
+#include "xdiff-interface.h"
#define GIT_REFLOG_ACTION "GIT_REFLOG_ACTION"
@@ -274,6 +275,9 @@ static int git_sequencer_config(const char *k, const char *v, void *cb)
if (opts->action == REPLAY_REVERT && !strcmp(k, "revert.reference"))
opts->commit_use_reference = git_config_bool(k, v);
+ status = git_xmerge_config(k, v, NULL);
+ if (status)
+ return status;
return git_diff_basic_config(k, v, NULL);
}
The configuration shouldn't be loaded whenever, it should be loaded *before* command options are parsed, so the code has the opportunity to override the configuration. merge_recursive_config() erroneously calls git_xmerge_config() directly, overriding any previous options, for example `--confligt=diff3`. To do this properly git_xmerge_config is explicitly called at the top level of all the commands that call merge_recursive_config() directly or indirectly. Some commands already do this, for example `git checkout`, others probably don't need it, like `git bisect` or `git diff-tree`. For the rest it's added. Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com> --- builtin/am.c | 3 ++- builtin/log.c | 5 +++++ builtin/merge-recursive.c | 3 +++ builtin/merge-tree.c | 4 ++++ builtin/merge.c | 4 ++++ builtin/stash.c | 5 +++++ merge-recursive.c | 1 - sequencer.c | 4 ++++ 8 files changed, 27 insertions(+), 2 deletions(-)