summaryrefslogtreecommitdiff
path: root/sequencer.c
diff options
context:
space:
mode:
authorPhillip Wood <phillip.wood@dunelm.org.uk>2019-04-17 10:23:29 (GMT)
committerJunio C Hamano <gitster@pobox.com>2019-04-19 03:05:28 (GMT)
commitdc42e9a83a9e9206566b6bc9b57f431b98682b29 (patch)
treec650fa02e5fd7c3294cc66e3ce1ac6f7ab31955a /sequencer.c
parent1055997e2fc707a15baf232df2ac481055c14321 (diff)
downloadgit-dc42e9a83a9e9206566b6bc9b57f431b98682b29.zip
git-dc42e9a83a9e9206566b6bc9b57f431b98682b29.tar.gz
git-dc42e9a83a9e9206566b6bc9b57f431b98682b29.tar.bz2
sequencer.c: save and restore cleanup mode
If the user specifies an explicit cleanup mode then save and restore it so that it is preserved by 'git cherry-pick --continue'. Signed-off-by: Phillip Wood <phillip.wood@dunelm.org.uk> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'sequencer.c')
-rw-r--r--sequencer.c28
1 files changed, 27 insertions, 1 deletions
diff --git a/sequencer.c b/sequencer.c
index 71636a3..501d99f 100644
--- a/sequencer.c
+++ b/sequencer.c
@@ -535,6 +535,24 @@ enum commit_msg_cleanup_mode get_cleanup_mode(const char *cleanup_arg,
die(_("Invalid cleanup mode %s"), cleanup_arg);
}
+/*
+ * NB using int rather than enum cleanup_mode to stop clang's
+ * -Wtautological-constant-out-of-range-compare complaining that the comparison
+ * is always true.
+ */
+static const char *describe_cleanup_mode(int cleanup_mode)
+{
+ static const char *modes[] = { "whitespace",
+ "verbatim",
+ "scissors",
+ "strip" };
+
+ if (cleanup_mode < ARRAY_SIZE(modes))
+ return modes[cleanup_mode];
+
+ BUG("invalid cleanup_mode provided (%d)", cleanup_mode);
+}
+
void append_conflicts_hint(struct index_state *istate,
struct strbuf *msgbuf)
{
@@ -2367,7 +2385,10 @@ static int populate_opts_cb(const char *key, const char *value, void *data)
opts->allow_rerere_auto =
git_config_bool_or_int(key, value, &error_flag) ?
RERERE_AUTOUPDATE : RERERE_NOAUTOUPDATE;
- else
+ else if (!strcmp(key, "options.default-msg-cleanup")) {
+ opts->explicit_cleanup = 1;
+ opts->default_msg_cleanup = get_cleanup_mode(value, 1);
+ } else
return error(_("invalid key: %s"), key);
if (!error_flag)
@@ -2771,6 +2792,11 @@ static int save_opts(struct replay_opts *opts)
res |= git_config_set_in_file_gently(opts_file, "options.allow-rerere-auto",
opts->allow_rerere_auto == RERERE_AUTOUPDATE ?
"true" : "false");
+
+ if (opts->explicit_cleanup)
+ res |= git_config_set_in_file_gently(opts_file,
+ "options.default-msg-cleanup",
+ describe_cleanup_mode(opts->default_msg_cleanup));
return res;
}