get_packed_ref(): add a files_ref_store argument

Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Michael Haggerty committed Sep 4, 2016 at 18:08 UTC f0d21efc3536b369e4a95d78628c19a941381be3
1 file changed +9 -7
refs/files-backend.c
+9 -7
@@ -1403,11 +1403,9 @@ int resolve_gitlink_ref(const char *path, const char *refname, unsigned char *sh
1403 * Return the ref_entry for the given refname from the packed
1404 * references. If it does not exist, return NULL.
1405 */
1406 -static struct ref_entry *get_packed_ref(const char *refname)
1406 +static struct ref_entry *get_packed_ref(struct files_ref_store *refs,
1407 + const char *refname)
1408 {
1408 - struct files_ref_store *refs =
1409 - get_files_ref_store(NULL, "get_packed_ref");
1410 -
1409 return find_ref(get_packed_refs(refs), refname);
1410 }
1411
@@ -1418,13 +1416,16 @@ static int resolve_missing_loose_ref(const char *refname,
1416 unsigned char *sha1,
1417 unsigned int *flags)
1418 {
1419 + struct files_ref_store *refs =
1420 + get_files_ref_store(NULL, "resolve_missing_loose_ref");
1421 +
1422 struct ref_entry *entry;
1423
1424 /*
1425 * The loose reference file does not exist; check for a packed
1426 * reference.
1427 */
1427 - entry = get_packed_ref(refname);
1428 + entry = get_packed_ref(refs, refname);
1429 if (entry) {
1430 hashcpy(sha1, entry->u.value.oid.hash);
1431 *flags |= REF_ISPACKED;
@@ -1836,6 +1837,7 @@ static enum peel_status peel_entry(struct ref_entry *entry, int repeel)
1837
1838 int peel_ref(const char *refname, unsigned char *sha1)
1839 {
1840 + struct files_ref_store *refs = get_files_ref_store(NULL, "peel_ref");
1841 int flag;
1842 unsigned char base[20];
1843
@@ -1860,7 +1862,7 @@ int peel_ref(const char *refname, unsigned char *sha1)
1862 * have REF_KNOWS_PEELED.
1863 */
1864 if (flag & REF_ISPACKED) {
1863 - struct ref_entry *r = get_packed_ref(refname);
1865 + struct ref_entry *r = get_packed_ref(refs, refname);
1866 if (r) {
1867 if (peel_entry(r, 0))
1868 return -1;
@@ -2469,7 +2471,7 @@ static int repack_without_refs(struct string_list *refnames, struct strbuf *err)
2471
2472 /* Look for a packed ref */
2473 for_each_string_list_item(refname, refnames) {
2472 - if (get_packed_ref(refname->string)) {
2474 + if (get_packed_ref(refs, refname->string)) {
2475 needs_repacking = 1;
2476 break;
2477 }