@@ -1504,16 +1504,15 @@ void warn_dangling_symref(FILE *fp, const char *msg_fmt, const char *refname)
1504
1504
}
1505
1505
1506
1506
/*
1507
- * Call fn for each reference in the specified submodule , omitting
1507
+ * Call fn for each reference in the specified ref_cache , omitting
1508
1508
* references not in the containing_dir of base. fn is called for all
1509
1509
* references, including broken ones. If fn ever returns a non-zero
1510
1510
* value, stop the iteration and return that value; otherwise, return
1511
1511
* 0.
1512
1512
*/
1513
- static int do_for_each_entry (const char * submodule , const char * base ,
1513
+ static int do_for_each_entry (struct ref_cache * refs , const char * base ,
1514
1514
each_ref_entry_fn fn , void * cb_data )
1515
1515
{
1516
- struct ref_cache * refs = get_ref_cache (submodule );
1517
1516
struct ref_dir * packed_dir = get_packed_refs (refs );
1518
1517
struct ref_dir * loose_dir = get_loose_refs (refs );
1519
1518
int retval = 0 ;
@@ -1542,16 +1541,16 @@ static int do_for_each_entry(const char *submodule, const char *base,
1542
1541
}
1543
1542
1544
1543
/*
1545
- * Call fn for each reference in the specified submodule for which the
1544
+ * Call fn for each reference in the specified ref_cache for which the
1546
1545
* refname begins with base. If trim is non-zero, then trim that many
1547
1546
* characters off the beginning of each refname before passing the
1548
1547
* refname to fn. flags can be DO_FOR_EACH_INCLUDE_BROKEN to include
1549
1548
* broken references in the iteration. If fn ever returns a non-zero
1550
1549
* value, stop the iteration and return that value; otherwise, return
1551
1550
* 0.
1552
1551
*/
1553
- static int do_for_each_ref (const char * submodule , const char * base , each_ref_fn fn ,
1554
- int trim , int flags , void * cb_data )
1552
+ static int do_for_each_ref (struct ref_cache * refs , const char * base ,
1553
+ each_ref_fn fn , int trim , int flags , void * cb_data )
1555
1554
{
1556
1555
struct ref_entry_cb data ;
1557
1556
data .base = base ;
@@ -1560,7 +1559,7 @@ static int do_for_each_ref(const char *submodule, const char *base, each_ref_fn
1560
1559
data .fn = fn ;
1561
1560
data .cb_data = cb_data ;
1562
1561
1563
- return do_for_each_entry (submodule , base , do_one_ref , & data );
1562
+ return do_for_each_entry (refs , base , do_one_ref , & data );
1564
1563
}
1565
1564
1566
1565
static int do_head_ref (const char * submodule , each_ref_fn fn , void * cb_data )
@@ -1593,23 +1592,23 @@ int head_ref_submodule(const char *submodule, each_ref_fn fn, void *cb_data)
1593
1592
1594
1593
int for_each_ref (each_ref_fn fn , void * cb_data )
1595
1594
{
1596
- return do_for_each_ref (NULL , "" , fn , 0 , 0 , cb_data );
1595
+ return do_for_each_ref (get_ref_cache ( NULL ) , "" , fn , 0 , 0 , cb_data );
1597
1596
}
1598
1597
1599
1598
int for_each_ref_submodule (const char * submodule , each_ref_fn fn , void * cb_data )
1600
1599
{
1601
- return do_for_each_ref (submodule , "" , fn , 0 , 0 , cb_data );
1600
+ return do_for_each_ref (get_ref_cache ( submodule ) , "" , fn , 0 , 0 , cb_data );
1602
1601
}
1603
1602
1604
1603
int for_each_ref_in (const char * prefix , each_ref_fn fn , void * cb_data )
1605
1604
{
1606
- return do_for_each_ref (NULL , prefix , fn , strlen (prefix ), 0 , cb_data );
1605
+ return do_for_each_ref (get_ref_cache ( NULL ) , prefix , fn , strlen (prefix ), 0 , cb_data );
1607
1606
}
1608
1607
1609
1608
int for_each_ref_in_submodule (const char * submodule , const char * prefix ,
1610
1609
each_ref_fn fn , void * cb_data )
1611
1610
{
1612
- return do_for_each_ref (submodule , prefix , fn , strlen (prefix ), 0 , cb_data );
1611
+ return do_for_each_ref (get_ref_cache ( submodule ) , prefix , fn , strlen (prefix ), 0 , cb_data );
1613
1612
}
1614
1613
1615
1614
int for_each_tag_ref (each_ref_fn fn , void * cb_data )
@@ -1644,7 +1643,7 @@ int for_each_remote_ref_submodule(const char *submodule, each_ref_fn fn, void *c
1644
1643
1645
1644
int for_each_replace_ref (each_ref_fn fn , void * cb_data )
1646
1645
{
1647
- return do_for_each_ref (NULL , "refs/replace/" , fn , 13 , 0 , cb_data );
1646
+ return do_for_each_ref (get_ref_cache ( NULL ) , "refs/replace/" , fn , 13 , 0 , cb_data );
1648
1647
}
1649
1648
1650
1649
int head_ref_namespaced (each_ref_fn fn , void * cb_data )
@@ -1667,7 +1666,7 @@ int for_each_namespaced_ref(each_ref_fn fn, void *cb_data)
1667
1666
struct strbuf buf = STRBUF_INIT ;
1668
1667
int ret ;
1669
1668
strbuf_addf (& buf , "%srefs/" , get_git_namespace ());
1670
- ret = do_for_each_ref (NULL , buf .buf , fn , 0 , 0 , cb_data );
1669
+ ret = do_for_each_ref (get_ref_cache ( NULL ) , buf .buf , fn , 0 , 0 , cb_data );
1671
1670
strbuf_release (& buf );
1672
1671
return ret ;
1673
1672
}
@@ -1709,7 +1708,7 @@ int for_each_glob_ref(each_ref_fn fn, const char *pattern, void *cb_data)
1709
1708
1710
1709
int for_each_rawref (each_ref_fn fn , void * cb_data )
1711
1710
{
1712
- return do_for_each_ref (NULL , "" , fn , 0 ,
1711
+ return do_for_each_ref (get_ref_cache ( NULL ) , "" , fn , 0 ,
1713
1712
DO_FOR_EACH_INCLUDE_BROKEN , cb_data );
1714
1713
}
1715
1714
@@ -2104,7 +2103,7 @@ int pack_refs(unsigned int flags)
2104
2103
2105
2104
write_or_die (cbdata .fd , PACKED_REFS_HEADER , strlen (PACKED_REFS_HEADER ));
2106
2105
2107
- do_for_each_entry (NULL , "" , pack_one_ref , & cbdata );
2106
+ do_for_each_entry (get_ref_cache ( NULL ) , "" , pack_one_ref , & cbdata );
2108
2107
if (commit_lock_file (& packlock ) < 0 )
2109
2108
die_errno ("unable to overwrite old ref-pack file" );
2110
2109
prune_refs (cbdata .ref_to_prune );
0 commit comments