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.
This commit is contained in:
@@ -116,7 +116,7 @@ py_oid_to_git_oid_expand(git_repository *repo, PyObject *py_str, git_oid *oid)
|
|||||||
int err;
|
int err;
|
||||||
size_t len;
|
size_t len;
|
||||||
git_odb *odb = NULL;
|
git_odb *odb = NULL;
|
||||||
git_odb_object *obj = NULL;
|
git_oid tmp;
|
||||||
|
|
||||||
len = py_oid_to_git_oid(py_str, oid);
|
len = py_oid_to_git_oid(py_str, oid);
|
||||||
if (len == 0)
|
if (len == 0)
|
||||||
@@ -130,17 +130,16 @@ py_oid_to_git_oid_expand(git_repository *repo, PyObject *py_str, git_oid *oid)
|
|||||||
if (err < 0)
|
if (err < 0)
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
err = git_odb_read_prefix(&obj, odb, oid, len);
|
err = git_odb_exists_prefix(&tmp, odb, oid, len);
|
||||||
if (err < 0)
|
if (err < 0)
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
git_oid_cpy(oid, git_odb_object_id(obj));
|
git_oid_cpy(oid, &tmp);
|
||||||
git_odb_object_free(obj);
|
|
||||||
git_odb_free(odb);
|
git_odb_free(odb);
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
error:
|
error:
|
||||||
git_odb_object_free(obj);
|
|
||||||
git_odb_free(odb);
|
git_odb_free(odb);
|
||||||
Error_set(err);
|
Error_set(err);
|
||||||
return -1;
|
return -1;
|
||||||
|
Reference in New Issue
Block a user