@@ -400,19 +400,29 @@ struct for_each_ref_filter {
400
400
void * cb_data ;
401
401
};
402
402
403
- int read_ref_full (const char * refname , int resolve_flags , struct object_id * oid , int * flags )
403
+ int refs_read_ref_full (struct ref_store * refs , const char * refname ,
404
+ int resolve_flags , struct object_id * oid , int * flags )
404
405
{
405
- struct ref_store * refs = get_main_ref_store (the_repository );
406
-
407
406
if (refs_resolve_ref_unsafe (refs , refname , resolve_flags ,
408
407
oid , flags ))
409
408
return 0 ;
410
409
return -1 ;
411
410
}
412
411
412
+ int read_ref_full (const char * refname , int resolve_flags , struct object_id * oid , int * flags )
413
+ {
414
+ return refs_read_ref_full (get_main_ref_store (the_repository ), refname ,
415
+ resolve_flags , oid , flags );
416
+ }
417
+
418
+ int refs_read_ref (struct ref_store * refs , const char * refname , struct object_id * oid )
419
+ {
420
+ return refs_read_ref_full (refs , refname , RESOLVE_REF_READING , oid , NULL );
421
+ }
422
+
413
423
int read_ref (const char * refname , struct object_id * oid )
414
424
{
415
- return read_ref_full ( refname , RESOLVE_REF_READING , oid , NULL );
425
+ return refs_read_ref ( get_main_ref_store ( the_repository ), refname , oid );
416
426
}
417
427
418
428
int refs_ref_exists (struct ref_store * refs , const char * refname )
@@ -542,21 +552,27 @@ int for_each_remote_ref(each_ref_fn fn, void *cb_data)
542
552
return refs_for_each_remote_ref (get_main_ref_store (the_repository ), fn , cb_data );
543
553
}
544
554
545
- int head_ref_namespaced ( each_ref_fn fn , void * cb_data )
555
+ int refs_head_ref_namespaced ( struct ref_store * refs , each_ref_fn fn , void * cb_data )
546
556
{
547
557
struct strbuf buf = STRBUF_INIT ;
548
558
int ret = 0 ;
549
559
struct object_id oid ;
550
560
int flag ;
551
561
552
562
strbuf_addf (& buf , "%sHEAD" , get_git_namespace ());
553
- if (!read_ref_full ( buf .buf , RESOLVE_REF_READING , & oid , & flag ))
563
+ if (!refs_read_ref_full ( refs , buf .buf , RESOLVE_REF_READING , & oid , & flag ))
554
564
ret = fn (buf .buf , & oid , flag , cb_data );
555
565
strbuf_release (& buf );
556
566
557
567
return ret ;
558
568
}
559
569
570
+ int head_ref_namespaced (each_ref_fn fn , void * cb_data )
571
+ {
572
+ return refs_head_ref_namespaced (get_main_ref_store (the_repository ),
573
+ fn , cb_data );
574
+ }
575
+
560
576
void normalize_glob_ref (struct string_list_item * item , const char * prefix ,
561
577
const char * pattern )
562
578
{
@@ -583,8 +599,8 @@ void normalize_glob_ref(struct string_list_item *item, const char *prefix,
583
599
strbuf_release (& normalized_pattern );
584
600
}
585
601
586
- int for_each_glob_ref_in ( each_ref_fn fn , const char * pattern ,
587
- const char * prefix , void * cb_data )
602
+ int refs_for_each_glob_ref_in ( struct ref_store * refs , each_ref_fn fn ,
603
+ const char * pattern , const char * prefix , void * cb_data )
588
604
{
589
605
struct strbuf real_pattern = STRBUF_INIT ;
590
606
struct for_each_ref_filter filter ;
@@ -607,15 +623,29 @@ int for_each_glob_ref_in(each_ref_fn fn, const char *pattern,
607
623
filter .prefix = prefix ;
608
624
filter .fn = fn ;
609
625
filter .cb_data = cb_data ;
610
- ret = for_each_ref ( for_each_filter_refs , & filter );
626
+ ret = refs_for_each_ref ( refs , for_each_filter_refs , & filter );
611
627
612
628
strbuf_release (& real_pattern );
613
629
return ret ;
614
630
}
615
631
632
+ int for_each_glob_ref_in (each_ref_fn fn , const char * pattern ,
633
+ const char * prefix , void * cb_data )
634
+ {
635
+ return refs_for_each_glob_ref_in (get_main_ref_store (the_repository ),
636
+ fn , pattern , prefix , cb_data );
637
+ }
638
+
639
+ int refs_for_each_glob_ref (struct ref_store * refs , each_ref_fn fn ,
640
+ const char * pattern , void * cb_data )
641
+ {
642
+ return refs_for_each_glob_ref_in (refs , fn , pattern , NULL , cb_data );
643
+ }
644
+
616
645
int for_each_glob_ref (each_ref_fn fn , const char * pattern , void * cb_data )
617
646
{
618
- return for_each_glob_ref_in (fn , pattern , NULL , cb_data );
647
+ return refs_for_each_glob_ref (get_main_ref_store (the_repository ),
648
+ fn , pattern , cb_data );
619
649
}
620
650
621
651
const char * prettify_refname (const char * name )
@@ -1733,18 +1763,25 @@ int for_each_replace_ref(struct repository *r, each_repo_ref_fn fn, void *cb_dat
1733
1763
DO_FOR_EACH_INCLUDE_BROKEN , cb_data );
1734
1764
}
1735
1765
1736
- int for_each_namespaced_ref (const char * * exclude_patterns ,
1737
- each_ref_fn fn , void * cb_data )
1766
+ int refs_for_each_namespaced_ref (struct ref_store * refs ,
1767
+ const char * * exclude_patterns ,
1768
+ each_ref_fn fn , void * cb_data )
1738
1769
{
1739
1770
struct strbuf buf = STRBUF_INIT ;
1740
1771
int ret ;
1741
1772
strbuf_addf (& buf , "%srefs/" , get_git_namespace ());
1742
- ret = do_for_each_ref (get_main_ref_store (the_repository ),
1743
- buf .buf , exclude_patterns , fn , 0 , 0 , cb_data );
1773
+ ret = do_for_each_ref (refs , buf .buf , exclude_patterns , fn , 0 , 0 , cb_data );
1744
1774
strbuf_release (& buf );
1745
1775
return ret ;
1746
1776
}
1747
1777
1778
+ int for_each_namespaced_ref (const char * * exclude_patterns ,
1779
+ each_ref_fn fn , void * cb_data )
1780
+ {
1781
+ return refs_for_each_namespaced_ref (get_main_ref_store (the_repository ),
1782
+ exclude_patterns , fn , cb_data );
1783
+ }
1784
+
1748
1785
int refs_for_each_rawref (struct ref_store * refs , each_ref_fn fn , void * cb_data )
1749
1786
{
1750
1787
return do_for_each_ref (refs , "" , NULL , fn , 0 ,
0 commit comments