From: Derrick Stolee Date: Fri, 01 Jun 2018 11:46:08 GMT Subject: Re: [RFC PATCH 4/6] commit-graph: avoid writing when repo is shallow Message-ID: <95354da4-7590-4fa6-de83-30f883d77188@gmail.com> In-Reply-To: On 5/31/2018 10:30 PM, Junio C Hamano wrote: > Derrick Stolee writes: > >> Shallow clones do not interact well with the commit-graph feature for >> several reasons. Instead of doing the hard thing to fix those >> interactions, instead prevent reading or writing a commit-graph file for >> shallow repositories. > The latter instead would want to vanish, I would guess. Do you mean that we should call destroy_commit_graph() if we detect a shallow repository during write_commit_graph(), then I can make that change. > >> Signed-off-by: Derrick Stolee >> --- >> commit-graph.c | 12 ++++++++++++ >> 1 file changed, 12 insertions(+) >> >> diff --git a/commit-graph.c b/commit-graph.c >> index 95af4ed519..80e377b90f 100644 >> --- a/commit-graph.c >> +++ b/commit-graph.c >> @@ -208,6 +208,9 @@ static void prepare_commit_graph(void) >> return; >> prepare_commit_graph_run_once = 1; >> >> + if (is_repository_shallow()) >> + return; >> + >> obj_dir = get_object_directory(); >> prepare_commit_graph_one(obj_dir); >> prepare_alt_odb(); >> @@ -711,6 +714,15 @@ void write_commit_graph(const char *obj_dir, >> int num_extra_edges; >> struct commit_list *parent; >> >> + /* >> + * Shallow clones are not supproted, as they create bad >> + * generation skips as they are un-shallowed. >> + */ >> + if (is_repository_shallow()) { >> + warning("writing a commit-graph in a shallow repository is not supported"); >> + return; >> + } >> + >> oids.nr = 0; >> oids.alloc = approximate_object_count() / 4;