@@ -278,16 +278,14 @@ void clear_extra_refs(void)
278
278
clear_ref_array (& extra_refs );
279
279
}
280
280
281
- static struct ref_array * get_packed_refs (const char * submodule )
281
+ static struct ref_array * get_packed_refs (struct ref_cache * refs )
282
282
{
283
- struct ref_cache * refs = get_ref_cache (submodule );
284
-
285
283
if (!refs -> did_packed ) {
286
284
const char * packed_refs_file ;
287
285
FILE * f ;
288
286
289
- if (submodule )
290
- packed_refs_file = git_path_submodule (submodule , "packed-refs" );
287
+ if (* refs -> name )
288
+ packed_refs_file = git_path_submodule (refs -> name , "packed-refs" );
291
289
else
292
290
packed_refs_file = git_path ("packed-refs" );
293
291
f = fopen (packed_refs_file , "r" );
@@ -306,7 +304,7 @@ static void get_ref_dir(const char *submodule, const char *base,
306
304
DIR * dir ;
307
305
const char * path ;
308
306
309
- if (submodule )
307
+ if (* submodule )
310
308
path = git_path_submodule (submodule , "%s" , base );
311
309
else
312
310
path = git_path ("%s" , base );
@@ -399,12 +397,10 @@ void warn_dangling_symref(FILE *fp, const char *msg_fmt, const char *refname)
399
397
for_each_rawref (warn_if_dangling_symref , & data );
400
398
}
401
399
402
- static struct ref_array * get_loose_refs (const char * submodule )
400
+ static struct ref_array * get_loose_refs (struct ref_cache * refs )
403
401
{
404
- struct ref_cache * refs = get_ref_cache (submodule );
405
-
406
402
if (!refs -> did_loose ) {
407
- get_ref_dir (submodule , "refs" , & refs -> loose );
403
+ get_ref_dir (refs -> name , "refs" , & refs -> loose );
408
404
sort_ref_array (& refs -> loose );
409
405
refs -> did_loose = 1 ;
410
406
}
@@ -431,7 +427,7 @@ static int resolve_gitlink_packed_ref(char *name, int pathlen,
431
427
if (pathlen < 6 || memcmp (name + pathlen - 6 , "/.git/" , 6 ))
432
428
die ("Oops" );
433
429
name [pathlen - 6 ] = '\0' ; /* make it path to the submodule */
434
- array = get_packed_refs (name );
430
+ array = get_packed_refs (get_ref_cache ( name ) );
435
431
ref = search_ref_array (array , refname );
436
432
if (ref != NULL ) {
437
433
memcpy (sha1 , ref -> sha1 , 20 );
@@ -511,7 +507,7 @@ int resolve_gitlink_ref(const char *path, const char *refname, unsigned char *sh
511
507
*/
512
508
static int get_packed_ref (const char * refname , unsigned char * sha1 )
513
509
{
514
- struct ref_array * packed = get_packed_refs (NULL );
510
+ struct ref_array * packed = get_packed_refs (get_ref_cache ( NULL ) );
515
511
struct ref_entry * entry = search_ref_array (packed , refname );
516
512
if (entry ) {
517
513
hashcpy (sha1 , entry -> sha1 );
@@ -695,7 +691,7 @@ int peel_ref(const char *refname, unsigned char *sha1)
695
691
return -1 ;
696
692
697
693
if ((flag & REF_ISPACKED )) {
698
- struct ref_array * array = get_packed_refs (NULL );
694
+ struct ref_array * array = get_packed_refs (get_ref_cache ( NULL ) );
699
695
struct ref_entry * r = search_ref_array (array , refname );
700
696
701
697
if (r != NULL && r -> flag & REF_KNOWS_PEELED ) {
@@ -720,8 +716,9 @@ static int do_for_each_ref(const char *submodule, const char *base, each_ref_fn
720
716
int trim , int flags , void * cb_data )
721
717
{
722
718
int retval = 0 , i , p = 0 , l = 0 ;
723
- struct ref_array * packed = get_packed_refs (submodule );
724
- struct ref_array * loose = get_loose_refs (submodule );
719
+ struct ref_cache * refs = get_ref_cache (submodule );
720
+ struct ref_array * packed = get_packed_refs (refs );
721
+ struct ref_array * loose = get_loose_refs (refs );
725
722
726
723
struct ref_array * extra = & extra_refs ;
727
724
@@ -1238,7 +1235,7 @@ static struct ref_lock *lock_ref_sha1_basic(const char *refname,
1238
1235
* name is a proper prefix of our refname.
1239
1236
*/
1240
1237
if (missing &&
1241
- !is_refname_available (refname , NULL , get_packed_refs (NULL ))) {
1238
+ !is_refname_available (refname , NULL , get_packed_refs (get_ref_cache ( NULL ) ))) {
1242
1239
last_errno = ENOTDIR ;
1243
1240
goto error_return ;
1244
1241
}
@@ -1298,7 +1295,7 @@ static int repack_without_ref(const char *refname)
1298
1295
struct ref_entry * ref ;
1299
1296
int fd , i ;
1300
1297
1301
- packed = get_packed_refs (NULL );
1298
+ packed = get_packed_refs (get_ref_cache ( NULL ) );
1302
1299
ref = search_ref_array (packed , refname );
1303
1300
if (ref == NULL )
1304
1301
return 0 ;
@@ -1381,6 +1378,7 @@ int rename_ref(const char *oldrefname, const char *newrefname, const char *logms
1381
1378
struct stat loginfo ;
1382
1379
int log = !lstat (git_path ("logs/%s" , oldrefname ), & loginfo );
1383
1380
const char * symref = NULL ;
1381
+ struct ref_cache * refs = get_ref_cache (NULL );
1384
1382
1385
1383
if (log && S_ISLNK (loginfo .st_mode ))
1386
1384
return error ("reflog for %s is a symlink" , oldrefname );
@@ -1392,10 +1390,10 @@ int rename_ref(const char *oldrefname, const char *newrefname, const char *logms
1392
1390
if (!symref )
1393
1391
return error ("refname %s not found" , oldrefname );
1394
1392
1395
- if (!is_refname_available (newrefname , oldrefname , get_packed_refs (NULL )))
1393
+ if (!is_refname_available (newrefname , oldrefname , get_packed_refs (refs )))
1396
1394
return 1 ;
1397
1395
1398
- if (!is_refname_available (newrefname , oldrefname , get_loose_refs (NULL )))
1396
+ if (!is_refname_available (newrefname , oldrefname , get_loose_refs (refs )))
1399
1397
return 1 ;
1400
1398
1401
1399
if (log && rename (git_path ("logs/%s" , oldrefname ), git_path (TMP_RENAMED_LOG )))
0 commit comments