Skip to content

Commit ead98c1

Browse files
prertikgitster
authored andcommitted
builtin rebase: support --rerere-autoupdate
The `--rerere-autoupdate` option allows rerere to update the index with resolved conflicts. This commit follows closely the equivalent part of `git-legacy-rebase.sh`. Signed-off-by: Pratik Karki <[email protected]> Signed-off-by: Johannes Schindelin <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 73d51ed commit ead98c1

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

builtin/rebase.c

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ struct rebase_options {
9494
struct strbuf git_am_opt;
9595
const char *action;
9696
int signoff;
97+
int allow_rerere_autoupdate;
9798
};
9899

99100
static int is_interactive(struct rebase_options *opts)
@@ -174,6 +175,21 @@ static int read_basic_state(struct rebase_options *opts)
174175
opts->flags |= REBASE_FORCE;
175176
}
176177

178+
if (file_exists(state_dir_path("allow_rerere_autoupdate", opts))) {
179+
strbuf_reset(&buf);
180+
if (read_one(state_dir_path("allow_rerere_autoupdate", opts),
181+
&buf))
182+
return -1;
183+
if (!strcmp(buf.buf, "--rerere-autoupdate"))
184+
opts->allow_rerere_autoupdate = 1;
185+
else if (!strcmp(buf.buf, "--no-rerere-autoupdate"))
186+
opts->allow_rerere_autoupdate = 0;
187+
else
188+
warning(_("ignoring invalid allow_rerere_autoupdate: "
189+
"'%s'"), buf.buf);
190+
} else
191+
opts->allow_rerere_autoupdate = -1;
192+
177193
strbuf_release(&buf);
178194

179195
return 0;
@@ -256,6 +272,10 @@ static int run_specific_rebase(struct rebase_options *opts)
256272
add_var(&script_snippet, "switch_to", opts->switch_to);
257273
add_var(&script_snippet, "action", opts->action ? opts->action : "");
258274
add_var(&script_snippet, "signoff", opts->signoff ? "--signoff" : "");
275+
add_var(&script_snippet, "allow_rerere_autoupdate",
276+
opts->allow_rerere_autoupdate < 0 ? "" :
277+
opts->allow_rerere_autoupdate ?
278+
"--rerere-autoupdate" : "--no-rerere-autoupdate");
259279

260280
switch (opts->type) {
261281
case REBASE_AM:
@@ -488,6 +508,7 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
488508
.type = REBASE_UNSPECIFIED,
489509
.flags = REBASE_NO_QUIET,
490510
.git_am_opt = STRBUF_INIT,
511+
.allow_rerere_autoupdate = -1,
491512
};
492513
const char *branch_name;
493514
int ret, flags, total_argc, in_progress = 0;
@@ -553,6 +574,10 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
553574
OPT_SET_INT('p', "preserve-merges", &options.type,
554575
N_("try to recreate merges instead of ignoring "
555576
"them"), REBASE_PRESERVE_MERGES),
577+
OPT_BOOL(0, "rerere-autoupdate",
578+
&options.allow_rerere_autoupdate,
579+
N_("allow rerere to update index with resolved "
580+
"conflict")),
556581
OPT_END(),
557582
};
558583

0 commit comments

Comments
 (0)