@@ -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,15 +2308,19 @@ 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 ;
2313
2318
}
2314
2319
2315
- if (file_exists (git_path_revert_head (r ))) {
2316
- 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 )
2317
2324
warning (_ ("cancelling a revert in progress" ));
2318
2325
opts .action = REPLAY_REVERT ;
2319
2326
need_cleanup = 1 ;
@@ -2671,8 +2678,9 @@ static int create_seq_dir(struct repository *r)
2671
2678
enum replay_action action ;
2672
2679
const char * in_progress_error = NULL ;
2673
2680
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 ));
2681
+ unsigned int advise_skip =
2682
+ refs_ref_exists (get_main_ref_store (r ), "REVERT_HEAD" ) ||
2683
+ refs_ref_exists (get_main_ref_store (r ), "CHERRY_PICK_HEAD" );
2676
2684
2677
2685
if (!sequencer_get_last_command (r , & action )) {
2678
2686
switch (action ) {
@@ -2771,8 +2779,8 @@ static int rollback_single_pick(struct repository *r)
2771
2779
{
2772
2780
struct object_id head_oid ;
2773
2781
2774
- if (!file_exists ( git_path_cherry_pick_head (r )) &&
2775
- !file_exists ( git_path_revert_head (r )))
2782
+ if (!refs_ref_exists ( get_main_ref_store (r ), "CHERRY_PICK_HEAD" ) &&
2783
+ !refs_ref_exists ( get_main_ref_store (r ), "REVERT_HEAD" ))
2776
2784
return error (_ ("no cherry-pick or revert in progress" ));
2777
2785
if (read_ref_full ("HEAD" , 0 , & head_oid , NULL ))
2778
2786
return error (_ ("cannot resolve HEAD" ));
@@ -2866,15 +2874,16 @@ int sequencer_skip(struct repository *r, struct replay_opts *opts)
2866
2874
*/
2867
2875
switch (opts -> action ) {
2868
2876
case REPLAY_REVERT :
2869
- if (!file_exists ( git_path_revert_head (r ))) {
2877
+ if (!refs_ref_exists ( get_main_ref_store (r ), "REVERT_HEAD" )) {
2870
2878
if (action != REPLAY_REVERT )
2871
2879
return error (_ ("no revert in progress" ));
2872
2880
if (!rollback_is_safe ())
2873
2881
goto give_advice ;
2874
2882
}
2875
2883
break ;
2876
2884
case REPLAY_PICK :
2877
- if (!file_exists (git_path_cherry_pick_head (r ))) {
2885
+ if (!refs_ref_exists (get_main_ref_store (r ),
2886
+ "CHERRY_PICK_HEAD" )) {
2878
2887
if (action != REPLAY_PICK )
2879
2888
return error (_ ("no cherry-pick in progress" ));
2880
2889
if (!rollback_is_safe ())
@@ -3569,7 +3578,8 @@ static int do_merge(struct repository *r,
3569
3578
oid_to_hex (& j -> item -> object .oid ));
3570
3579
3571
3580
strbuf_release (& ref_name );
3572
- unlink (git_path_cherry_pick_head (r ));
3581
+ refs_delete_ref (get_main_ref_store (r ), "" , "CHERRY_PICK_HEAD" ,
3582
+ NULL , 0 );
3573
3583
rollback_lock_file (& lock );
3574
3584
3575
3585
rollback_lock_file (& lock );
@@ -4201,8 +4211,8 @@ static int continue_single_pick(struct repository *r)
4201
4211
{
4202
4212
const char * argv [] = { "commit" , NULL };
4203
4213
4204
- if (!file_exists ( git_path_cherry_pick_head (r )) &&
4205
- !file_exists ( git_path_revert_head (r )))
4214
+ if (!refs_ref_exists ( get_main_ref_store (r ), "CHERRY_PICK_HEAD" ) &&
4215
+ !refs_ref_exists ( get_main_ref_store (r ), "REVERT_HEAD" ))
4206
4216
return error (_ ("no cherry-pick or revert in progress" ));
4207
4217
return run_command_v_opt (argv , RUN_GIT_CMD );
4208
4218
}
@@ -4318,9 +4328,10 @@ static int commit_staged_changes(struct repository *r,
4318
4328
}
4319
4329
4320
4330
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 ))
4331
+ if (refs_ref_exists (get_main_ref_store (r ),
4332
+ "CHERRY_PICK_HEAD" ) &&
4333
+ refs_delete_ref (get_main_ref_store (r ), "" ,
4334
+ "CHERRY_PICK_HEAD" , NULL , 0 ))
4324
4335
return error (_ ("could not remove CHERRY_PICK_HEAD" ));
4325
4336
if (!final_fixup )
4326
4337
return 0 ;
@@ -4379,8 +4390,9 @@ int sequencer_continue(struct repository *r, struct replay_opts *opts)
4379
4390
4380
4391
if (!is_rebase_i (opts )) {
4381
4392
/* Verify that the conflict has been resolved */
4382
- if (file_exists (git_path_cherry_pick_head (r )) ||
4383
- file_exists (git_path_revert_head (r ))) {
4393
+ if (refs_ref_exists (get_main_ref_store (r ),
4394
+ "CHERRY_PICK_HEAD" ) ||
4395
+ refs_ref_exists (get_main_ref_store (r ), "REVERT_HEAD" )) {
4384
4396
res = continue_single_pick (r );
4385
4397
if (res )
4386
4398
goto release_todo_list ;
@@ -5443,7 +5455,7 @@ int todo_list_rearrange_squash(struct todo_list *todo_list)
5443
5455
5444
5456
int sequencer_determine_whence (struct repository * r , enum commit_whence * whence )
5445
5457
{
5446
- if (file_exists ( git_path_cherry_pick_head (r ))) {
5458
+ if (refs_ref_exists ( get_main_ref_store (r ), "CHERRY_PICK_HEAD" )) {
5447
5459
struct object_id cherry_pick_head , rebase_head ;
5448
5460
5449
5461
if (file_exists (git_path_seq_dir ()))
0 commit comments