1
0
Fork 0
mirror of https://github.com/git/git.git synced 2024-06-09 02:26:11 +02:00

Merge branch 'sg/maint-gitdir-in-subdir' into maint

* sg/maint-gitdir-in-subdir:
  Fix gitdir detection when in subdir of gitdir
This commit is contained in:
Junio C Hamano 2009-02-05 18:05:43 -08:00
commit f20408dadb
2 changed files with 12 additions and 1 deletions

View File

@ -456,7 +456,11 @@ const char *setup_git_directory_gently(int *nongit_ok)
inside_git_dir = 1;
if (!work_tree_env)
inside_work_tree = 0;
setenv(GIT_DIR_ENVIRONMENT, ".", 1);
if (offset != len) {
cwd[offset] = '\0';
setenv(GIT_DIR_ENVIRONMENT, cwd, 1);
} else
setenv(GIT_DIR_ENVIRONMENT, ".", 1);
check_repository_format_gently(nongit_ok);
return NULL;
}

View File

@ -92,6 +92,13 @@ cd sub/dir || exit 1
test_rev_parse 'in repo.git/sub/dir' false true true sub/dir/
cd ../../../.. || exit 1
test_expect_success 'detecting gitdir when cwd is in a subdir of gitdir' '
(expected=$(pwd)/repo.git &&
cd repo.git/refs &&
unset GIT_DIR &&
test "$expected" = "$(git rev-parse --git-dir)")
'
test_expect_success 'repo finds its work tree' '
(cd repo.git &&
: > work/sub/dir/untracked &&