Message ID | 20190417102330.24434-10-phillip.wood123@gmail.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | Fix scissors bug during conflict | expand |
On Wed, Apr 17, 2019 at 11:23:29AM +0100, Phillip Wood wrote: > From: Denton Liu <liu.denton@gmail.com> We should drop this line before applying the patch since Phillip did all of the hard work for this patch and he's the primary author. > > 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> > --- > sequencer.c | 28 +++++++++++++++++++++++++++- > 1 file changed, 27 insertions(+), 1 deletion(-) > > diff --git a/sequencer.c b/sequencer.c > index b049951c34..3f4b0896e3 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) > { > @@ -2366,7 +2384,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) > @@ -2770,6 +2791,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; > } > > -- > 2.21.0 >
Hi Denton On 17/04/2019 18:02, Denton Liu wrote: > On Wed, Apr 17, 2019 at 11:23:29AM +0100, Phillip Wood wrote: >> From: Denton Liu <liu.denton@gmail.com> > > We should drop this line before applying the patch since Phillip did all > of the hard work for this patch and he's the primary author. > >> >> If the user specifies an explicit cleanup mode then save and restore it >> so that it is preserved by 'git cherry-pick --continue'. Sorry when I removed your Signed-off-by: as you suggested I forget to change the authorship of the patch Best Wishes Phillip >> >> Signed-off-by: Phillip Wood <phillip.wood@dunelm.org.uk> >> --- >> sequencer.c | 28 +++++++++++++++++++++++++++- >> 1 file changed, 27 insertions(+), 1 deletion(-) >> >> diff --git a/sequencer.c b/sequencer.c >> index b049951c34..3f4b0896e3 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) >> { >> @@ -2366,7 +2384,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) >> @@ -2770,6 +2791,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; >> } >> >> -- >> 2.21.0 >>
Hi Junio, On Wed, Apr 17, 2019 at 10:02:47AM -0700, Denton Liu wrote: > On Wed, Apr 17, 2019 at 11:23:29AM +0100, Phillip Wood wrote: > > From: Denton Liu <liu.denton@gmail.com> > > We should drop this line before applying the patch since Phillip did all > of the hard work for this patch and he's the primary author. Sorry, I made the mistake of suggesting that this line be dropped. This resulted in the patchset being queued with Phillip's gmail instead of his dunelm email. We should probably change the authorship to Phillip Wood <phillip.wood@dunelm.org.uk>. Thanks, Denton > > > > > 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> > > --- > > sequencer.c | 28 +++++++++++++++++++++++++++- > > 1 file changed, 27 insertions(+), 1 deletion(-) > > > > diff --git a/sequencer.c b/sequencer.c > > index b049951c34..3f4b0896e3 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) > > { > > @@ -2366,7 +2384,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) > > @@ -2770,6 +2791,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; > > } > > > > -- > > 2.21.0 > >
diff --git a/sequencer.c b/sequencer.c index b049951c34..3f4b0896e3 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) { @@ -2366,7 +2384,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) @@ -2770,6 +2791,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; }