commit-graph: return if there is no git directory

Return early if git directory does not exist. This will protect against test failures in the upcoming change to BUG in prepare_repo_settings if no git directory exists. Signed-off-by: Lessley Dennington <lessleydennington@gmail.com> Reviewed-by: Elijah Newren <newren@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Lessley Dennington committed Dec 6, 2021 at 15:55 UTC 0803f9c7cdff63d0c6cb992ba90f53fdcae50869
1 file changed +4 -1
commit-graph.c
+4 -1
@@ -632,10 +632,13 @@ static int prepare_commit_graph(struct repository *r)
632 struct object_directory *odb;
633
634 /*
635 + * Early return if there is no git dir or if the commit graph is
636 + * disabled.
637 + *
638 * This must come before the "already attempted?" check below, because
639 * we want to disable even an already-loaded graph file.
640 */
638 - if (r->commit_graph_disabled)
641 + if (!r->gitdir || r->commit_graph_disabled)
642 return 0;
643
644 if (r->objects->commit_graph_attempted)