All of lore.kernel.org
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: "Ævar Arnfjörð Bjarmason" <avarab@gmail.com>
Cc: git@vger.kernel.org, Jeff King <peff@peff.net>,
	Carlo Arenas <carenas@gmail.com>,
	Paul-Sebastian Ungureanu <ungureanupaulsebastian@gmail.com>,
	Alexandr Miloslavskiy <alexandr.miloslavskiy@syntevo.com>
Subject: Re: [PATCH v3] stash: don't show "git stash push" usage on bad "git stash" usage
Date: Thu, 16 Dec 2021 14:03:10 -0800	[thread overview]
Message-ID: <xmqqczlw8axt.fsf@gitster.g> (raw)
In-Reply-To: <patch-v3-1.1-6b33b104c84-20211216T125317Z-avarab@gmail.com> (=?utf-8?B?IsOGdmFyIEFybmZqw7Zyw7A=?= Bjarmason"'s message of "Thu, 16 Dec 2021 13:54:21 +0100")

Ævar Arnfjörð Bjarmason  <avarab@gmail.com> writes:

> diff --git a/builtin/stash.c b/builtin/stash.c
> index 18c812bbe03..5462840a073 100644
> --- a/builtin/stash.c
> +++ b/builtin/stash.c
> @@ -1681,6 +1681,7 @@ static int push_stash(int argc, const char **argv, const char *prefix,
>  	if (argc) {
>  		force_assume = !strcmp(argv[0], "-p");
>  		argc = parse_options(argc, argv, prefix, options,
> +				     push_assumed ? git_stash_usage :
>  				     git_stash_push_usage,
>  				     PARSE_OPT_KEEP_DASHDASH);
>  	}

Yeah, "git stash" having the implicit default to "push" may have
been convenient for its original intended use case (i.e. clear the
working area with as little typing and effort as possible), but
without a care like this one, it would result in surprises.

Looks good, will queue.


> diff --git a/t/t3903-stash.sh b/t/t3903-stash.sh
> index 2c66cfbc3b7..b17c52d8807 100755
> --- a/t/t3903-stash.sh
> +++ b/t/t3903-stash.sh
> @@ -10,6 +10,25 @@ export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
>  
>  . ./test-lib.sh
>  
> +test_expect_success 'usage on cmd and subcommand invalid option' '
> +	test_expect_code 129 git stash --invalid-option 2>usage &&
> +	grep "or: git stash" usage &&
> +
> +	test_expect_code 129 git stash push --invalid-option 2>usage &&
> +	! grep "or: git stash" usage
> +'
> +
> +test_expect_success 'usage on main command -h emits a summary of subcommands' '
> +	test_expect_code 129 git stash -h >usage &&
> +	grep -F "usage: git stash list" usage &&
> +	grep -F "or: git stash show" usage
> +'
> +
> +test_expect_failure 'usage for subcommands should emit subcommand usage' '
> +	test_expect_code 129 git stash push -h >usage &&
> +	grep -F "usage: git stash [push" usage
> +'
> +
>  diff_cmp () {
>  	for i in "$1" "$2"
>  	do

  reply	other threads:[~2021-12-16 22:03 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-01 11:19 [PATCH] stash: print the correct usage on "git stash [push] --invalid-option" Ævar Arnfjörð Bjarmason
2021-09-21 13:46 ` [PATCH v2] " Ævar Arnfjörð Bjarmason
2021-12-16 12:54   ` [PATCH v3] stash: don't show "git stash push" usage on bad "git stash" usage Ævar Arnfjörð Bjarmason
2021-12-16 22:03     ` Junio C Hamano [this message]
2021-12-16 22:05     ` Junio C Hamano

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=xmqqczlw8axt.fsf@gitster.g \
    --to=gitster@pobox.com \
    --cc=alexandr.miloslavskiy@syntevo.com \
    --cc=avarab@gmail.com \
    --cc=carenas@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=peff@peff.net \
    --cc=ungureanupaulsebastian@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.