summaryrefslogtreecommitdiff
path: root/builtin
diff options
context:
space:
mode:
authorPhillip Wood <phillip.wood@dunelm.org.uk>2017-12-13 11:46:21 (GMT)
committerJunio C Hamano <gitster@pobox.com>2017-12-13 19:15:14 (GMT)
commit28d6daed4f119940ace31e523b3b272d3d153d04 (patch)
tree66856848873f995175be96b7052b8962e43ea287 /builtin
parentdb9476b50348c9d7e6a076cf4bd9ce0e70995439 (diff)
downloadgit-28d6daed4f119940ace31e523b3b272d3d153d04.zip
git-28d6daed4f119940ace31e523b3b272d3d153d04.tar.gz
git-28d6daed4f119940ace31e523b3b272d3d153d04.tar.bz2
sequencer: improve config handling
The previous config handling relied on global variables, called git_default_config() even when the key had already been handled by git_sequencer_config() and did not initialize the diff configuration variables. Improve this by: i) loading the default values for message cleanup and gpg signing of commits into struct replay_opts; ii) restructuring the code to return immediately once a key is handled; and iii) calling git_diff_basic_config(). Note that unfortunately it is not possible to return early if the key is handled by git_gpg_config() as it does not indicate to the caller if the key has been handled or not. The sequencer should probably have been calling git_diff_basic_config() before as it creates a patch when there are conflicts. The shell version uses 'diff-tree' to create the patch so calling git_diff_basic_config() should match that. Although 'git commit' calls git_diff_ui_config() I don't think the output of print_commit_summary() is affected by anything that is loaded by that as print_commit_summary() always turns on rename detection so would ignore the value in the user's configuration anyway. The other values loaded by git_diff_ui_config() are about the formatting of patches so are not relevant to print_commit_summary(). Signed-off-by: Phillip Wood <phillip.wood@dunelm.org.uk> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin')
-rw-r--r--builtin/rebase--helper.c13
-rw-r--r--builtin/revert.c15
2 files changed, 3 insertions, 25 deletions
diff --git a/builtin/rebase--helper.c b/builtin/rebase--helper.c
index 68194d3..decb8f7 100644
--- a/builtin/rebase--helper.c
+++ b/builtin/rebase--helper.c
@@ -9,17 +9,6 @@ static const char * const builtin_rebase_helper_usage[] = {
NULL
};
-static int git_rebase_helper_config(const char *k, const char *v, void *cb)
-{
- int status;
-
- status = git_sequencer_config(k, v, NULL);
- if (status)
- return status;
-
- return git_default_config(k, v, NULL);
-}
-
int cmd_rebase__helper(int argc, const char **argv, const char *prefix)
{
struct replay_opts opts = REPLAY_OPTS_INIT;
@@ -50,7 +39,7 @@ int cmd_rebase__helper(int argc, const char **argv, const char *prefix)
OPT_END()
};
- git_config(git_rebase_helper_config, NULL);
+ sequencer_init_config(&opts);
opts.action = REPLAY_INTERACTIVE_REBASE;
opts.allow_ff = 1;
diff --git a/builtin/revert.c b/builtin/revert.c
index 1938825..76f0a35 100644
--- a/builtin/revert.c
+++ b/builtin/revert.c
@@ -31,17 +31,6 @@ static const char * const cherry_pick_usage[] = {
NULL
};
-static int common_config(const char *k, const char *v, void *cb)
-{
- int status;
-
- status = git_sequencer_config(k, v, NULL);
- if (status)
- return status;
-
- return git_default_config(k, v, NULL);
-}
-
static const char *action_name(const struct replay_opts *opts)
{
return opts->action == REPLAY_REVERT ? "revert" : "cherry-pick";
@@ -219,7 +208,7 @@ int cmd_revert(int argc, const char **argv, const char *prefix)
if (isatty(0))
opts.edit = 1;
opts.action = REPLAY_REVERT;
- git_config(common_config, NULL);
+ sequencer_init_config(&opts);
res = run_sequencer(argc, argv, &opts);
if (res < 0)
die(_("revert failed"));
@@ -232,7 +221,7 @@ int cmd_cherry_pick(int argc, const char **argv, const char *prefix)
int res;
opts.action = REPLAY_PICK;
- git_config(common_config, NULL);
+ sequencer_init_config(&opts);
res = run_sequencer(argc, argv, &opts);
if (res < 0)
die(_("cherry-pick failed"));