summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLibravatar Michael Haggerty <mhagger@alum.mit.edu>2017-06-23 09:01:26 +0200
committerLibravatar Junio C Hamano <gitster@pobox.com>2017-06-23 13:27:32 -0700
commit8e821c38f76c49e0e679c8d79c0b150d18aba155 (patch)
tree30c797637030f85f6a9eea7b2b13496603f68150
parentvalidate_packed_ref_cache(): take a `packed_ref_store *` parameter (diff)
downloadtgif-8e821c38f76c49e0e679c8d79c0b150d18aba155.tar.xz
get_packed_ref_cache(): take a `packed_ref_store *` parameter
It only cares about the packed-refs part of the reference store. Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu> Signed-off-by: Junio C Hamano <gitster@pobox.com>
-rw-r--r--refs/files-backend.c26
1 files changed, 12 insertions, 14 deletions
diff --git a/refs/files-backend.c b/refs/files-backend.c
index f061506bf0..b2ef7b3bb9 100644
--- a/refs/files-backend.c
+++ b/refs/files-backend.c
@@ -404,24 +404,22 @@ static void validate_packed_ref_cache(struct packed_ref_store *refs)
}
/*
- * Get the packed_ref_cache for the specified files_ref_store,
+ * Get the packed_ref_cache for the specified packed_ref_store,
* creating and populating it if it hasn't been read before or if the
* file has been changed (according to its `validity` field) since it
* was last read. On the other hand, if we hold the lock, then assume
* that the file hasn't been changed out from under us, so skip the
* extra `stat()` call in `stat_validity_check()`.
*/
-static struct packed_ref_cache *get_packed_ref_cache(struct files_ref_store *refs)
+static struct packed_ref_cache *get_packed_ref_cache(struct packed_ref_store *refs)
{
- const char *packed_refs_file = refs->packed_ref_store->path;
+ if (!is_lock_file_locked(&refs->lock))
+ validate_packed_ref_cache(refs);
- if (!is_lock_file_locked(&refs->packed_ref_store->lock))
- validate_packed_ref_cache(refs->packed_ref_store);
-
- if (!refs->packed_ref_store->cache)
- refs->packed_ref_store->cache = read_packed_refs(packed_refs_file);
+ if (!refs->cache)
+ refs->cache = read_packed_refs(refs->path);
- return refs->packed_ref_store->cache;
+ return refs->cache;
}
static struct ref_dir *get_packed_ref_dir(struct packed_ref_cache *packed_ref_cache)
@@ -431,7 +429,7 @@ static struct ref_dir *get_packed_ref_dir(struct packed_ref_cache *packed_ref_ca
static struct ref_dir *get_packed_refs(struct files_ref_store *refs)
{
- return get_packed_ref_dir(get_packed_ref_cache(refs));
+ return get_packed_ref_dir(get_packed_ref_cache(refs->packed_ref_store));
}
/*
@@ -1151,7 +1149,7 @@ static struct ref_iterator *files_ref_iterator_begin(
loose_iter = cache_ref_iterator_begin(get_loose_ref_cache(refs),
prefix, 1);
- iter->packed_ref_cache = get_packed_ref_cache(refs);
+ iter->packed_ref_cache = get_packed_ref_cache(refs->packed_ref_store);
acquire_packed_ref_cache(iter->packed_ref_cache);
packed_iter = cache_ref_iterator_begin(iter->packed_ref_cache->cache,
prefix, 0);
@@ -1365,7 +1363,7 @@ static int lock_packed_refs(struct files_ref_store *refs, int flags)
*/
validate_packed_ref_cache(refs->packed_ref_store);
- packed_ref_cache = get_packed_ref_cache(refs);
+ packed_ref_cache = get_packed_ref_cache(refs->packed_ref_store);
/* Increment the reference count to prevent it from being freed: */
acquire_packed_ref_cache(packed_ref_cache);
return 0;
@@ -1380,7 +1378,7 @@ static int lock_packed_refs(struct files_ref_store *refs, int flags)
static int commit_packed_refs(struct files_ref_store *refs)
{
struct packed_ref_cache *packed_ref_cache =
- get_packed_ref_cache(refs);
+ get_packed_ref_cache(refs->packed_ref_store);
int ok, error = 0;
int save_errno = 0;
FILE *out;
@@ -1426,7 +1424,7 @@ static int commit_packed_refs(struct files_ref_store *refs)
static void rollback_packed_refs(struct files_ref_store *refs)
{
struct packed_ref_cache *packed_ref_cache =
- get_packed_ref_cache(refs);
+ get_packed_ref_cache(refs->packed_ref_store);
files_assert_main_repository(refs, "rollback_packed_refs");