File tree Expand file tree Collapse file tree 2 files changed +12
-1
lines changed Expand file tree Collapse file tree 2 files changed +12
-1
lines changed Original file line number Diff line number Diff line change @@ -456,7 +456,11 @@ const char *setup_git_directory_gently(int *nongit_ok)
456
456
inside_git_dir = 1 ;
457
457
if (!work_tree_env )
458
458
inside_work_tree = 0 ;
459
- setenv (GIT_DIR_ENVIRONMENT , "." , 1 );
459
+ if (offset != len ) {
460
+ cwd [offset ] = '\0' ;
461
+ setenv (GIT_DIR_ENVIRONMENT , cwd , 1 );
462
+ } else
463
+ setenv (GIT_DIR_ENVIRONMENT , "." , 1 );
460
464
check_repository_format_gently (nongit_ok );
461
465
return NULL ;
462
466
}
Original file line number Diff line number Diff line change @@ -92,6 +92,13 @@ cd sub/dir || exit 1
92
92
test_rev_parse ' in repo.git/sub/dir' false true true sub/dir/
93
93
cd ../../../.. || exit 1
94
94
95
+ test_expect_success ' detecting gitdir when cwd is in a subdir of gitdir' '
96
+ (expected=$(pwd)/repo.git &&
97
+ cd repo.git/refs &&
98
+ unset GIT_DIR &&
99
+ test "$expected" = "$(git rev-parse --git-dir)")
100
+ '
101
+
95
102
test_expect_success ' repo finds its work tree' '
96
103
(cd repo.git &&
97
104
: > work/sub/dir/untracked &&
You can’t perform that action at this time.
0 commit comments