From f1c126bd8b24ab7a78de33f4ba1f8a496e7245e2 Mon Sep 17 00:00:00 2001 From: Jeff King Date: Sat, 5 Mar 2016 17:11:34 -0500 Subject: setup: set startup_info->have_repository more reliably When setup_git_directory() is called, we set a flag in startup_info to indicate we have a repository. But there are a few other mechanisms by which we might set up a repo: 1. When creating a new repository via init_db(), we transition from no-repo to being in a repo. We should tweak this flag at that moment. 2. In enter_repo(), a stricter form of setup_git_directory() used by server-side programs, we check the repository format config. After doing so, we know we're in a repository, and can set the flag. With these changes, library code can now reliably tell whether we are in a repository and act accordingly. We'll leave the "prefix" field as NULL, which is what happens when setup_git_directory() finds there is no prefix. Signed-off-by: Jeff King Signed-off-by: Junio C Hamano --- builtin/init-db.c | 1 + 1 file changed, 1 insertion(+) (limited to 'builtin/init-db.c') diff --git a/builtin/init-db.c b/builtin/init-db.c index 6223b7d46a..da531f6b76 100644 --- a/builtin/init-db.c +++ b/builtin/init-db.c @@ -322,6 +322,7 @@ int set_git_dir_init(const char *git_dir, const char *real_git_dir, set_git_dir(real_path(git_dir)); git_link = NULL; } + startup_info->have_repository = 1; return 0; } -- cgit v1.2.3