1
0
Fork 0
mirror of https://github.com/git/git.git synced 2024-05-20 19:16:10 +02:00

stash: do not attempt to remove startup_info->original_cwd

Since stash spawns a `clean` subprocess, make sure we run that from the
startup_info->original_cwd directory, so that the `clean` processs knows
to protect that directory.  Also, since the `clean` command might no
longer run from the toplevel, pass the ':/' magic pathspec to ensure we
still clean from the toplevel.

Acked-by: Derrick Stolee <stolee@gmail.com>
Acked-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Elijah Newren 2021-12-09 05:08:32 +00:00 committed by Junio C Hamano
parent bc3ae46b42
commit 0fce211ccc
2 changed files with 4 additions and 2 deletions

View File

@ -1485,8 +1485,10 @@ static int do_push_stash(const struct pathspec *ps, const char *stash_msg, int q
struct child_process cp = CHILD_PROCESS_INIT;
cp.git_cmd = 1;
if (startup_info->original_cwd)
cp.dir = startup_info->original_cwd;
strvec_pushl(&cp.args, "clean", "--force",
"--quiet", "-d", NULL);
"--quiet", "-d", ":/", NULL);
if (include_untracked == INCLUDE_ALL_FILES)
strvec_push(&cp.args, "-x");
if (run_command(&cp)) {

View File

@ -236,7 +236,7 @@ test_expect_success 'clean does not remove cwd incidentally' '
'
test_expect_success 'stash does not remove cwd incidentally' '
test_incidental_untracked_dir_removal failure \
test_incidental_untracked_dir_removal success \
git stash --include-untracked
'