]> git.ipfire.org Git - thirdparty/git.git/commit
stash apply: report status correctly even in a worktree's subdirectory
authorJohannes Schindelin <johannes.schindelin@gmx.de>
Fri, 4 Oct 2019 12:30:59 +0000 (05:30 -0700)
committerJunio C Hamano <gitster@pobox.com>
Sun, 6 Oct 2019 00:04:56 +0000 (09:04 +0900)
commitdfd557c9783433bd6273987982f0665d99e52df2
tree3f667e1537920860737c4480be9282c10d7327d2
parent5fa0f5238b0cd46cfe7f6fa76c3f526ea98148d9
stash apply: report status correctly even in a worktree's subdirectory

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>
builtin/stash.c
t/t3908-stash-in-worktree.sh [new file with mode: 0755]