1313#include "tag.h"
1414#include "submodule.h"
1515#include "worktree.h"
16+ #include "repository.h"
1617
1718/*
1819 * List of all available backends
@@ -206,7 +207,7 @@ char *refs_resolve_refdup(struct ref_store *refs,
206207char * resolve_refdup (const char * refname , int resolve_flags ,
207208 struct object_id * oid , int * flags )
208209{
209- return refs_resolve_refdup (get_main_ref_store (),
210+ return refs_resolve_refdup (get_main_ref_store (the_repository ),
210211 refname , resolve_flags ,
211212 oid , flags );
212213}
@@ -228,7 +229,7 @@ int refs_read_ref_full(struct ref_store *refs, const char *refname,
228229
229230int read_ref_full (const char * refname , int resolve_flags , struct object_id * oid , int * flags )
230231{
231- return refs_read_ref_full (get_main_ref_store (), refname ,
232+ return refs_read_ref_full (get_main_ref_store (the_repository ), refname ,
232233 resolve_flags , oid , flags );
233234}
234235
@@ -375,7 +376,7 @@ int refs_for_each_tag_ref(struct ref_store *refs, each_ref_fn fn, void *cb_data)
375376
376377int for_each_tag_ref (each_ref_fn fn , void * cb_data )
377378{
378- return refs_for_each_tag_ref (get_main_ref_store (), fn , cb_data );
379+ return refs_for_each_tag_ref (get_main_ref_store (the_repository ), fn , cb_data );
379380}
380381
381382int refs_for_each_branch_ref (struct ref_store * refs , each_ref_fn fn , void * cb_data )
@@ -385,7 +386,7 @@ int refs_for_each_branch_ref(struct ref_store *refs, each_ref_fn fn, void *cb_da
385386
386387int for_each_branch_ref (each_ref_fn fn , void * cb_data )
387388{
388- return refs_for_each_branch_ref (get_main_ref_store (), fn , cb_data );
389+ return refs_for_each_branch_ref (get_main_ref_store (the_repository ), fn , cb_data );
389390}
390391
391392int refs_for_each_remote_ref (struct ref_store * refs , each_ref_fn fn , void * cb_data )
@@ -395,7 +396,7 @@ int refs_for_each_remote_ref(struct ref_store *refs, each_ref_fn fn, void *cb_da
395396
396397int for_each_remote_ref (each_ref_fn fn , void * cb_data )
397398{
398- return refs_for_each_remote_ref (get_main_ref_store (), fn , cb_data );
399+ return refs_for_each_remote_ref (get_main_ref_store (the_repository ), fn , cb_data );
399400}
400401
401402int head_ref_namespaced (each_ref_fn fn , void * cb_data )
@@ -730,7 +731,7 @@ int refs_delete_ref(struct ref_store *refs, const char *msg,
730731 struct strbuf err = STRBUF_INIT ;
731732
732733 if (ref_type (refname ) == REF_TYPE_PSEUDOREF ) {
733- assert (refs == get_main_ref_store ());
734+ assert (refs == get_main_ref_store (the_repository ));
734735 return delete_pseudoref (refname , old_oid );
735736 }
736737
@@ -752,7 +753,7 @@ int refs_delete_ref(struct ref_store *refs, const char *msg,
752753int delete_ref (const char * msg , const char * refname ,
753754 const struct object_id * old_oid , unsigned int flags )
754755{
755- return refs_delete_ref (get_main_ref_store (), msg , refname ,
756+ return refs_delete_ref (get_main_ref_store (the_repository ), msg , refname ,
756757 old_oid , flags );
757758}
758759
@@ -928,7 +929,7 @@ struct ref_transaction *ref_store_transaction_begin(struct ref_store *refs,
928929
929930struct ref_transaction * ref_transaction_begin (struct strbuf * err )
930931{
931- return ref_store_transaction_begin (get_main_ref_store (), err );
932+ return ref_store_transaction_begin (get_main_ref_store (the_repository ), err );
932933}
933934
934935void ref_transaction_free (struct ref_transaction * transaction )
@@ -1060,7 +1061,7 @@ int refs_update_ref(struct ref_store *refs, const char *msg,
10601061 int ret = 0 ;
10611062
10621063 if (ref_type (refname ) == REF_TYPE_PSEUDOREF ) {
1063- assert (refs == get_main_ref_store ());
1064+ assert (refs == get_main_ref_store (the_repository ));
10641065 ret = write_pseudoref (refname , new_oid , old_oid , & err );
10651066 } else {
10661067 t = ref_store_transaction_begin (refs , & err );
@@ -1099,7 +1100,7 @@ int update_ref(const char *msg, const char *refname,
10991100 const struct object_id * old_oid ,
11001101 unsigned int flags , enum action_on_err onerr )
11011102{
1102- return refs_update_ref (get_main_ref_store (), msg , refname , new_oid ,
1103+ return refs_update_ref (get_main_ref_store (the_repository ), msg , refname , new_oid ,
11031104 old_oid , flags , onerr );
11041105}
11051106
@@ -1320,7 +1321,7 @@ int refs_head_ref(struct ref_store *refs, each_ref_fn fn, void *cb_data)
13201321
13211322int head_ref (each_ref_fn fn , void * cb_data )
13221323{
1323- return refs_head_ref (get_main_ref_store (), fn , cb_data );
1324+ return refs_head_ref (get_main_ref_store (the_repository ), fn , cb_data );
13241325}
13251326
13261327struct ref_iterator * refs_ref_iterator_begin (
@@ -1379,7 +1380,7 @@ int refs_for_each_ref(struct ref_store *refs, each_ref_fn fn, void *cb_data)
13791380
13801381int for_each_ref (each_ref_fn fn , void * cb_data )
13811382{
1382- return refs_for_each_ref (get_main_ref_store (), fn , cb_data );
1383+ return refs_for_each_ref (get_main_ref_store (the_repository ), fn , cb_data );
13831384}
13841385
13851386int refs_for_each_ref_in (struct ref_store * refs , const char * prefix ,
@@ -1390,7 +1391,7 @@ int refs_for_each_ref_in(struct ref_store *refs, const char *prefix,
13901391
13911392int for_each_ref_in (const char * prefix , each_ref_fn fn , void * cb_data )
13921393{
1393- return refs_for_each_ref_in (get_main_ref_store (), prefix , fn , cb_data );
1394+ return refs_for_each_ref_in (get_main_ref_store (the_repository ), prefix , fn , cb_data );
13941395}
13951396
13961397int for_each_fullref_in (const char * prefix , each_ref_fn fn , void * cb_data , unsigned int broken )
@@ -1399,7 +1400,7 @@ int for_each_fullref_in(const char *prefix, each_ref_fn fn, void *cb_data, unsig
13991400
14001401 if (broken )
14011402 flag = DO_FOR_EACH_INCLUDE_BROKEN ;
1402- return do_for_each_ref (get_main_ref_store (),
1403+ return do_for_each_ref (get_main_ref_store (the_repository ),
14031404 prefix , fn , 0 , flag , cb_data );
14041405}
14051406
@@ -1416,7 +1417,7 @@ int refs_for_each_fullref_in(struct ref_store *refs, const char *prefix,
14161417
14171418int for_each_replace_ref (each_ref_fn fn , void * cb_data )
14181419{
1419- return do_for_each_ref (get_main_ref_store (),
1420+ return do_for_each_ref (get_main_ref_store (the_repository ),
14201421 git_replace_ref_base , fn ,
14211422 strlen (git_replace_ref_base ),
14221423 DO_FOR_EACH_INCLUDE_BROKEN , cb_data );
@@ -1427,7 +1428,7 @@ int for_each_namespaced_ref(each_ref_fn fn, void *cb_data)
14271428 struct strbuf buf = STRBUF_INIT ;
14281429 int ret ;
14291430 strbuf_addf (& buf , "%srefs/" , get_git_namespace ());
1430- ret = do_for_each_ref (get_main_ref_store (),
1431+ ret = do_for_each_ref (get_main_ref_store (the_repository ),
14311432 buf .buf , fn , 0 , 0 , cb_data );
14321433 strbuf_release (& buf );
14331434 return ret ;
@@ -1441,7 +1442,7 @@ int refs_for_each_rawref(struct ref_store *refs, each_ref_fn fn, void *cb_data)
14411442
14421443int for_each_rawref (each_ref_fn fn , void * cb_data )
14431444{
1444- return refs_for_each_rawref (get_main_ref_store (), fn , cb_data );
1445+ return refs_for_each_rawref (get_main_ref_store (the_repository ), fn , cb_data );
14451446}
14461447
14471448int refs_read_raw_ref (struct ref_store * ref_store ,
@@ -1547,15 +1548,15 @@ const char *refs_resolve_ref_unsafe(struct ref_store *refs,
15471548/* backend functions */
15481549int refs_init_db (struct strbuf * err )
15491550{
1550- struct ref_store * refs = get_main_ref_store ();
1551+ struct ref_store * refs = get_main_ref_store (the_repository );
15511552
15521553 return refs -> be -> init_db (refs , err );
15531554}
15541555
15551556const char * resolve_ref_unsafe (const char * refname , int resolve_flags ,
15561557 struct object_id * oid , int * flags )
15571558{
1558- return refs_resolve_ref_unsafe (get_main_ref_store (), refname ,
1559+ return refs_resolve_ref_unsafe (get_main_ref_store (the_repository ), refname ,
15591560 resolve_flags , oid , flags );
15601561}
15611562
@@ -1651,7 +1652,7 @@ static struct ref_store *ref_store_init(const char *gitdir,
16511652 return refs ;
16521653}
16531654
1654- struct ref_store * get_main_ref_store (void )
1655+ struct ref_store * get_main_ref_store_the_repository (void )
16551656{
16561657 if (main_ref_store )
16571658 return main_ref_store ;
@@ -1726,7 +1727,7 @@ struct ref_store *get_worktree_ref_store(const struct worktree *wt)
17261727 const char * id ;
17271728
17281729 if (wt -> is_current )
1729- return get_main_ref_store ();
1730+ return get_main_ref_store (the_repository );
17301731
17311732 id = wt -> id ? wt -> id : "/" ;
17321733 refs = lookup_ref_store_map (& worktree_ref_stores , id );
@@ -1782,7 +1783,7 @@ int refs_peel_ref(struct ref_store *refs, const char *refname,
17821783
17831784int peel_ref (const char * refname , struct object_id * oid )
17841785{
1785- return refs_peel_ref (get_main_ref_store (), refname , oid );
1786+ return refs_peel_ref (get_main_ref_store (the_repository ), refname , oid );
17861787}
17871788
17881789int refs_create_symref (struct ref_store * refs ,
@@ -1798,7 +1799,7 @@ int refs_create_symref(struct ref_store *refs,
17981799int create_symref (const char * ref_target , const char * refs_heads_master ,
17991800 const char * logmsg )
18001801{
1801- return refs_create_symref (get_main_ref_store (), ref_target ,
1802+ return refs_create_symref (get_main_ref_store (the_repository ), ref_target ,
18021803 refs_heads_master , logmsg );
18031804}
18041805
@@ -2006,7 +2007,7 @@ int refs_for_each_reflog(struct ref_store *refs, each_ref_fn fn, void *cb_data)
20062007
20072008int for_each_reflog (each_ref_fn fn , void * cb_data )
20082009{
2009- return refs_for_each_reflog (get_main_ref_store (), fn , cb_data );
2010+ return refs_for_each_reflog (get_main_ref_store (the_repository ), fn , cb_data );
20102011}
20112012
20122013int refs_for_each_reflog_ent_reverse (struct ref_store * refs ,
@@ -2021,7 +2022,7 @@ int refs_for_each_reflog_ent_reverse(struct ref_store *refs,
20212022int for_each_reflog_ent_reverse (const char * refname , each_reflog_ent_fn fn ,
20222023 void * cb_data )
20232024{
2024- return refs_for_each_reflog_ent_reverse (get_main_ref_store (),
2025+ return refs_for_each_reflog_ent_reverse (get_main_ref_store (the_repository ),
20252026 refname , fn , cb_data );
20262027}
20272028
@@ -2034,7 +2035,7 @@ int refs_for_each_reflog_ent(struct ref_store *refs, const char *refname,
20342035int for_each_reflog_ent (const char * refname , each_reflog_ent_fn fn ,
20352036 void * cb_data )
20362037{
2037- return refs_for_each_reflog_ent (get_main_ref_store (), refname ,
2038+ return refs_for_each_reflog_ent (get_main_ref_store (the_repository ), refname ,
20382039 fn , cb_data );
20392040}
20402041
@@ -2045,7 +2046,7 @@ int refs_reflog_exists(struct ref_store *refs, const char *refname)
20452046
20462047int reflog_exists (const char * refname )
20472048{
2048- return refs_reflog_exists (get_main_ref_store (), refname );
2049+ return refs_reflog_exists (get_main_ref_store (the_repository ), refname );
20492050}
20502051
20512052int refs_create_reflog (struct ref_store * refs , const char * refname ,
@@ -2057,7 +2058,7 @@ int refs_create_reflog(struct ref_store *refs, const char *refname,
20572058int safe_create_reflog (const char * refname , int force_create ,
20582059 struct strbuf * err )
20592060{
2060- return refs_create_reflog (get_main_ref_store (), refname ,
2061+ return refs_create_reflog (get_main_ref_store (the_repository ), refname ,
20612062 force_create , err );
20622063}
20632064
@@ -2068,7 +2069,7 @@ int refs_delete_reflog(struct ref_store *refs, const char *refname)
20682069
20692070int delete_reflog (const char * refname )
20702071{
2071- return refs_delete_reflog (get_main_ref_store (), refname );
2072+ return refs_delete_reflog (get_main_ref_store (the_repository ), refname );
20722073}
20732074
20742075int refs_reflog_expire (struct ref_store * refs ,
@@ -2091,7 +2092,7 @@ int reflog_expire(const char *refname, const struct object_id *oid,
20912092 reflog_expiry_cleanup_fn cleanup_fn ,
20922093 void * policy_cb_data )
20932094{
2094- return refs_reflog_expire (get_main_ref_store (),
2095+ return refs_reflog_expire (get_main_ref_store (the_repository ),
20952096 refname , oid , flags ,
20962097 prepare_fn , should_prune_fn ,
20972098 cleanup_fn , policy_cb_data );
@@ -2114,7 +2115,7 @@ int refs_delete_refs(struct ref_store *refs, const char *msg,
21142115int delete_refs (const char * msg , struct string_list * refnames ,
21152116 unsigned int flags )
21162117{
2117- return refs_delete_refs (get_main_ref_store (), msg , refnames , flags );
2118+ return refs_delete_refs (get_main_ref_store (the_repository ), msg , refnames , flags );
21182119}
21192120
21202121int refs_rename_ref (struct ref_store * refs , const char * oldref ,
@@ -2125,7 +2126,7 @@ int refs_rename_ref(struct ref_store *refs, const char *oldref,
21252126
21262127int rename_ref (const char * oldref , const char * newref , const char * logmsg )
21272128{
2128- return refs_rename_ref (get_main_ref_store (), oldref , newref , logmsg );
2129+ return refs_rename_ref (get_main_ref_store (the_repository ), oldref , newref , logmsg );
21292130}
21302131
21312132int refs_copy_existing_ref (struct ref_store * refs , const char * oldref ,
@@ -2136,5 +2137,5 @@ int refs_copy_existing_ref(struct ref_store *refs, const char *oldref,
21362137
21372138int copy_existing_ref (const char * oldref , const char * newref , const char * logmsg )
21382139{
2139- return refs_copy_existing_ref (get_main_ref_store (), oldref , newref , logmsg );
2140+ return refs_copy_existing_ref (get_main_ref_store (the_repository ), oldref , newref , logmsg );
21402141}
0 commit comments