diff options
author | Junio C Hamano <gitster@pobox.com> | 2009-01-21 16:51:25 -0800 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2009-01-21 16:51:25 -0800 |
commit | 0aac1614e976164259edf5f950da4cbebe069466 (patch) | |
tree | 50f0dd772ab75c2086458b51b421bde6863574ed | |
parent | Merge branch 'jf/am-failure-report' (diff) | |
parent | Fix gitdir detection when in subdir of gitdir (diff) | |
download | tgif-0aac1614e976164259edf5f950da4cbebe069466.tar.xz |
Merge branch 'sg/maint-gitdir-in-subdir'
* sg/maint-gitdir-in-subdir:
Fix gitdir detection when in subdir of gitdir
-rw-r--r-- | setup.c | 6 | ||||
-rwxr-xr-x | t/t1501-worktree.sh | 7 |
2 files changed, 12 insertions, 1 deletions
@@ -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; } diff --git a/t/t1501-worktree.sh b/t/t1501-worktree.sh index f6a6f839a1..27dc6c55d5 100755 --- a/t/t1501-worktree.sh +++ b/t/t1501-worktree.sh @@ -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 && |