rebase: use OPT_RERERE_AUTOUPDATE()

As we have a macro for this it makes sense to use it. Having cmd_rebase() and cmd_rebase__interactive() use the same values for this option will be helpful when we start running interactive rebases without forking rebase--interactive. Signed-off-by: Phillip Wood <phillip.wood@dunelm.org.uk> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Phillip Wood committed Apr 17, 2019 at 15:30 UTC 6023c928aa07128b4270446e7735beb20b2c8096
1 file changed +13 -17
builtin/rebase.c
+13 -17
@@ -206,14 +206,13 @@ static int read_basic_state(struct rebase_options *opts)
206 &buf))
207 return -1;
208 if (!strcmp(buf.buf, "--rerere-autoupdate"))
209 - opts->allow_rerere_autoupdate = 1;
209 + opts->allow_rerere_autoupdate = RERERE_AUTOUPDATE;
210 else if (!strcmp(buf.buf, "--no-rerere-autoupdate"))
211 - opts->allow_rerere_autoupdate = 0;
211 + opts->allow_rerere_autoupdate = RERERE_NOAUTOUPDATE;
212 else
213 warning(_("ignoring invalid allow_rerere_autoupdate: "
214 "'%s'"), buf.buf);
215 - } else
216 - opts->allow_rerere_autoupdate = -1;
215 + }
216
217 if (file_exists(state_dir_path("gpg_sign_opt", opts))) {
218 strbuf_reset(&buf);
@@ -263,10 +262,11 @@ static int rebase_write_basic_state(struct rebase_options *opts)
262 if (opts->strategy_opts)
263 write_file(state_dir_path("strategy_opts", opts), "%s",
264 opts->strategy_opts);
266 - if (opts->allow_rerere_autoupdate >= 0)
265 + if (opts->allow_rerere_autoupdate > 0)
266 write_file(state_dir_path("allow_rerere_autoupdate", opts),
267 "-%s-rerere-autoupdate",
269 - opts->allow_rerere_autoupdate ? "" : "-no");
268 + opts->allow_rerere_autoupdate == RERERE_AUTOUPDATE ?
269 + "" : "-no");
270 if (opts->gpg_sign_opt)
271 write_file(state_dir_path("gpg_sign_opt", opts), "%s",
272 opts->gpg_sign_opt);
@@ -625,9 +625,9 @@ static int run_am(struct rebase_options *opts)
625 argv_array_push(&am.args, "--rebasing");
626 argv_array_pushf(&am.args, "--resolvemsg=%s", resolvemsg);
627 argv_array_push(&am.args, "--patch-format=mboxrd");
628 - if (opts->allow_rerere_autoupdate > 0)
628 + if (opts->allow_rerere_autoupdate == RERERE_AUTOUPDATE)
629 argv_array_push(&am.args, "--rerere-autoupdate");
630 - else if (opts->allow_rerere_autoupdate == 0)
630 + else if (opts->allow_rerere_autoupdate == RERERE_NOAUTOUPDATE)
631 argv_array_push(&am.args, "--no-rerere-autoupdate");
632 if (opts->gpg_sign_opt)
633 argv_array_push(&am.args, opts->gpg_sign_opt);
@@ -713,9 +713,9 @@ static int run_specific_rebase(struct rebase_options *opts)
713 argv_array_pushf(&child.args, "--cmd=%s", opts->cmd);
714 if (opts->allow_empty_message)
715 argv_array_push(&child.args, "--allow-empty-message");
716 - if (opts->allow_rerere_autoupdate > 0)
716 + if (opts->allow_rerere_autoupdate == RERERE_AUTOUPDATE)
717 argv_array_push(&child.args, "--rerere-autoupdate");
718 - else if (opts->allow_rerere_autoupdate == 0)
718 + else if (opts->allow_rerere_autoupdate == RERERE_NOAUTOUPDATE)
719 argv_array_push(&child.args, "--no-rerere-autoupdate");
720 if (opts->gpg_sign_opt)
721 argv_array_push(&child.args, opts->gpg_sign_opt);
@@ -764,9 +764,9 @@ static int run_specific_rebase(struct rebase_options *opts)
764 add_var(&script_snippet, "action", opts->action ? opts->action : "");
765 add_var(&script_snippet, "signoff", opts->signoff ? "--signoff" : "");
766 add_var(&script_snippet, "allow_rerere_autoupdate",
767 - opts->allow_rerere_autoupdate < 0 ? "" :
767 opts->allow_rerere_autoupdate ?
769 - "--rerere-autoupdate" : "--no-rerere-autoupdate");
768 + opts->allow_rerere_autoupdate == RERERE_AUTOUPDATE ?
769 + "--rerere-autoupdate" : "--no-rerere-autoupdate" : "");
770 add_var(&script_snippet, "keep_empty", opts->keep_empty ? "yes" : "");
771 add_var(&script_snippet, "autosquash", opts->autosquash ? "t" : "");
772 add_var(&script_snippet, "gpg_sign_opt", opts->gpg_sign_opt);
@@ -1007,7 +1007,6 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
1007 .type = REBASE_UNSPECIFIED,
1008 .flags = REBASE_NO_QUIET,
1009 .git_am_opts = ARGV_ARRAY_INIT,
1010 - .allow_rerere_autoupdate = -1,
1010 .allow_empty_message = 1,
1011 .git_format_patch_opt = STRBUF_INIT,
1012 };
@@ -1101,10 +1100,7 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
1100 OPT_SET_INT('p', "preserve-merges", &options.type,
1101 N_("try to recreate merges instead of ignoring "
1102 "them"), REBASE_PRESERVE_MERGES),
1104 - OPT_BOOL(0, "rerere-autoupdate",
1105 - &options.allow_rerere_autoupdate,
1106 - N_("allow rerere to update index with resolved "
1107 - "conflict")),
1103 + OPT_RERERE_AUTOUPDATE(&options.allow_rerere_autoupdate),
1104 OPT_BOOL('k', "keep-empty", &options.keep_empty,
1105 N_("preserve empty commits during rebase")),
1106 OPT_BOOL(0, "autosquash", &options.autosquash,