Skip to content

Commit 821f663

Browse files
pks-tgitster
authored andcommitted
sequencer: clean up pseudo refs with REF_NO_DEREF
When cleaning up the state-tracking pseudorefs CHERRY_PICK_HEAD or REVERT_HEAD we do not set REF_NO_DEREF. In the unlikely case where those refs are a symref we would thus end up deleting the symref targets, and not the symrefs themselves. Harden the code to use REF_NO_DEREF to fix this. Signed-off-by: Patrick Steinhardt <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 186b115 commit 821f663

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

sequencer.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -474,7 +474,7 @@ static void print_advice(struct repository *r, int show_hint,
474474
* of the commit itself so remove CHERRY_PICK_HEAD
475475
*/
476476
refs_delete_ref(get_main_ref_store(r), "", "CHERRY_PICK_HEAD",
477-
NULL, 0);
477+
NULL, REF_NO_DEREF);
478478
return;
479479
}
480480

@@ -1667,7 +1667,7 @@ static int do_commit(struct repository *r,
16671667
strbuf_release(&sb);
16681668
if (!res) {
16691669
refs_delete_ref(get_main_ref_store(r), "",
1670-
"CHERRY_PICK_HEAD", NULL, 0);
1670+
"CHERRY_PICK_HEAD", NULL, REF_NO_DEREF);
16711671
unlink(git_path_merge_msg(r));
16721672
if (!is_rebase_i(opts))
16731673
print_commit_summary(r, NULL, &oid,
@@ -2406,7 +2406,7 @@ static int do_pick_commit(struct repository *r,
24062406
} else if (allow == 2) {
24072407
drop_commit = 1;
24082408
refs_delete_ref(get_main_ref_store(r), "", "CHERRY_PICK_HEAD",
2409-
NULL, 0);
2409+
NULL, REF_NO_DEREF);
24102410
unlink(git_path_merge_msg(r));
24112411
unlink(git_path_auto_merge(r));
24122412
fprintf(stderr,
@@ -2802,7 +2802,7 @@ void sequencer_post_commit_cleanup(struct repository *r, int verbose)
28022802

28032803
if (refs_ref_exists(get_main_ref_store(r), "CHERRY_PICK_HEAD")) {
28042804
if (!refs_delete_ref(get_main_ref_store(r), "",
2805-
"CHERRY_PICK_HEAD", NULL, 0) &&
2805+
"CHERRY_PICK_HEAD", NULL, REF_NO_DEREF) &&
28062806
verbose)
28072807
warning(_("cancelling a cherry picking in progress"));
28082808
opts.action = REPLAY_PICK;
@@ -2811,7 +2811,7 @@ void sequencer_post_commit_cleanup(struct repository *r, int verbose)
28112811

28122812
if (refs_ref_exists(get_main_ref_store(r), "REVERT_HEAD")) {
28132813
if (!refs_delete_ref(get_main_ref_store(r), "", "REVERT_HEAD",
2814-
NULL, 0) &&
2814+
NULL, REF_NO_DEREF) &&
28152815
verbose)
28162816
warning(_("cancelling a revert in progress"));
28172817
opts.action = REPLAY_REVERT;
@@ -4116,7 +4116,7 @@ static int do_merge(struct repository *r,
41164116

41174117
strbuf_release(&ref_name);
41184118
refs_delete_ref(get_main_ref_store(r), "", "CHERRY_PICK_HEAD",
4119-
NULL, 0);
4119+
NULL, REF_NO_DEREF);
41204120
rollback_lock_file(&lock);
41214121

41224122
ret = run_command(&cmd);
@@ -5108,7 +5108,7 @@ static int commit_staged_changes(struct repository *r,
51085108
if (refs_ref_exists(get_main_ref_store(r),
51095109
"CHERRY_PICK_HEAD") &&
51105110
refs_delete_ref(get_main_ref_store(r), "",
5111-
"CHERRY_PICK_HEAD", NULL, 0))
5111+
"CHERRY_PICK_HEAD", NULL, REF_NO_DEREF))
51125112
return error(_("could not remove CHERRY_PICK_HEAD"));
51135113
if (unlink(git_path_merge_msg(r)) && errno != ENOENT)
51145114
return error_errno(_("could not remove '%s'"),

0 commit comments

Comments
 (0)