aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--environment.c9
-rwxr-xr-xt/t0001-init.sh4
2 files changed, 8 insertions, 5 deletions
diff --git a/environment.c b/environment.c
index e2e75c166..03c9eb7a2 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);
diff --git a/t/t0001-init.sh b/t/t0001-init.sh
index ad6641056..9fb582b19 100755
--- a/t/t0001-init.sh
+++ b/t/t0001-init.sh
@@ -379,6 +379,10 @@ test_expect_success 'init with separate gitdir' '
test -d realgitdir/refs
'
+test_expect_success 're-init on .git file' '
+ ( cd newdir && git init )
+'
+
test_expect_success 're-init to update git link' '
(
cd newdir &&