* it might still be current; otherwise, NULL.
*/
struct packed_ref_cache *cache;
+
+ /*
+ * Lock used for the "packed-refs" file. Note that this (and
+ * thus the enclosing `packed_ref_store`) must not be freed.
+ */
+ struct lock_file lock;
};
static struct packed_ref_store *packed_ref_store_create(
struct ref_cache *loose;
- /*
- * Lock used for the "packed-refs" file. Note that this (and
- * thus the enclosing `files_ref_store`) must not be freed.
- */
- struct lock_file packed_refs_lock;
-
struct packed_ref_store *packed_ref_store;
};
if (refs->packed_ref_store->cache) {
struct packed_ref_cache *packed_refs = refs->packed_ref_store->cache;
- if (is_lock_file_locked(&refs->packed_refs_lock))
+ if (is_lock_file_locked(&refs->packed_ref_store->lock))
die("BUG: packed-ref cache cleared while locked");
refs->packed_ref_store->cache = NULL;
release_packed_ref_cache(packed_refs);
{
const char *packed_refs_file = refs->packed_ref_store->path;
- if (!is_lock_file_locked(&refs->packed_refs_lock))
+ if (!is_lock_file_locked(&refs->packed_ref_store->lock))
validate_packed_ref_cache(refs);
if (!refs->packed_ref_store->cache)
struct ref_dir *packed_refs;
struct ref_entry *packed_entry;
- if (!is_lock_file_locked(&refs->packed_refs_lock))
+ if (!is_lock_file_locked(&refs->packed_ref_store->lock))
die("BUG: packed refs not locked");
if (check_refname_format(refname, REFNAME_ALLOW_ONELEVEL))
}
if (hold_lock_file_for_update_timeout(
- &refs->packed_refs_lock, refs->packed_ref_store->path,
+ &refs->packed_ref_store->lock,
+ refs->packed_ref_store->path,
flags, timeout_value) < 0)
return -1;
files_assert_main_repository(refs, "commit_packed_refs");
- if (!is_lock_file_locked(&refs->packed_refs_lock))
+ if (!is_lock_file_locked(&refs->packed_ref_store->lock))
die("BUG: packed-refs not locked");
- out = fdopen_lock_file(&refs->packed_refs_lock, "w");
+ out = fdopen_lock_file(&refs->packed_ref_store->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(&refs->packed_refs_lock)) {
+ if (commit_lock_file(&refs->packed_ref_store->lock)) {
save_errno = errno;
error = -1;
}
files_assert_main_repository(refs, "rollback_packed_refs");
- if (!is_lock_file_locked(&refs->packed_refs_lock))
+ if (!is_lock_file_locked(&refs->packed_ref_store->lock))
die("BUG: packed-refs not locked");
- rollback_lock_file(&refs->packed_refs_lock);
+ rollback_lock_file(&refs->packed_ref_store->lock);
release_packed_ref_cache(packed_ref_cache);
clear_packed_ref_cache(refs);
}