Commit 70867f7c by Patrick Steinhardt

repository: disentangle shallow and normal grafts

When loading shallow grafts, we add each of the grafting commits to the
grafts backed by ".git/info/grafts". Keeping track of both grafts
separately, but partially storing them in a common grafts structure is
likely to lead to inconsistencies. In fact, there already are
inconsistencies if refreshing shallow grafts at a later point, as we
only refresh the shallows, but not the normal grafts in that case.

Disentangle both grafting stores and instead check both separately when
parsing commits.
parent a11026ec
......@@ -504,7 +504,8 @@ int git_commit__parse_ext(git_commit *commit, git_odb_object *odb_obj, unsigned
return error;
/* Perform necessary grafts */
if (git_grafts_get(&graft, repo->grafts, git_odb_object_id(odb_obj)) != GIT_ENOTFOUND) {
if (git_grafts_get(&graft, repo->grafts, git_odb_object_id(odb_obj)) == 0 ||
git_grafts_get(&graft, repo->shallow_grafts, git_odb_object_id(odb_obj)) == 0) {
size_t idx;
git_oid *oid;
git_array_clear(commit->parent_ids);
......
......@@ -613,22 +613,15 @@ cleanup:
static int load_shallow(git_repository *repo)
{
git_array_oid_t parents = GIT_ARRAY_INIT;
git_oidarray roots;
int error;
size_t i;
/* Graft shallow roots */
if ((error = git_repository_shallow_roots(&roots, repo)) < 0)
goto out;
for (i = 0; i < roots.count; i++)
if ((error = git_grafts_add(repo->grafts, &roots.ids[i], parents)) < 0)
goto out;
return error;
out:
git_oidarray_free(&roots);
return error;
return 0;
}
int git_repository_open_bare(
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment