mirror of
https://github.com/git/git
synced 2024-10-30 04:01:21 +00:00
dfd557c978
When Git wants to spawn a child Git process inside a worktree's subdirectory while `GIT_DIR` is set, we need to take care of specifying the work tree's top-level directory explicitly because it cannot be discovered: the current directory is _not_ the top-level directory of the work tree, and neither is it inside the parent directory of `GIT_DIR`. This fixes the problem where `git stash apply` would report pretty much everything deleted or untracked when run inside a worktree's subdirectory. To make sure that we do not introduce the "reverse problem", i.e. when `GIT_WORK_TREE` is defined but `GIT_DIR` is not, we simply make sure that both are set. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
27 lines
452 B
Bash
Executable file
27 lines
452 B
Bash
Executable file
#!/bin/sh
|
|
#
|
|
# Copyright (c) 2019 Johannes E Schindelin
|
|
#
|
|
|
|
test_description='Test git stash in a worktree'
|
|
|
|
. ./test-lib.sh
|
|
|
|
test_expect_success 'setup' '
|
|
test_commit initial &&
|
|
git worktree add wt &&
|
|
test_commit -C wt in-worktree
|
|
'
|
|
|
|
test_expect_success 'apply in subdirectory' '
|
|
mkdir wt/subdir &&
|
|
(
|
|
cd wt/subdir &&
|
|
echo modified >../initial.t &&
|
|
git stash &&
|
|
git stash apply >out
|
|
) &&
|
|
grep "\.\.\/initial\.t" wt/subdir/out
|
|
'
|
|
|
|
test_done
|