@@ -62,6 +62,12 @@ struct packed_ref_store {
6262 * it might still be current; otherwise, NULL.
6363 */
6464 struct packed_ref_cache * cache ;
65+
66+ /*
67+ * Lock used for the "packed-refs" file. Note that this (and
68+ * thus the enclosing `packed_ref_store`) must not be freed.
69+ */
70+ struct lock_file lock ;
6571};
6672
6773static struct packed_ref_store * packed_ref_store_create (
@@ -87,12 +93,6 @@ struct files_ref_store {
8793
8894 struct ref_cache * loose ;
8995
90- /*
91- * Lock used for the "packed-refs" file. Note that this (and
92- * thus the enclosing `files_ref_store`) must not be freed.
93- */
94- struct lock_file packed_refs_lock ;
95-
9696 struct packed_ref_store * packed_ref_store ;
9797};
9898
@@ -125,7 +125,7 @@ static void clear_packed_ref_cache(struct files_ref_store *refs)
125125 if (refs -> packed_ref_store -> cache ) {
126126 struct packed_ref_cache * packed_refs = refs -> packed_ref_store -> cache ;
127127
128- if (is_lock_file_locked (& refs -> packed_refs_lock ))
128+ if (is_lock_file_locked (& refs -> packed_ref_store -> lock ))
129129 die ("BUG: packed-ref cache cleared while locked" );
130130 refs -> packed_ref_store -> cache = NULL ;
131131 release_packed_ref_cache (packed_refs );
@@ -416,7 +416,7 @@ static struct packed_ref_cache *get_packed_ref_cache(struct files_ref_store *ref
416416{
417417 const char * packed_refs_file = refs -> packed_ref_store -> path ;
418418
419- if (!is_lock_file_locked (& refs -> packed_refs_lock ))
419+ if (!is_lock_file_locked (& refs -> packed_ref_store -> lock ))
420420 validate_packed_ref_cache (refs );
421421
422422 if (!refs -> packed_ref_store -> cache )
@@ -447,7 +447,7 @@ static void add_packed_ref(struct files_ref_store *refs,
447447 struct ref_dir * packed_refs ;
448448 struct ref_entry * packed_entry ;
449449
450- if (!is_lock_file_locked (& refs -> packed_refs_lock ))
450+ if (!is_lock_file_locked (& refs -> packed_ref_store -> lock ))
451451 die ("BUG: packed refs not locked" );
452452
453453 if (check_refname_format (refname , REFNAME_ALLOW_ONELEVEL ))
@@ -1351,7 +1351,8 @@ static int lock_packed_refs(struct files_ref_store *refs, int flags)
13511351 }
13521352
13531353 if (hold_lock_file_for_update_timeout (
1354- & refs -> packed_refs_lock , refs -> packed_ref_store -> path ,
1354+ & refs -> packed_ref_store -> lock ,
1355+ refs -> packed_ref_store -> path ,
13551356 flags , timeout_value ) < 0 )
13561357 return -1 ;
13571358
@@ -1388,10 +1389,10 @@ static int commit_packed_refs(struct files_ref_store *refs)
13881389
13891390 files_assert_main_repository (refs , "commit_packed_refs" );
13901391
1391- if (!is_lock_file_locked (& refs -> packed_refs_lock ))
1392+ if (!is_lock_file_locked (& refs -> packed_ref_store -> lock ))
13921393 die ("BUG: packed-refs not locked" );
13931394
1394- out = fdopen_lock_file (& refs -> packed_refs_lock , "w" );
1395+ out = fdopen_lock_file (& refs -> packed_ref_store -> lock , "w" );
13951396 if (!out )
13961397 die_errno ("unable to fdopen packed-refs descriptor" );
13971398
@@ -1409,7 +1410,7 @@ static int commit_packed_refs(struct files_ref_store *refs)
14091410 if (ok != ITER_DONE )
14101411 die ("error while iterating over references" );
14111412
1412- if (commit_lock_file (& refs -> packed_refs_lock )) {
1413+ if (commit_lock_file (& refs -> packed_ref_store -> lock )) {
14131414 save_errno = errno ;
14141415 error = -1 ;
14151416 }
@@ -1430,9 +1431,9 @@ static void rollback_packed_refs(struct files_ref_store *refs)
14301431
14311432 files_assert_main_repository (refs , "rollback_packed_refs" );
14321433
1433- if (!is_lock_file_locked (& refs -> packed_refs_lock ))
1434+ if (!is_lock_file_locked (& refs -> packed_ref_store -> lock ))
14341435 die ("BUG: packed-refs not locked" );
1435- rollback_lock_file (& refs -> packed_refs_lock );
1436+ rollback_lock_file (& refs -> packed_ref_store -> lock );
14361437 release_packed_ref_cache (packed_ref_cache );
14371438 clear_packed_ref_cache (refs );
14381439}
0 commit comments