@@ -1404,7 +1404,8 @@ static int create_stash(int argc, const char **argv, const char *prefix)
return ret;
}
-static int do_push_stash(const struct pathspec *ps, const char *stash_msg, int quiet,
+static int do_push_stash(const struct pathspec *ps, const char *stash_msg,
+ const char *prefix, int quiet,
int keep_index, int patch_mode, int include_untracked)
{
int ret = 0;
@@ -1485,8 +1486,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 (prefix)
+ strvec_pushl(&cp.args, "-C", prefix, NULL);
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)) {
@@ -1656,8 +1659,8 @@ static int push_stash(int argc, const char **argv, const char *prefix,
die(_("--pathspec-file-nul requires --pathspec-from-file"));
}
- return do_push_stash(&ps, stash_msg, quiet, keep_index, patch_mode,
- include_untracked);
+ return do_push_stash(&ps, stash_msg, prefix, quiet, keep_index,
+ patch_mode, include_untracked);
}
static int save_stash(int argc, const char **argv, const char *prefix)
@@ -1693,7 +1696,7 @@ static int save_stash(int argc, const char **argv, const char *prefix)
stash_msg = strbuf_join_argv(&stash_msg_buf, argc, argv, ' ');
memset(&ps, 0, sizeof(ps));
- ret = do_push_stash(&ps, stash_msg, quiet, keep_index,
+ ret = do_push_stash(&ps, stash_msg, prefix, quiet, keep_index,
patch_mode, include_untracked);
strbuf_release(&stash_msg_buf);
@@ -236,7 +236,7 @@ test_expect_success 'clean does not remove cwd incidentally' '
test_path_is_dir untracked
'
-test_expect_failure 'stash does not remove cwd incidentally' '
+test_expect_success 'stash does not remove cwd incidentally' '
git checkout foo/bar/baz &&
test_when_finished "git clean -fdx" &&