Skip to content

Commit b8825ef

Browse files
hanwengitster
authored andcommitted
sequencer: treat REVERT_HEAD as a pseudo ref
Signed-off-by: Han-Wen Nienhuys <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent b6d2558 commit b8825ef

File tree

4 files changed

+13
-14
lines changed

4 files changed

+13
-14
lines changed

path.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1528,7 +1528,6 @@ char *xdg_cache_home(const char *filename)
15281528
return NULL;
15291529
}
15301530

1531-
REPO_GIT_PATH_FUNC(revert_head, "REVERT_HEAD")
15321531
REPO_GIT_PATH_FUNC(squash_msg, "SQUASH_MSG")
15331532
REPO_GIT_PATH_FUNC(merge_msg, "MERGE_MSG")
15341533
REPO_GIT_PATH_FUNC(merge_rr, "MERGE_RR")

path.h

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,6 @@ void report_linked_checkout_garbage(void);
170170
}
171171

172172
struct path_cache {
173-
const char *revert_head;
174173
const char *squash_msg;
175174
const char *merge_msg;
176175
const char *merge_rr;
@@ -181,12 +180,11 @@ struct path_cache {
181180
const char *shallow;
182181
};
183182

184-
#define PATH_CACHE_INIT \
185-
{ \
186-
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL \
183+
#define PATH_CACHE_INIT \
184+
{ \
185+
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL \
187186
}
188187

189-
const char *git_path_revert_head(struct repository *r);
190188
const char *git_path_squash_msg(struct repository *r);
191189
const char *git_path_merge_msg(struct repository *r);
192190
const char *git_path_merge_rr(struct repository *r);

sequencer.c

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2317,8 +2317,10 @@ void sequencer_post_commit_cleanup(struct repository *r, int verbose)
23172317
need_cleanup = 1;
23182318
}
23192319

2320-
if (file_exists(git_path_revert_head(r))) {
2321-
if (!unlink(git_path_revert_head(r)) && verbose)
2320+
if (refs_ref_exists(get_main_ref_store(r), "REVERT_HEAD")) {
2321+
if (!refs_delete_ref(get_main_ref_store(r), "", "REVERT_HEAD",
2322+
NULL, 0) &&
2323+
verbose)
23222324
warning(_("cancelling a revert in progress"));
23232325
opts.action = REPLAY_REVERT;
23242326
need_cleanup = 1;
@@ -2677,7 +2679,7 @@ static int create_seq_dir(struct repository *r)
26772679
const char *in_progress_error = NULL;
26782680
const char *in_progress_advice = NULL;
26792681
unsigned int advise_skip =
2680-
file_exists(git_path_revert_head(r)) ||
2682+
refs_ref_exists(get_main_ref_store(r), "REVERT_HEAD") ||
26812683
refs_ref_exists(get_main_ref_store(r), "CHERRY_PICK_HEAD");
26822684

26832685
if (!sequencer_get_last_command(r, &action)) {
@@ -2778,7 +2780,7 @@ static int rollback_single_pick(struct repository *r)
27782780
struct object_id head_oid;
27792781

27802782
if (!refs_ref_exists(get_main_ref_store(r), "CHERRY_PICK_HEAD") &&
2781-
!file_exists(git_path_revert_head(r)))
2783+
!refs_ref_exists(get_main_ref_store(r), "REVERT_HEAD"))
27822784
return error(_("no cherry-pick or revert in progress"));
27832785
if (read_ref_full("HEAD", 0, &head_oid, NULL))
27842786
return error(_("cannot resolve HEAD"));
@@ -2872,7 +2874,7 @@ int sequencer_skip(struct repository *r, struct replay_opts *opts)
28722874
*/
28732875
switch (opts->action) {
28742876
case REPLAY_REVERT:
2875-
if (!file_exists(git_path_revert_head(r))) {
2877+
if (!refs_ref_exists(get_main_ref_store(r), "REVERT_HEAD")) {
28762878
if (action != REPLAY_REVERT)
28772879
return error(_("no revert in progress"));
28782880
if (!rollback_is_safe())
@@ -4210,7 +4212,7 @@ static int continue_single_pick(struct repository *r)
42104212
const char *argv[] = { "commit", NULL };
42114213

42124214
if (!refs_ref_exists(get_main_ref_store(r), "CHERRY_PICK_HEAD") &&
4213-
!file_exists(git_path_revert_head(r)))
4215+
!refs_ref_exists(get_main_ref_store(r), "REVERT_HEAD"))
42144216
return error(_("no cherry-pick or revert in progress"));
42154217
return run_command_v_opt(argv, RUN_GIT_CMD);
42164218
}
@@ -4390,7 +4392,7 @@ int sequencer_continue(struct repository *r, struct replay_opts *opts)
43904392
/* Verify that the conflict has been resolved */
43914393
if (refs_ref_exists(get_main_ref_store(r),
43924394
"CHERRY_PICK_HEAD") ||
4393-
file_exists(git_path_revert_head(r))) {
4395+
refs_ref_exists(get_main_ref_store(r), "REVERT_HEAD")) {
43944396
res = continue_single_pick(r);
43954397
if (res)
43964398
goto release_todo_list;

wt-status.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1678,7 +1678,7 @@ void wt_status_get_state(struct repository *r,
16781678
oidcpy(&state->cherry_pick_head_oid, &oid);
16791679
}
16801680
wt_status_check_bisect(NULL, state);
1681-
if (!stat(git_path_revert_head(r), &st) &&
1681+
if (refs_ref_exists(get_main_ref_store(r), "REVERT_HEAD") &&
16821682
!get_oid("REVERT_HEAD", &oid)) {
16831683
state->revert_in_progress = 1;
16841684
oidcpy(&state->revert_head_oid, &oid);

0 commit comments

Comments
 (0)