mirror of
https://github.com/git/git.git
synced 2024-12-11 10:54:21 +08:00
Merge branch 'js/stash-apply-in-secondary-worktree'
"git stash apply" in a subdirectory of a secondary worktree failed to access the worktree correctly, which has been corrected. * js/stash-apply-in-secondary-worktree: stash apply: report status correctly even in a worktree's subdirectory
This commit is contained in:
commit
66102cfad8
@ -497,6 +497,10 @@ static int do_apply_stash(const char *prefix, struct stash_info *info,
|
||||
*/
|
||||
cp.git_cmd = 1;
|
||||
cp.dir = prefix;
|
||||
argv_array_pushf(&cp.env_array, GIT_WORK_TREE_ENVIRONMENT"=%s",
|
||||
absolute_path(get_git_work_tree()));
|
||||
argv_array_pushf(&cp.env_array, GIT_DIR_ENVIRONMENT"=%s",
|
||||
absolute_path(get_git_dir()));
|
||||
argv_array_push(&cp.args, "status");
|
||||
run_command(&cp);
|
||||
}
|
||||
|
27
t/t3908-stash-in-worktree.sh
Executable file
27
t/t3908-stash-in-worktree.sh
Executable file
@ -0,0 +1,27 @@
|
||||
#!/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
|
Loading…
Reference in New Issue
Block a user