@@ -381,7 +381,8 @@ static void print_advice(struct repository *r, int show_hint,
381
381
* (typically rebase --interactive) wants to take care
382
382
* of the commit itself so remove CHERRY_PICK_HEAD
383
383
*/
384
- unlink (git_path_cherry_pick_head (r ));
384
+ refs_delete_ref (get_main_ref_store (r ), "" , "CHERRY_PICK_HEAD" ,
385
+ NULL , 0 );
385
386
return ;
386
387
}
387
388
@@ -1455,7 +1456,8 @@ static int do_commit(struct repository *r,
1455
1456
author , opts , flags , & oid );
1456
1457
strbuf_release (& sb );
1457
1458
if (!res ) {
1458
- unlink (git_path_cherry_pick_head (r ));
1459
+ refs_delete_ref (get_main_ref_store (r ), "" ,
1460
+ "CHERRY_PICK_HEAD" , NULL , 0 );
1459
1461
unlink (git_path_merge_msg (r ));
1460
1462
if (!is_rebase_i (opts ))
1461
1463
print_commit_summary (r , NULL , & oid ,
@@ -1966,7 +1968,8 @@ static int do_pick_commit(struct repository *r,
1966
1968
flags |= ALLOW_EMPTY ;
1967
1969
} else if (allow == 2 ) {
1968
1970
drop_commit = 1 ;
1969
- unlink (git_path_cherry_pick_head (r ));
1971
+ refs_delete_ref (get_main_ref_store (r ), "" , "CHERRY_PICK_HEAD" ,
1972
+ NULL , 0 );
1970
1973
unlink (git_path_merge_msg (r ));
1971
1974
fprintf (stderr ,
1972
1975
_ ("dropping %s %s -- patch contents already upstream\n" ),
@@ -2305,8 +2308,10 @@ void sequencer_post_commit_cleanup(struct repository *r, int verbose)
2305
2308
struct replay_opts opts = REPLAY_OPTS_INIT ;
2306
2309
int need_cleanup = 0 ;
2307
2310
2308
- if (file_exists (git_path_cherry_pick_head (r ))) {
2309
- if (!unlink (git_path_cherry_pick_head (r )) && verbose )
2311
+ if (refs_ref_exists (get_main_ref_store (r ), "CHERRY_PICK_HEAD" )) {
2312
+ if (!refs_delete_ref (get_main_ref_store (r ), "" ,
2313
+ "CHERRY_PICK_HEAD" , NULL , 0 ) &&
2314
+ verbose )
2310
2315
warning (_ ("cancelling a cherry picking in progress" ));
2311
2316
opts .action = REPLAY_PICK ;
2312
2317
need_cleanup = 1 ;
@@ -2671,8 +2676,9 @@ static int create_seq_dir(struct repository *r)
2671
2676
enum replay_action action ;
2672
2677
const char * in_progress_error = NULL ;
2673
2678
const char * in_progress_advice = NULL ;
2674
- unsigned int advise_skip = file_exists (git_path_revert_head (r )) ||
2675
- file_exists (git_path_cherry_pick_head (r ));
2679
+ unsigned int advise_skip =
2680
+ file_exists (git_path_revert_head (r )) ||
2681
+ refs_ref_exists (get_main_ref_store (r ), "CHERRY_PICK_HEAD" );
2676
2682
2677
2683
if (!sequencer_get_last_command (r , & action )) {
2678
2684
switch (action ) {
@@ -2771,7 +2777,7 @@ static int rollback_single_pick(struct repository *r)
2771
2777
{
2772
2778
struct object_id head_oid ;
2773
2779
2774
- if (!file_exists ( git_path_cherry_pick_head (r )) &&
2780
+ if (!refs_ref_exists ( get_main_ref_store (r ), "CHERRY_PICK_HEAD" ) &&
2775
2781
!file_exists (git_path_revert_head (r )))
2776
2782
return error (_ ("no cherry-pick or revert in progress" ));
2777
2783
if (read_ref_full ("HEAD" , 0 , & head_oid , NULL ))
@@ -2874,7 +2880,8 @@ int sequencer_skip(struct repository *r, struct replay_opts *opts)
2874
2880
}
2875
2881
break ;
2876
2882
case REPLAY_PICK :
2877
- if (!file_exists (git_path_cherry_pick_head (r ))) {
2883
+ if (!refs_ref_exists (get_main_ref_store (r ),
2884
+ "CHERRY_PICK_HEAD" )) {
2878
2885
if (action != REPLAY_PICK )
2879
2886
return error (_ ("no cherry-pick in progress" ));
2880
2887
if (!rollback_is_safe ())
@@ -3569,7 +3576,8 @@ static int do_merge(struct repository *r,
3569
3576
oid_to_hex (& j -> item -> object .oid ));
3570
3577
3571
3578
strbuf_release (& ref_name );
3572
- unlink (git_path_cherry_pick_head (r ));
3579
+ refs_delete_ref (get_main_ref_store (r ), "" , "CHERRY_PICK_HEAD" ,
3580
+ NULL , 0 );
3573
3581
rollback_lock_file (& lock );
3574
3582
3575
3583
rollback_lock_file (& lock );
@@ -4201,7 +4209,7 @@ static int continue_single_pick(struct repository *r)
4201
4209
{
4202
4210
const char * argv [] = { "commit" , NULL };
4203
4211
4204
- if (!file_exists ( git_path_cherry_pick_head (r )) &&
4212
+ if (!refs_ref_exists ( get_main_ref_store (r ), "CHERRY_PICK_HEAD" ) &&
4205
4213
!file_exists (git_path_revert_head (r )))
4206
4214
return error (_ ("no cherry-pick or revert in progress" ));
4207
4215
return run_command_v_opt (argv , RUN_GIT_CMD );
@@ -4318,9 +4326,10 @@ static int commit_staged_changes(struct repository *r,
4318
4326
}
4319
4327
4320
4328
if (is_clean ) {
4321
- const char * cherry_pick_head = git_path_cherry_pick_head (r );
4322
-
4323
- if (file_exists (cherry_pick_head ) && unlink (cherry_pick_head ))
4329
+ if (refs_ref_exists (get_main_ref_store (r ),
4330
+ "CHERRY_PICK_HEAD" ) &&
4331
+ refs_delete_ref (get_main_ref_store (r ), "" ,
4332
+ "CHERRY_PICK_HEAD" , NULL , 0 ))
4324
4333
return error (_ ("could not remove CHERRY_PICK_HEAD" ));
4325
4334
if (!final_fixup )
4326
4335
return 0 ;
@@ -4379,7 +4388,8 @@ int sequencer_continue(struct repository *r, struct replay_opts *opts)
4379
4388
4380
4389
if (!is_rebase_i (opts )) {
4381
4390
/* Verify that the conflict has been resolved */
4382
- if (file_exists (git_path_cherry_pick_head (r )) ||
4391
+ if (refs_ref_exists (get_main_ref_store (r ),
4392
+ "CHERRY_PICK_HEAD" ) ||
4383
4393
file_exists (git_path_revert_head (r ))) {
4384
4394
res = continue_single_pick (r );
4385
4395
if (res )
@@ -5442,7 +5452,7 @@ int todo_list_rearrange_squash(struct todo_list *todo_list)
5442
5452
5443
5453
int sequencer_determine_whence (struct repository * r , enum commit_whence * whence )
5444
5454
{
5445
- if (file_exists ( git_path_cherry_pick_head (r ))) {
5455
+ if (refs_ref_exists ( get_main_ref_store (r ), "CHERRY_PICK_HEAD" )) {
5446
5456
struct object_id cherry_pick_head , rebase_head ;
5447
5457
5448
5458
if (file_exists (git_path_seq_dir ()))
0 commit comments