summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--setup.c2
-rwxr-xr-xt/t4111-apply-subdir.sh2
2 files changed, 3 insertions, 1 deletions
diff --git a/setup.c b/setup.c
index 5fb9c54ba6..5734a1f1c1 100644
--- a/setup.c
+++ b/setup.c
@@ -369,6 +369,8 @@ static const char *setup_bare_git_dir(const char *work_tree_env,
if (!work_tree_env)
inside_work_tree = 0;
if (offset != len) {
+ if (chdir(cwd))
+ die_errno("Cannot come back to cwd");
root_len = offset_1st_component(cwd);
cwd[offset > root_len ? offset : root_len] = '\0';
set_git_dir(cwd);
diff --git a/t/t4111-apply-subdir.sh b/t/t4111-apply-subdir.sh
index d6271ae34b..a52d94ae21 100755
--- a/t/t4111-apply-subdir.sh
+++ b/t/t4111-apply-subdir.sh
@@ -97,7 +97,7 @@ test_expect_success 'apply from .git dir' '
test_cmp expected .git/file
'
-test_expect_failure 'apply from subdir of .git dir' '
+test_expect_success 'apply from subdir of .git dir' '
cp postimage expected &&
cp preimage .git/file &&
cp preimage .git/objects/file