*/
unsigned int referrers;
- /*
- * Iff the packed-refs file associated with this instance is
- * currently locked for writing, this points at the associated
- * lock (which is owned by somebody else). The referrer count
- * is also incremented when the file is locked and decremented
- * when it is unlocked.
- */
- struct lock_file *lock;
-
/* The metadata from when this packed-refs cache was read */
struct stat_validity validity;
};
struct ref_cache *loose;
struct packed_ref_cache *packed;
+
+ /*
+ * Iff the packed-refs file associated with this instance is
+ * currently locked for writing, this points at the associated
+ * lock (which is owned by somebody else).
+ */
+ struct lock_file *packed_refs_lock;
};
/* Lock used for the main packed-refs file: */
if (refs->packed) {
struct packed_ref_cache *packed_refs = refs->packed;
- if (packed_refs->lock)
+ if (refs->packed_refs_lock)
die("BUG: packed-ref cache cleared while locked");
refs->packed = NULL;
release_packed_ref_cache(packed_refs);
{
struct packed_ref_cache *packed_ref_cache = get_packed_ref_cache(refs);
- if (!packed_ref_cache->lock)
+ if (!refs->packed_refs_lock)
die("BUG: packed refs not locked");
add_ref_entry(get_packed_ref_dir(packed_ref_cache),
create_ref_entry(refname, oid, REF_ISPACKED, 1));
* the packed-refs file.
*/
packed_ref_cache = get_packed_ref_cache(refs);
- packed_ref_cache->lock = &packlock;
+ refs->packed_refs_lock = &packlock;
/* Increment the reference count to prevent it from being freed: */
acquire_packed_ref_cache(packed_ref_cache);
return 0;
files_assert_main_repository(refs, "commit_packed_refs");
- if (!packed_ref_cache->lock)
+ if (!refs->packed_refs_lock)
die("BUG: packed-refs not locked");
- out = fdopen_lock_file(packed_ref_cache->lock, "w");
+ out = fdopen_lock_file(refs->packed_refs_lock, "w");
if (!out)
die_errno("unable to fdopen packed-refs descriptor");
if (ok != ITER_DONE)
die("error while iterating over references");
- if (commit_lock_file(packed_ref_cache->lock)) {
+ if (commit_lock_file(refs->packed_refs_lock)) {
save_errno = errno;
error = -1;
}
- packed_ref_cache->lock = NULL;
+ refs->packed_refs_lock = NULL;
release_packed_ref_cache(packed_ref_cache);
errno = save_errno;
return error;
files_assert_main_repository(refs, "rollback_packed_refs");
- if (!packed_ref_cache->lock)
+ if (!refs->packed_refs_lock)
die("BUG: packed-refs not locked");
- rollback_lock_file(packed_ref_cache->lock);
- packed_ref_cache->lock = NULL;
+ rollback_lock_file(refs->packed_refs_lock);
+ refs->packed_refs_lock = NULL;
release_packed_ref_cache(packed_ref_cache);
clear_packed_ref_cache(refs);
}