@@ -1829,8 +1829,6 @@ static int files_peel_ref(struct ref_store *ref_store,
1829
1829
int flag ;
1830
1830
unsigned char base [20 ];
1831
1831
1832
- files_assert_main_repository (refs , "peel_ref" );
1833
-
1834
1832
if (current_ref_iter && current_ref_iter -> refname == refname ) {
1835
1833
struct object_id peeled ;
1836
1834
@@ -1840,7 +1838,8 @@ static int files_peel_ref(struct ref_store *ref_store,
1840
1838
return 0 ;
1841
1839
}
1842
1840
1843
- if (read_ref_full (refname , RESOLVE_REF_READING , base , & flag ))
1841
+ if (refs_read_ref_full (ref_store , refname ,
1842
+ RESOLVE_REF_READING , base , & flag ))
1844
1843
return -1 ;
1845
1844
1846
1845
/*
@@ -2008,15 +2007,15 @@ static struct ref_iterator *files_ref_iterator_begin(
2008
2007
* on success. On error, write an error message to err, set errno, and
2009
2008
* return a negative value.
2010
2009
*/
2011
- static int verify_lock (struct ref_lock * lock ,
2010
+ static int verify_lock (struct ref_store * ref_store , struct ref_lock * lock ,
2012
2011
const unsigned char * old_sha1 , int mustexist ,
2013
2012
struct strbuf * err )
2014
2013
{
2015
2014
assert (err );
2016
2015
2017
- if (read_ref_full ( lock -> ref_name ,
2018
- mustexist ? RESOLVE_REF_READING : 0 ,
2019
- lock -> old_oid .hash , NULL )) {
2016
+ if (refs_read_ref_full ( ref_store , lock -> ref_name ,
2017
+ mustexist ? RESOLVE_REF_READING : 0 ,
2018
+ lock -> old_oid .hash , NULL )) {
2020
2019
if (old_sha1 ) {
2021
2020
int save_errno = errno ;
2022
2021
strbuf_addf (err , "can't verify ref '%s'" , lock -> ref_name );
@@ -2085,8 +2084,9 @@ static struct ref_lock *lock_ref_sha1_basic(struct files_ref_store *refs,
2085
2084
resolve_flags |= RESOLVE_REF_ALLOW_BAD_NAME ;
2086
2085
2087
2086
files_ref_path (refs , & ref_file , refname );
2088
- resolved = !!resolve_ref_unsafe (refname , resolve_flags ,
2089
- lock -> old_oid .hash , type );
2087
+ resolved = !!refs_resolve_ref_unsafe (& refs -> base ,
2088
+ refname , resolve_flags ,
2089
+ lock -> old_oid .hash , type );
2090
2090
if (!resolved && errno == EISDIR ) {
2091
2091
/*
2092
2092
* we are trying to lock foo but we used to
@@ -2103,8 +2103,9 @@ static struct ref_lock *lock_ref_sha1_basic(struct files_ref_store *refs,
2103
2103
refname );
2104
2104
goto error_return ;
2105
2105
}
2106
- resolved = !!resolve_ref_unsafe (refname , resolve_flags ,
2107
- lock -> old_oid .hash , type );
2106
+ resolved = !!refs_resolve_ref_unsafe (& refs -> base ,
2107
+ refname , resolve_flags ,
2108
+ lock -> old_oid .hash , type );
2108
2109
}
2109
2110
if (!resolved ) {
2110
2111
last_errno = errno ;
@@ -2142,7 +2143,7 @@ static struct ref_lock *lock_ref_sha1_basic(struct files_ref_store *refs,
2142
2143
goto error_return ;
2143
2144
}
2144
2145
2145
- if (verify_lock (lock , old_sha1 , mustexist , err )) {
2146
+ if (verify_lock (& refs -> base , lock , old_sha1 , mustexist , err )) {
2146
2147
last_errno = errno ;
2147
2148
goto error_return ;
2148
2149
}
@@ -2397,15 +2398,15 @@ static void try_remove_empty_parents(struct files_ref_store *refs,
2397
2398
}
2398
2399
2399
2400
/* make sure nobody touched the ref, and unlink */
2400
- static void prune_ref (struct ref_to_prune * r )
2401
+ static void prune_ref (struct files_ref_store * refs , struct ref_to_prune * r )
2401
2402
{
2402
2403
struct ref_transaction * transaction ;
2403
2404
struct strbuf err = STRBUF_INIT ;
2404
2405
2405
2406
if (check_refname_format (r -> name , 0 ))
2406
2407
return ;
2407
2408
2408
- transaction = ref_transaction_begin ( & err );
2409
+ transaction = ref_store_transaction_begin ( & refs -> base , & err );
2409
2410
if (!transaction ||
2410
2411
ref_transaction_delete (transaction , r -> name , r -> sha1 ,
2411
2412
REF_ISPRUNING | REF_NODEREF , NULL , & err ) ||
@@ -2419,10 +2420,10 @@ static void prune_ref(struct ref_to_prune *r)
2419
2420
strbuf_release (& err );
2420
2421
}
2421
2422
2422
- static void prune_refs (struct ref_to_prune * r )
2423
+ static void prune_refs (struct files_ref_store * refs , struct ref_to_prune * r )
2423
2424
{
2424
2425
while (r ) {
2425
- prune_ref (r );
2426
+ prune_ref (refs , r );
2426
2427
r = r -> next ;
2427
2428
}
2428
2429
}
@@ -2446,7 +2447,7 @@ static int files_pack_refs(struct ref_store *ref_store, unsigned int flags)
2446
2447
if (commit_packed_refs (refs ))
2447
2448
die_errno ("unable to overwrite old ref-pack file" );
2448
2449
2449
- prune_refs (cbdata .ref_to_prune );
2450
+ prune_refs (refs , cbdata .ref_to_prune );
2450
2451
return 0 ;
2451
2452
}
2452
2453
@@ -2538,7 +2539,7 @@ static int files_delete_refs(struct ref_store *ref_store,
2538
2539
for (i = 0 ; i < refnames -> nr ; i ++ ) {
2539
2540
const char * refname = refnames -> items [i ].string ;
2540
2541
2541
- if (delete_ref ( NULL , refname , NULL , flags ))
2542
+ if (refs_delete_ref ( & refs -> base , NULL , refname , NULL , flags ))
2542
2543
result |= error (_ ("could not remove reference %s" ), refname );
2543
2544
}
2544
2545
@@ -2660,7 +2661,8 @@ static int files_rename_ref(struct ref_store *ref_store,
2660
2661
goto out ;
2661
2662
}
2662
2663
2663
- if (!resolve_ref_unsafe (oldrefname , RESOLVE_REF_READING | RESOLVE_REF_NO_RECURSE ,
2664
+ if (!refs_resolve_ref_unsafe (& refs -> base , oldrefname ,
2665
+ RESOLVE_REF_READING | RESOLVE_REF_NO_RECURSE ,
2664
2666
orig_sha1 , & flag )) {
2665
2667
ret = error ("refname %s not found" , oldrefname );
2666
2668
goto out ;
@@ -2682,7 +2684,8 @@ static int files_rename_ref(struct ref_store *ref_store,
2682
2684
goto out ;
2683
2685
}
2684
2686
2685
- if (delete_ref (logmsg , oldrefname , orig_sha1 , REF_NODEREF )) {
2687
+ if (refs_delete_ref (& refs -> base , logmsg , oldrefname ,
2688
+ orig_sha1 , REF_NODEREF )) {
2686
2689
error ("unable to delete old %s" , oldrefname );
2687
2690
goto rollback ;
2688
2691
}
@@ -2694,9 +2697,11 @@ static int files_rename_ref(struct ref_store *ref_store,
2694
2697
* the safety anyway; we want to delete the reference whatever
2695
2698
* its current value.
2696
2699
*/
2697
- if (!read_ref_full (newrefname , RESOLVE_REF_READING | RESOLVE_REF_NO_RECURSE ,
2698
- sha1 , NULL ) &&
2699
- delete_ref (NULL , newrefname , NULL , REF_NODEREF )) {
2700
+ if (!refs_read_ref_full (& refs -> base , newrefname ,
2701
+ RESOLVE_REF_READING | RESOLVE_REF_NO_RECURSE ,
2702
+ sha1 , NULL ) &&
2703
+ refs_delete_ref (& refs -> base , NULL , newrefname ,
2704
+ NULL , REF_NODEREF )) {
2700
2705
if (errno == EISDIR ) {
2701
2706
struct strbuf path = STRBUF_INIT ;
2702
2707
int result ;
@@ -3052,8 +3057,9 @@ static int commit_ref_update(struct files_ref_store *refs,
3052
3057
int head_flag ;
3053
3058
const char * head_ref ;
3054
3059
3055
- head_ref = resolve_ref_unsafe ("HEAD" , RESOLVE_REF_READING ,
3056
- head_sha1 , & head_flag );
3060
+ head_ref = refs_resolve_ref_unsafe (& refs -> base , "HEAD" ,
3061
+ RESOLVE_REF_READING ,
3062
+ head_sha1 , & head_flag );
3057
3063
if (head_ref && (head_flag & REF_ISSYMREF ) &&
3058
3064
!strcmp (head_ref , lock -> ref_name )) {
3059
3065
struct strbuf log_err = STRBUF_INIT ;
@@ -3097,7 +3103,9 @@ static void update_symref_reflog(struct files_ref_store *refs,
3097
3103
{
3098
3104
struct strbuf err = STRBUF_INIT ;
3099
3105
unsigned char new_sha1 [20 ];
3100
- if (logmsg && !read_ref (target , new_sha1 ) &&
3106
+ if (logmsg &&
3107
+ !refs_read_ref_full (& refs -> base , target ,
3108
+ RESOLVE_REF_READING , new_sha1 , NULL ) &&
3101
3109
files_log_ref_write (refs , refname , lock -> old_oid .hash ,
3102
3110
new_sha1 , logmsg , 0 , & err )) {
3103
3111
error ("%s" , err .buf );
@@ -3402,6 +3410,7 @@ static int files_for_each_reflog_ent(struct ref_store *ref_store,
3402
3410
struct files_reflog_iterator {
3403
3411
struct ref_iterator base ;
3404
3412
3413
+ struct ref_store * ref_store ;
3405
3414
struct dir_iterator * dir_iterator ;
3406
3415
struct object_id oid ;
3407
3416
};
@@ -3423,8 +3432,9 @@ static int files_reflog_iterator_advance(struct ref_iterator *ref_iterator)
3423
3432
if (ends_with (diter -> basename , ".lock" ))
3424
3433
continue ;
3425
3434
3426
- if (read_ref_full (diter -> relative_path , 0 ,
3427
- iter -> oid .hash , & flags )) {
3435
+ if (refs_read_ref_full (iter -> ref_store ,
3436
+ diter -> relative_path , 0 ,
3437
+ iter -> oid .hash , & flags )) {
3428
3438
error ("bad ref for %s" , diter -> path .buf );
3429
3439
continue ;
3430
3440
}
@@ -3478,6 +3488,7 @@ static struct ref_iterator *files_reflog_iterator_begin(struct ref_store *ref_st
3478
3488
base_ref_iterator_init (ref_iterator , & files_reflog_iterator_vtable );
3479
3489
files_reflog_path (refs , & sb , NULL );
3480
3490
iter -> dir_iterator = dir_iterator_begin (sb .buf );
3491
+ iter -> ref_store = ref_store ;
3481
3492
strbuf_release (& sb );
3482
3493
return ref_iterator ;
3483
3494
}
@@ -3717,8 +3728,9 @@ static int lock_ref_for_update(struct files_ref_store *refs,
3717
3728
* the transaction, so we have to read it here
3718
3729
* to record and possibly check old_sha1:
3719
3730
*/
3720
- if (read_ref_full (referent .buf , 0 ,
3721
- lock -> old_oid .hash , NULL )) {
3731
+ if (refs_read_ref_full (& refs -> base ,
3732
+ referent .buf , 0 ,
3733
+ lock -> old_oid .hash , NULL )) {
3722
3734
if (update -> flags & REF_HAVE_OLD ) {
3723
3735
strbuf_addf (err , "cannot lock ref '%s': "
3724
3736
"error reading reference" ,
@@ -3872,8 +3884,9 @@ static int files_transaction_commit(struct ref_store *ref_store,
3872
3884
* head_ref within the transaction, then split_head_update()
3873
3885
* arranges for the reflog of HEAD to be updated, too.
3874
3886
*/
3875
- head_ref = resolve_refdup ("HEAD" , RESOLVE_REF_NO_RECURSE ,
3876
- head_oid .hash , & head_type );
3887
+ head_ref = refs_resolve_refdup (ref_store , "HEAD" ,
3888
+ RESOLVE_REF_NO_RECURSE ,
3889
+ head_oid .hash , & head_type );
3877
3890
3878
3891
if (head_ref && !(head_type & REF_ISSYMREF )) {
3879
3892
free (head_ref );
@@ -4046,7 +4059,8 @@ static int files_initial_transaction_commit(struct ref_store *ref_store,
4046
4059
* so here we really only check that none of the references
4047
4060
* that we are creating already exists.
4048
4061
*/
4049
- if (for_each_rawref (ref_present , & affected_refnames ))
4062
+ if (refs_for_each_rawref (& refs -> base , ref_present ,
4063
+ & affected_refnames ))
4050
4064
die ("BUG: initial ref transaction called with existing refs" );
4051
4065
4052
4066
for (i = 0 ; i < transaction -> nr ; i ++ ) {
@@ -4165,7 +4179,7 @@ static int files_reflog_expire(struct ref_store *ref_store,
4165
4179
strbuf_release (& err );
4166
4180
return -1 ;
4167
4181
}
4168
- if (!reflog_exists ( refname )) {
4182
+ if (!refs_reflog_exists ( ref_store , refname )) {
4169
4183
unlock_ref (lock );
4170
4184
return 0 ;
4171
4185
}
@@ -4196,7 +4210,7 @@ static int files_reflog_expire(struct ref_store *ref_store,
4196
4210
}
4197
4211
4198
4212
(* prepare_fn )(refname , sha1 , cb .policy_cb );
4199
- for_each_reflog_ent ( refname , expire_reflog_ent , & cb );
4213
+ refs_for_each_reflog_ent ( ref_store , refname , expire_reflog_ent , & cb );
4200
4214
(* cleanup_fn )(cb .policy_cb );
4201
4215
4202
4216
if (!(flags & EXPIRE_REFLOGS_DRY_RUN )) {
0 commit comments