Skip to content

Commit 6023c92

Browse files
phillipwoodgitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 28dc09d commit 6023c92

File tree

1 file changed

+13
-17
lines changed

1 file changed

+13
-17
lines changed

builtin/rebase.c

Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -206,14 +206,13 @@ static int read_basic_state(struct rebase_options *opts)
206206
&buf))
207207
return -1;
208208
if (!strcmp(buf.buf, "--rerere-autoupdate"))
209-
opts->allow_rerere_autoupdate = 1;
209+
opts->allow_rerere_autoupdate = RERERE_AUTOUPDATE;
210210
else if (!strcmp(buf.buf, "--no-rerere-autoupdate"))
211-
opts->allow_rerere_autoupdate = 0;
211+
opts->allow_rerere_autoupdate = RERERE_NOAUTOUPDATE;
212212
else
213213
warning(_("ignoring invalid allow_rerere_autoupdate: "
214214
"'%s'"), buf.buf);
215-
} else
216-
opts->allow_rerere_autoupdate = -1;
215+
}
217216

218217
if (file_exists(state_dir_path("gpg_sign_opt", opts))) {
219218
strbuf_reset(&buf);
@@ -263,10 +262,11 @@ static int rebase_write_basic_state(struct rebase_options *opts)
263262
if (opts->strategy_opts)
264263
write_file(state_dir_path("strategy_opts", opts), "%s",
265264
opts->strategy_opts);
266-
if (opts->allow_rerere_autoupdate >= 0)
265+
if (opts->allow_rerere_autoupdate > 0)
267266
write_file(state_dir_path("allow_rerere_autoupdate", opts),
268267
"-%s-rerere-autoupdate",
269-
opts->allow_rerere_autoupdate ? "" : "-no");
268+
opts->allow_rerere_autoupdate == RERERE_AUTOUPDATE ?
269+
"" : "-no");
270270
if (opts->gpg_sign_opt)
271271
write_file(state_dir_path("gpg_sign_opt", opts), "%s",
272272
opts->gpg_sign_opt);
@@ -625,9 +625,9 @@ static int run_am(struct rebase_options *opts)
625625
argv_array_push(&am.args, "--rebasing");
626626
argv_array_pushf(&am.args, "--resolvemsg=%s", resolvemsg);
627627
argv_array_push(&am.args, "--patch-format=mboxrd");
628-
if (opts->allow_rerere_autoupdate > 0)
628+
if (opts->allow_rerere_autoupdate == RERERE_AUTOUPDATE)
629629
argv_array_push(&am.args, "--rerere-autoupdate");
630-
else if (opts->allow_rerere_autoupdate == 0)
630+
else if (opts->allow_rerere_autoupdate == RERERE_NOAUTOUPDATE)
631631
argv_array_push(&am.args, "--no-rerere-autoupdate");
632632
if (opts->gpg_sign_opt)
633633
argv_array_push(&am.args, opts->gpg_sign_opt);
@@ -713,9 +713,9 @@ static int run_specific_rebase(struct rebase_options *opts)
713713
argv_array_pushf(&child.args, "--cmd=%s", opts->cmd);
714714
if (opts->allow_empty_message)
715715
argv_array_push(&child.args, "--allow-empty-message");
716-
if (opts->allow_rerere_autoupdate > 0)
716+
if (opts->allow_rerere_autoupdate == RERERE_AUTOUPDATE)
717717
argv_array_push(&child.args, "--rerere-autoupdate");
718-
else if (opts->allow_rerere_autoupdate == 0)
718+
else if (opts->allow_rerere_autoupdate == RERERE_NOAUTOUPDATE)
719719
argv_array_push(&child.args, "--no-rerere-autoupdate");
720720
if (opts->gpg_sign_opt)
721721
argv_array_push(&child.args, opts->gpg_sign_opt);
@@ -764,9 +764,9 @@ static int run_specific_rebase(struct rebase_options *opts)
764764
add_var(&script_snippet, "action", opts->action ? opts->action : "");
765765
add_var(&script_snippet, "signoff", opts->signoff ? "--signoff" : "");
766766
add_var(&script_snippet, "allow_rerere_autoupdate",
767-
opts->allow_rerere_autoupdate < 0 ? "" :
768767
opts->allow_rerere_autoupdate ?
769-
"--rerere-autoupdate" : "--no-rerere-autoupdate");
768+
opts->allow_rerere_autoupdate == RERERE_AUTOUPDATE ?
769+
"--rerere-autoupdate" : "--no-rerere-autoupdate" : "");
770770
add_var(&script_snippet, "keep_empty", opts->keep_empty ? "yes" : "");
771771
add_var(&script_snippet, "autosquash", opts->autosquash ? "t" : "");
772772
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)
10071007
.type = REBASE_UNSPECIFIED,
10081008
.flags = REBASE_NO_QUIET,
10091009
.git_am_opts = ARGV_ARRAY_INIT,
1010-
.allow_rerere_autoupdate = -1,
10111010
.allow_empty_message = 1,
10121011
.git_format_patch_opt = STRBUF_INIT,
10131012
};
@@ -1101,10 +1100,7 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
11011100
OPT_SET_INT('p', "preserve-merges", &options.type,
11021101
N_("try to recreate merges instead of ignoring "
11031102
"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),
11081104
OPT_BOOL('k', "keep-empty", &options.keep_empty,
11091105
N_("preserve empty commits during rebase")),
11101106
OPT_BOOL(0, "autosquash", &options.autosquash,

0 commit comments

Comments
 (0)