packed_read_raw_ref(): new function, replacing resolve_packed_ref()
Add a new function, `packed_read_raw_ref()`, which is nearly a `read_raw_ref_fn`. Use it in place of `resolve_packed_ref()`. Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
parent
38b86e81ae
commit
d13fa1a9ba
@ -608,27 +608,23 @@ static struct ref_entry *get_packed_ref(struct packed_ref_store *refs,
|
|||||||
return find_ref_entry(get_packed_refs(refs), refname);
|
return find_ref_entry(get_packed_refs(refs), refname);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
static int packed_read_raw_ref(struct packed_ref_store *refs,
|
||||||
* A loose ref file doesn't exist; check for a packed ref.
|
const char *refname, unsigned char *sha1,
|
||||||
*/
|
struct strbuf *referent, unsigned int *type)
|
||||||
static int resolve_packed_ref(struct files_ref_store *refs,
|
|
||||||
const char *refname,
|
|
||||||
unsigned char *sha1, unsigned int *flags)
|
|
||||||
{
|
{
|
||||||
struct ref_entry *entry;
|
struct ref_entry *entry;
|
||||||
|
|
||||||
/*
|
*type = 0;
|
||||||
* The loose reference file does not exist; check for a packed
|
|
||||||
* reference.
|
entry = get_packed_ref(refs, refname);
|
||||||
*/
|
if (!entry) {
|
||||||
entry = get_packed_ref(refs->packed_ref_store, refname);
|
errno = ENOENT;
|
||||||
if (entry) {
|
return -1;
|
||||||
hashcpy(sha1, entry->u.value.oid.hash);
|
|
||||||
*flags |= REF_ISPACKED;
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
/* refname is not a packed reference. */
|
|
||||||
return -1;
|
hashcpy(sha1, entry->u.value.oid.hash);
|
||||||
|
*type = REF_ISPACKED;
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int files_read_raw_ref(struct ref_store *ref_store,
|
static int files_read_raw_ref(struct ref_store *ref_store,
|
||||||
@ -674,7 +670,8 @@ stat_ref:
|
|||||||
if (lstat(path, &st) < 0) {
|
if (lstat(path, &st) < 0) {
|
||||||
if (errno != ENOENT)
|
if (errno != ENOENT)
|
||||||
goto out;
|
goto out;
|
||||||
if (resolve_packed_ref(refs, refname, sha1, type)) {
|
if (packed_read_raw_ref(refs->packed_ref_store, refname,
|
||||||
|
sha1, referent, type)) {
|
||||||
errno = ENOENT;
|
errno = ENOENT;
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
@ -713,7 +710,8 @@ stat_ref:
|
|||||||
* ref is supposed to be, there could still be a
|
* ref is supposed to be, there could still be a
|
||||||
* packed ref:
|
* packed ref:
|
||||||
*/
|
*/
|
||||||
if (resolve_packed_ref(refs, refname, sha1, type)) {
|
if (packed_read_raw_ref(refs->packed_ref_store, refname,
|
||||||
|
sha1, referent, type)) {
|
||||||
errno = EISDIR;
|
errno = EISDIR;
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user