@@ -43,15 +43,6 @@ struct packed_ref_cache {
43
43
*/
44
44
unsigned int referrers ;
45
45
46
- /*
47
- * Iff the packed-refs file associated with this instance is
48
- * currently locked for writing, this points at the associated
49
- * lock (which is owned by somebody else). The referrer count
50
- * is also incremented when the file is locked and decremented
51
- * when it is unlocked.
52
- */
53
- struct lock_file * lock ;
54
-
55
46
/* The metadata from when this packed-refs cache was read */
56
47
struct stat_validity validity ;
57
48
};
@@ -70,6 +61,13 @@ struct files_ref_store {
70
61
71
62
struct ref_cache * loose ;
72
63
struct packed_ref_cache * packed ;
64
+
65
+ /*
66
+ * Iff the packed-refs file associated with this instance is
67
+ * currently locked for writing, this points at the associated
68
+ * lock (which is owned by somebody else).
69
+ */
70
+ struct lock_file * packed_refs_lock ;
73
71
};
74
72
75
73
/* Lock used for the main packed-refs file: */
@@ -104,7 +102,7 @@ static void clear_packed_ref_cache(struct files_ref_store *refs)
104
102
if (refs -> packed ) {
105
103
struct packed_ref_cache * packed_refs = refs -> packed ;
106
104
107
- if (packed_refs -> lock )
105
+ if (refs -> packed_refs_lock )
108
106
die ("BUG: packed-ref cache cleared while locked" );
109
107
refs -> packed = NULL ;
110
108
release_packed_ref_cache (packed_refs );
@@ -396,7 +394,7 @@ static void add_packed_ref(struct files_ref_store *refs,
396
394
{
397
395
struct packed_ref_cache * packed_ref_cache = get_packed_ref_cache (refs );
398
396
399
- if (!packed_ref_cache -> lock )
397
+ if (!refs -> packed_refs_lock )
400
398
die ("BUG: packed refs not locked" );
401
399
add_ref_entry (get_packed_ref_dir (packed_ref_cache ),
402
400
create_ref_entry (refname , oid , REF_ISPACKED , 1 ));
@@ -1300,7 +1298,7 @@ static int lock_packed_refs(struct files_ref_store *refs, int flags)
1300
1298
* the packed-refs file.
1301
1299
*/
1302
1300
packed_ref_cache = get_packed_ref_cache (refs );
1303
- packed_ref_cache -> lock = & packlock ;
1301
+ refs -> packed_refs_lock = & packlock ;
1304
1302
/* Increment the reference count to prevent it from being freed: */
1305
1303
acquire_packed_ref_cache (packed_ref_cache );
1306
1304
return 0 ;
@@ -1323,10 +1321,10 @@ static int commit_packed_refs(struct files_ref_store *refs)
1323
1321
1324
1322
files_assert_main_repository (refs , "commit_packed_refs" );
1325
1323
1326
- if (!packed_ref_cache -> lock )
1324
+ if (!refs -> packed_refs_lock )
1327
1325
die ("BUG: packed-refs not locked" );
1328
1326
1329
- out = fdopen_lock_file (packed_ref_cache -> lock , "w" );
1327
+ out = fdopen_lock_file (refs -> packed_refs_lock , "w" );
1330
1328
if (!out )
1331
1329
die_errno ("unable to fdopen packed-refs descriptor" );
1332
1330
@@ -1344,11 +1342,11 @@ static int commit_packed_refs(struct files_ref_store *refs)
1344
1342
if (ok != ITER_DONE )
1345
1343
die ("error while iterating over references" );
1346
1344
1347
- if (commit_lock_file (packed_ref_cache -> lock )) {
1345
+ if (commit_lock_file (refs -> packed_refs_lock )) {
1348
1346
save_errno = errno ;
1349
1347
error = -1 ;
1350
1348
}
1351
- packed_ref_cache -> lock = NULL ;
1349
+ refs -> packed_refs_lock = NULL ;
1352
1350
release_packed_ref_cache (packed_ref_cache );
1353
1351
errno = save_errno ;
1354
1352
return error ;
@@ -1366,10 +1364,10 @@ static void rollback_packed_refs(struct files_ref_store *refs)
1366
1364
1367
1365
files_assert_main_repository (refs , "rollback_packed_refs" );
1368
1366
1369
- if (!packed_ref_cache -> lock )
1367
+ if (!refs -> packed_refs_lock )
1370
1368
die ("BUG: packed-refs not locked" );
1371
- rollback_lock_file (packed_ref_cache -> lock );
1372
- packed_ref_cache -> lock = NULL ;
1369
+ rollback_lock_file (refs -> packed_refs_lock );
1370
+ refs -> packed_refs_lock = NULL ;
1373
1371
release_packed_ref_cache (packed_ref_cache );
1374
1372
clear_packed_ref_cache (refs );
1375
1373
}
0 commit comments