Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 3d9ef2d

Browse files
committed
Revert "object: correct the expected ID size in prefix lookup"
This reverts commit 969d4b7. This was a fluke from Coverity. The length to all the APIs in the library is supposed to be passed in as nibbles, not bytes. Passing it as bytes would prevent us from parsing uneven-sized SHA1 strings. Also, the rest of the library was still using nibbles (including revparse and the odb_prefix APIs), so this change was seriously breaking things in unexpected ways. ^^
1 parent 1488807 commit 3d9ef2d

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/object.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -129,10 +129,10 @@ int git_object_lookup_prefix(
129129
if (error < 0)
130130
return error;
131131

132-
if (len > GIT_OID_RAWSZ)
133-
len = GIT_OID_RAWSZ;
132+
if (len > GIT_OID_HEXSZ)
133+
len = GIT_OID_HEXSZ;
134134

135-
if (len == GIT_OID_RAWSZ) {
135+
if (len == GIT_OID_HEXSZ) {
136136
git_cached_obj *cached = NULL;
137137

138138
/* We want to match the full id : we can first look up in the cache,
@@ -172,9 +172,9 @@ int git_object_lookup_prefix(
172172
memcpy(short_oid.id, id->id, (len + 1) / 2);
173173
if (len % 2)
174174
short_oid.id[len / 2] &= 0xF0;
175-
memset(short_oid.id + (len + 1) / 2, 0, (GIT_OID_RAWSZ - len) / 2);
175+
memset(short_oid.id + (len + 1) / 2, 0, (GIT_OID_HEXSZ - len) / 2);
176176

177-
/* If len < GIT_OID_RAWSZ (a strict short oid was given), we have
177+
/* If len < GIT_OID_HEXSZ (a strict short oid was given), we have
178178
* 2 options :
179179
* - We always search in the cache first. If we find that short oid is
180180
* ambiguous, we can stop. But in all the other cases, we must then

0 commit comments

Comments
 (0)