summaryrefslogtreecommitdiff
path: root/environment.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2013-10-17 15:45:55 -0700
committerJunio C Hamano <gitster@pobox.com>2013-10-17 15:45:55 -0700
commitf8aeacfa1f1e7b1f2d7b0c5fbb7becbbc6248183 (patch)
treec9d1898aecd8d05574450db74d26c1f2c8d88741 /environment.c
parent7d9dd6da4a02d26b6841b67f6b1a8c5773114d3e (diff)
parent487a2b732230608fe7f2cdc46c9f11bd646cb1ac (diff)
downloadgit-f8aeacfa1f1e7b1f2d7b0c5fbb7becbbc6248183.tar.gz
Merge branch 'nd/git-dir-pointing-at-gitfile' into maint
* nd/git-dir-pointing-at-gitfile: Make setup_git_env() resolve .git file when $GIT_DIR is not specified
Diffstat (limited to 'environment.c')
-rw-r--r--environment.c9
1 files changed, 4 insertions, 5 deletions
diff --git a/environment.c b/environment.c
index 5398c36dd4..378254c77a 100644
--- a/environment.c
+++ b/environment.c
@@ -123,14 +123,13 @@ static char *expand_namespace(const char *raw_namespace)
static void setup_git_env(void)
{
+ const char *gitfile;
+
git_dir = getenv(GIT_DIR_ENVIRONMENT);
- git_dir = git_dir ? xstrdup(git_dir) : NULL;
- if (!git_dir) {
- git_dir = read_gitfile(DEFAULT_GIT_DIR_ENVIRONMENT);
- git_dir = git_dir ? xstrdup(git_dir) : NULL;
- }
if (!git_dir)
git_dir = DEFAULT_GIT_DIR_ENVIRONMENT;
+ gitfile = read_gitfile(git_dir);
+ git_dir = xstrdup(gitfile ? gitfile : git_dir);
git_object_dir = getenv(DB_ENVIRONMENT);
if (!git_object_dir) {
git_object_dir = xmalloc(strlen(git_dir) + 9);