commit_graft_oid_access);
}
+static void unparse_commit(struct repository *r, const struct object_id *oid)
+{
+ struct commit *c = lookup_commit(r, oid);
+
+ if (!c->object.parsed)
+ return;
+ free_commit_list(c->parents);
+ c->parents = NULL;
+ c->object.parsed = 0;
+}
+
int register_commit_graft(struct repository *r, struct commit_graft *graft,
int ignore_dups)
{
(r->parsed_objects->grafts_nr - pos - 1) *
sizeof(*r->parsed_objects->grafts));
r->parsed_objects->grafts[pos] = graft;
+ unparse_commit(r, &graft->oid);
return 0;
}
{
int i;
- for (i = 0; i < r->parsed_objects->grafts_nr; i++)
+ for (i = 0; i < r->parsed_objects->grafts_nr; i++) {
+ unparse_commit(r, &r->parsed_objects->grafts[i]->oid);
free(r->parsed_objects->grafts[i]);
+ }
r->parsed_objects->grafts_nr = 0;
r->parsed_objects->commit_graft_prepared = 0;
}
{
int res = commit_lock_file(&lk->lock);
reset_repository_shallow(r);
+
+ /*
+ * Update in-memory data structures with the new shallow information,
+ * including unparsing all commits that now have grafts.
+ */
+ is_repository_shallow(r);
+
return res;
}
test_expect_success 'fetch --update-shallow into a repo with submodules' '
git init a-submodule &&
test_commit -C a-submodule foo &&
+
+ test_when_finished "rm -rf repo-with-sub" &&
git init repo-with-sub &&
git -C repo-with-sub submodule add ../a-submodule a-submodule &&
git -C repo-with-sub commit -m "added submodule" &&
git -C repo-with-sub fetch --update-shallow ../shallow/.git refs/heads/*:refs/remotes/shallow/*
'
+test_expect_success 'fetch --update-shallow a commit that is also a shallow point into a repo with submodules' '
+ test_when_finished "rm -rf repo-with-sub" &&
+ git init repo-with-sub &&
+ git -C repo-with-sub submodule add ../a-submodule a-submodule &&
+ git -C repo-with-sub commit -m "added submodule" &&
+
+ SHALLOW=$(cat shallow/.git/shallow) &&
+ git -C repo-with-sub fetch --update-shallow ../shallow/.git "$SHALLOW":refs/heads/a-shallow
+'
+
test_expect_success 'fetch --update-shallow (with fetch.writeCommitGraph)' '
(
cd shallow &&