diff --git a/commit-graph.c b/commit-graph.c index 9abe62bd5a..0820cf5fb8 100644 --- a/commit-graph.c +++ b/commit-graph.c @@ -740,13 +740,13 @@ static struct commit_graph *prepare_commit_graph(struct repository *r) struct odb_source *source; /* - * Early return if there is no git dir or if the commit graph is + * Early return if there is no object database or if the commit graph is * disabled. * * This must come before the "already attempted?" check below, because * we want to disable even an already-loaded graph file. */ - if (!r->gitdir || r->commit_graph_disabled) + if (!r->objects || r->commit_graph_disabled) return NULL; if (r->objects->commit_graph_attempted) diff --git a/setup.c b/setup.c index 0dc9fe4565..4a8d6230b1 100644 --- a/setup.c +++ b/setup.c @@ -2043,13 +2043,12 @@ const char *setup_git_directory_gently(struct repository *repo, int *nongit_ok) setup_git_env_internal(repo, gitdir); } - repo->objects = odb_new(repo, - getenv_safe(&to_free, DB_ENVIRONMENT), - getenv_safe(&to_free, ALTERNATE_DB_ENVIRONMENT)); - if (startup_info->have_repository) { struct strbuf err = STRBUF_INIT; + repo->objects = odb_new(repo, + getenv_safe(&to_free, DB_ENVIRONMENT), + getenv_safe(&to_free, ALTERNATE_DB_ENVIRONMENT)); if (apply_repository_format(repo, &repo_fmt, &err) < 0) die("%s", err.buf);