diff options
author | Michael Haggerty <mhagger@alum.mit.edu> | 2017-02-09 23:53:52 +0300 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2017-02-14 02:14:15 +0300 |
commit | 3c0cb0cbaef699f699b79c8be716086053760ea9 (patch) | |
tree | e438fab5d0d8cf500c074b4e3b6db3a01f44afea /refs | |
parent | 9c7d772b6b716ec5f81afd3922340588985066b8 (diff) |
read_loose_refs(): read refs using resolve_ref_recursively()
There is no need to call read_ref_full() or resolve_gitlink_ref() from
read_loose_refs(), because we already have a ref_store object in hand.
So we can call resolve_ref_recursively() ourselves. Happily, this
unifies the code for the submodule vs. non-submodule cases.
This requires resolve_ref_recursively() to be exposed to the refs
subsystem, though not to non-refs code.
Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
Reviewed-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'refs')
-rw-r--r-- | refs/files-backend.c | 18 | ||||
-rw-r--r-- | refs/refs-internal.h | 5 |
2 files changed, 9 insertions, 14 deletions
diff --git a/refs/files-backend.c b/refs/files-backend.c index 4fe92f06373..cdb6b8ff572 100644 --- a/refs/files-backend.c +++ b/refs/files-backend.c @@ -1267,20 +1267,10 @@ static void read_loose_refs(const char *dirname, struct ref_dir *dir) create_dir_entry(refs, refname.buf, refname.len, 1)); } else { - int read_ok; - - if (refs->submodule) { - hashclr(sha1); - flag = 0; - read_ok = !resolve_gitlink_ref(refs->submodule, - refname.buf, sha1); - } else { - read_ok = !read_ref_full(refname.buf, - RESOLVE_REF_READING, - sha1, &flag); - } - - if (!read_ok) { + if (!resolve_ref_recursively(&refs->base, + refname.buf, + RESOLVE_REF_READING, + sha1, &flag)) { hashclr(sha1); flag |= REF_ISBROKEN; } else if (is_null_sha1(sha1)) { diff --git a/refs/refs-internal.h b/refs/refs-internal.h index 793c850e98f..33adbf93b56 100644 --- a/refs/refs-internal.h +++ b/refs/refs-internal.h @@ -650,4 +650,9 @@ void base_ref_store_init(struct ref_store *refs, */ struct ref_store *get_ref_store(const char *submodule); +const char *resolve_ref_recursively(struct ref_store *refs, + const char *refname, + int resolve_flags, + unsigned char *sha1, int *flags); + #endif /* REFS_REFS_INTERNAL_H */ |