+
Skip to content

stash: fix 'show -p' with unknown options #1973

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion builtin/stash.c
Original file line number Diff line number Diff line change
Expand Up @@ -917,6 +917,9 @@ static int show_stash(int argc, const char **argv, const char *prefix,
UNTRACKED_ONLY, PARSE_OPT_NONEG),
OPT_END()
};
struct setup_revision_opt s_r_opt = {
.free_removed_argv_elements = 1,
};
int do_usage = 0;

init_diff_ui_defaults();
Expand Down Expand Up @@ -955,7 +958,8 @@ static int show_stash(int argc, const char **argv, const char *prefix,
}
}

argc = setup_revisions(revision_args.nr, revision_args.v, &rev, NULL);
argc = setup_revisions(revision_args.nr, revision_args.v, &rev, &s_r_opt);
revision_args.nr = argc;
if (argc > 1)
goto usage;
if (!rev.diffopt.output_format) {
Expand Down
11 changes: 11 additions & 0 deletions t/t3903-stash.sh
Original file line number Diff line number Diff line change
Expand Up @@ -699,6 +699,17 @@ test_expect_success 'stash show - stashes on stack, stash-like argument' '
test_cmp expected actual
'

test_expect_success 'stash show -p - stashes on stack, unknown argument shows usage' '
git stash clear &&
test_when_finished "git reset --hard HEAD" &&
git reset --hard &&
echo foo >>file &&
git stash &&
test_when_finished "git stash drop" &&
test_expect_code 129 git stash show -p --unknown 2>usage &&
grep -F "usage: git stash show" usage
'

test_expect_success 'stash show -p - stashes on stack, stash-like argument' '
git stash clear &&
test_when_finished "git reset --hard HEAD" &&
Expand Down
Loading
点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载