diff options
author | Michael Haggerty <mhagger@alum.mit.edu> | 2016-06-18 06:15:14 +0200 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2016-06-20 11:38:19 -0700 |
commit | a873924483ec6ec548e94d723fe62875b1a4ec93 (patch) | |
tree | e730e6582dac53af3627170cacc32ada20a50789 /refs | |
parent | entry_resolves_to_object(): rename function from ref_resolves_to_object() (diff) | |
download | tgif-a873924483ec6ec548e94d723fe62875b1a4ec93.tar.xz |
ref_resolves_to_object(): new function
Extract new function ref_resolves_to_object() from
entry_resolves_to_object(). It can be used even if there is no ref_entry
at hand.
Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'refs')
-rw-r--r-- | refs/files-backend.c | 27 |
1 files changed, 20 insertions, 7 deletions
diff --git a/refs/files-backend.c b/refs/files-backend.c index c24a78ea8e..62280b5c70 100644 --- a/refs/files-backend.c +++ b/refs/files-backend.c @@ -513,22 +513,35 @@ static void sort_ref_dir(struct ref_dir *dir) } /* - * Return true iff the reference described by entry can be resolved to - * an object in the database. Emit a warning if the referred-to - * object does not exist. + * Return true if refname, which has the specified oid and flags, can + * be resolved to an object in the database. If the referred-to object + * does not exist, emit a warning and return false. */ -static int entry_resolves_to_object(struct ref_entry *entry) +static int ref_resolves_to_object(const char *refname, + const struct object_id *oid, + unsigned int flags) { - if (entry->flag & REF_ISBROKEN) + if (flags & REF_ISBROKEN) return 0; - if (!has_sha1_file(entry->u.value.oid.hash)) { - error("%s does not point to a valid object!", entry->name); + if (!has_sha1_file(oid->hash)) { + error("%s does not point to a valid object!", refname); return 0; } return 1; } /* + * Return true if the reference described by entry can be resolved to + * an object in the database; otherwise, emit a warning and return + * false. + */ +static int entry_resolves_to_object(struct ref_entry *entry) +{ + return ref_resolves_to_object(entry->name, + &entry->u.value.oid, entry->flag); +} + +/* * current_ref is a performance hack: when iterating over references * using the for_each_ref*() functions, current_ref is set to the * current reference's entry before calling the callback function. If |