Skip to content

Commit cb3010c

Browse files
committed
odb_read_prefix: reset error in backends loop
When looking for an object by prefix, we query all the backends so that we can ensure that there is no ambiguity. We need to reset the `error` value between backends; otherwise the first backend may find an object by prefix, but subsequent backends may not. If we do not reset the `error` value then it will remain at `GIT_ENOTFOUND` and `read_prefix_1` will fail, despite having actually found an object.
1 parent bd69280 commit cb3010c

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/odb.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1116,8 +1116,11 @@ static int read_prefix_1(git_odb_object **out, git_odb *db,
11161116
if (b->read_prefix != NULL) {
11171117
git_oid full_oid;
11181118
error = b->read_prefix(&full_oid, &raw.data, &raw.len, &raw.type, b, key, len);
1119-
if (error == GIT_ENOTFOUND || error == GIT_PASSTHROUGH)
1119+
1120+
if (error == GIT_ENOTFOUND || error == GIT_PASSTHROUGH) {
1121+
error = 0;
11201122
continue;
1123+
}
11211124

11221125
if (error)
11231126
goto out;

0 commit comments

Comments
 (0)