Skip to content

Commit 35843b1

Browse files
pcloudsgitster
authored andcommitted
rerere.c: remove implicit dependency on the_index
The reason rerere(), rerere_forget() and rerere_remaining() take a struct repository instead of struct index_state is not obvious from the patch: Deep in update_paths() and find_conflict(), hold_locked_index() and read_index() are called. These functions assumes the index path at $GIT_DIR/index which is not always true when you take an arbitrary index state. Taking a repository will allow us to point to the right index path later when we replace them with repo_ versions. Signed-off-by: Nguyễn Thái Ngọc Duy <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 58bf2a4 commit 35843b1

File tree

8 files changed

+81
-68
lines changed

8 files changed

+81
-68
lines changed

apply.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4630,7 +4630,7 @@ static int write_out_results(struct apply_state *state, struct patch *list)
46304630
}
46314631
string_list_clear(&cpath, 0);
46324632

4633-
rerere(0);
4633+
repo_rerere(state->repo, 0);
46344634
}
46354635

46364636
return errs;

builtin/am.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1604,7 +1604,7 @@ static int fall_back_threeway(const struct am_state *state, const char *index_pa
16041604
o.verbosity = 0;
16051605

16061606
if (merge_recursive_generic(&o, &our_tree, &their_tree, 1, bases, &result)) {
1607-
rerere(state->allow_rerere_autoupdate);
1607+
repo_rerere(the_repository, state->allow_rerere_autoupdate);
16081608
free(their_tree_name);
16091609
return error(_("Failed to merge in the changes."));
16101610
}
@@ -1899,7 +1899,7 @@ static void am_resolve(struct am_state *state)
18991899
goto next;
19001900
}
19011901

1902-
rerere(0);
1902+
repo_rerere(the_repository, 0);
19031903

19041904
do_commit(state);
19051905

builtin/commit.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1651,7 +1651,7 @@ int cmd_commit(int argc, const char **argv, const char *prefix)
16511651
"new_index file. Check that disk is not full and quota is\n"
16521652
"not exceeded, and then \"git reset HEAD\" to recover."));
16531653

1654-
rerere(0);
1654+
repo_rerere(the_repository, 0);
16551655
run_command_v_opt(argv_gc_auto, RUN_GIT_CMD);
16561656
run_commit_hook(use_editor, get_index_file(), "post-commit", NULL);
16571657
if (amend && !no_post_rewrite) {

builtin/merge.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -899,7 +899,7 @@ static int suggest_conflicts(void)
899899
fputs(msgbuf.buf, fp);
900900
strbuf_release(&msgbuf);
901901
fclose(fp);
902-
rerere(allow_rerere_auto);
902+
repo_rerere(the_repository, allow_rerere_auto);
903903
printf(_("Automatic merge failed; "
904904
"fix conflicts and then commit the result.\n"));
905905
return 1;

builtin/rerere.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,15 +70,15 @@ int cmd_rerere(int argc, const char **argv, const char *prefix)
7070
flags = RERERE_NOAUTOUPDATE;
7171

7272
if (argc < 1)
73-
return rerere(flags);
73+
return repo_rerere(the_repository, flags);
7474

7575
if (!strcmp(argv[0], "forget")) {
7676
struct pathspec pathspec;
7777
if (argc < 2)
7878
warning("'git rerere forget' without paths is deprecated");
7979
parse_pathspec(&pathspec, 0, PATHSPEC_PREFER_CWD,
8080
prefix, argv + 1);
81-
return rerere_forget(&pathspec);
81+
return rerere_forget(the_repository, &pathspec);
8282
}
8383

8484
if (!strcmp(argv[0], "clear")) {
@@ -91,7 +91,7 @@ int cmd_rerere(int argc, const char **argv, const char *prefix)
9191
for (i = 0; i < merge_rr.nr; i++)
9292
printf("%s\n", merge_rr.items[i].string);
9393
} else if (!strcmp(argv[0], "remaining")) {
94-
rerere_remaining(&merge_rr);
94+
rerere_remaining(the_repository, &merge_rr);
9595
for (i = 0; i < merge_rr.nr; i++) {
9696
if (merge_rr.items[i].util != RERERE_RESOLVED)
9797
printf("%s\n", merge_rr.items[i].string);

0 commit comments

Comments
 (0)