diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/object.c | 4 | ||||
| -rw-r--r-- | src/odb_pack.c | 4 |
2 files changed, 6 insertions, 2 deletions
diff --git a/src/object.c b/src/object.c index e6e976756..db8d2062c 100644 --- a/src/object.c +++ b/src/object.c @@ -104,8 +104,8 @@ int git_object_lookup_short_oid(git_object **object_out, git_repository *repo, c assert(repo && object_out && id); - if (len == 0) - return git__throw(GIT_EAMBIGUOUSOIDPREFIX, "Failed to lookup object. Prefix length should be not be 0."); + if (len < GIT_OID_MINPREFIXLEN) + return git__throw(GIT_EAMBIGUOUSOIDPREFIX, "Failed to lookup object. Prefix length is lower than %d.", GIT_OID_MINPREFIXLEN); if (len > GIT_OID_HEXSZ) { len = GIT_OID_HEXSZ; } diff --git a/src/odb_pack.c b/src/odb_pack.c index 605608314..070bde6e2 100644 --- a/src/odb_pack.c +++ b/src/odb_pack.c @@ -268,6 +268,8 @@ static off_t nth_packed_object_offset(const struct pack_file *p, uint32_t n); * a prefix of an identifier. * Throws GIT_EAMBIGUOUSOIDPREFIX if short oid * is ambiguous within the pack. + * This method assumes that len is between + * GIT_OID_MINPREFIXLEN and GIT_OID_HEXSZ. */ static int pack_entry_find_offset( off_t *offset_out, @@ -289,6 +291,8 @@ static int pack_entry_find(struct pack_entry *e, * a prefix of an identifier. * Throws GIT_EAMBIGUOUSOIDPREFIX if short oid * is ambiguous. + * This method assumes that len is between + * GIT_OID_MINPREFIXLEN and GIT_OID_HEXSZ. */ static int pack_entry_find_unique_short_oid(struct pack_entry *e, struct pack_backend *backend, |
