aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--builtin/stash.c10
-rwxr-xr-xt/t3903-stash.sh4
2 files changed, 9 insertions, 5 deletions
diff --git a/builtin/stash.c b/builtin/stash.c
index bc2c34fa04..b12fd6c40f 100644
--- a/builtin/stash.c
+++ b/builtin/stash.c
@@ -1789,11 +1789,15 @@ static int push_stash(int argc, const char **argv, const char *prefix,
int ret;
if (argc) {
- force_assume = argc > 1 && !strcmp(argv[1], "-p");
+ int flags = PARSE_OPT_KEEP_DASHDASH;
+
+ if (push_assumed)
+ flags |= PARSE_OPT_STOP_AT_NON_OPTION;
+
argc = parse_options(argc, argv, prefix, options,
push_assumed ? git_stash_usage :
- git_stash_push_usage,
- PARSE_OPT_KEEP_DASHDASH);
+ git_stash_push_usage, flags);
+ force_assume |= patch_mode;
}
if (argc) {
diff --git a/t/t3903-stash.sh b/t/t3903-stash.sh
index a99a746221..2bba3baa10 100755
--- a/t/t3903-stash.sh
+++ b/t/t3903-stash.sh
@@ -1177,13 +1177,13 @@ test_expect_success 'stash -- <pathspec> stashes and restores the file' '
test_path_is_file bar
'
-test_expect_success 'stash -p <pathspec> stash and restores the file' '
+test_expect_success 'stash --patch <pathspec> stash and restores the file' '
test_write_lines b c >file &&
git commit -m "add a few lines" file &&
test_write_lines a b c d >file &&
test_write_lines b c d >expect-file &&
echo changed-other-file >other-file &&
- test_write_lines s y n | git stash -p file &&
+ test_write_lines s y n | git stash -m "stash bar" --patch file &&
test_cmp expect-file file &&
echo changed-other-file >expect &&
test_cmp expect other-file &&