summaryrefslogtreecommitdiff
path: root/setup.c
diff options
context:
space:
mode:
authorJeff King <peff@peff.net>2016-03-05 22:11:34 (GMT)
committerJunio C Hamano <gitster@pobox.com>2016-03-07 01:18:16 (GMT)
commitf1c126bd8b24ab7a78de33f4ba1f8a496e7245e2 (patch)
tree8655fa8f0905bd5ebcc36e1cd5bd38a4883fbf8e /setup.c
parent46c3cd44d7a1e8a33ad66c017ac9e3575cc88c00 (diff)
downloadgit-f1c126bd8b24ab7a78de33f4ba1f8a496e7245e2.zip
git-f1c126bd8b24ab7a78de33f4ba1f8a496e7245e2.tar.gz
git-f1c126bd8b24ab7a78de33f4ba1f8a496e7245e2.tar.bz2
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 <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'setup.c')
-rw-r--r--setup.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/setup.c b/setup.c
index fa7a306..3439ec6 100644
--- a/setup.c
+++ b/setup.c
@@ -986,7 +986,9 @@ int check_repository_format_version(const char *var, const char *value, void *cb
int check_repository_format(void)
{
- return check_repository_format_gently(get_git_dir(), NULL);
+ check_repository_format_gently(get_git_dir(), NULL);
+ startup_info->have_repository = 1;
+ return 0;
}
/*