Skip to content

Commit 612639a

Browse files
committed
oid: do not load the object when expanding
We now have a function which lets us expand an id prefix by checking for existence and uniqueness instead of loading the object with that id.
1 parent 2a429aa commit 612639a

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

src/oid.c

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ py_oid_to_git_oid_expand(git_repository *repo, PyObject *py_str, git_oid *oid)
116116
int err;
117117
size_t len;
118118
git_odb *odb = NULL;
119-
git_odb_object *obj = NULL;
119+
git_oid tmp;
120120

121121
len = py_oid_to_git_oid(py_str, oid);
122122
if (len == 0)
@@ -130,17 +130,16 @@ py_oid_to_git_oid_expand(git_repository *repo, PyObject *py_str, git_oid *oid)
130130
if (err < 0)
131131
goto error;
132132

133-
err = git_odb_read_prefix(&obj, odb, oid, len);
133+
err = git_odb_exists_prefix(&tmp, odb, oid, len);
134134
if (err < 0)
135135
goto error;
136136

137-
git_oid_cpy(oid, git_odb_object_id(obj));
138-
git_odb_object_free(obj);
137+
git_oid_cpy(oid, &tmp);
138+
139139
git_odb_free(odb);
140140
return 0;
141141

142142
error:
143-
git_odb_object_free(obj);
144143
git_odb_free(odb);
145144
Error_set(err);
146145
return -1;

0 commit comments

Comments
 (0)