From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS53758 23.128.96.0/24 X-Spam-Status: No, score=-3.9 required=3.0 tests=AWL,BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_PASS,SPF_PASS shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by dcvr.yhbt.net (Postfix) with ESMTP id E4D501F953 for ; Thu, 16 Dec 2021 22:03:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237396AbhLPWDQ (ORCPT ); Thu, 16 Dec 2021 17:03:16 -0500 Received: from pb-smtp20.pobox.com ([173.228.157.52]:52327 "EHLO pb-smtp20.pobox.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234459AbhLPWDP (ORCPT ); Thu, 16 Dec 2021 17:03:15 -0500 Received: from pb-smtp20.pobox.com (unknown [127.0.0.1]) by pb-smtp20.pobox.com (Postfix) with ESMTP id 47BD816209D; Thu, 16 Dec 2021 17:03:15 -0500 (EST) (envelope-from junio@pobox.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed; d=pobox.com; h=from:to:cc :subject:references:date:in-reply-to:message-id:mime-version :content-type:content-transfer-encoding; s=sasl; bh=ZWN//yDbCG/k WXfKzE3LumGrrAVuBfqLiuctcWayHeI=; b=HtpwL95RrFhe3LVPPBiDjXpF2I52 B2QxqxUcPAp+yC2iDz/Ks8Lb7W7l61LculN5gZ/PCmepjGFXCBGYj+EYw6VRAZNp zR443Wx+QQjE6qrz1M1R1ugUR3S4GZCd0EvNjEhc71fM3TKhO50rG8j2zIQbCwzw vkAazcU4lwQCQus= Received: from pb-smtp20.sea.icgroup.com (unknown [127.0.0.1]) by pb-smtp20.pobox.com (Postfix) with ESMTP id 4177716209C; Thu, 16 Dec 2021 17:03:15 -0500 (EST) (envelope-from junio@pobox.com) Received: from pobox.com (unknown [104.133.2.91]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by pb-smtp20.pobox.com (Postfix) with ESMTPSA id B3D2A16209B; Thu, 16 Dec 2021 17:03:11 -0500 (EST) (envelope-from junio@pobox.com) From: Junio C Hamano To: =?utf-8?B?w4Z2YXIgQXJuZmrDtnLDsA==?= Bjarmason Cc: git@vger.kernel.org, Jeff King , Carlo Arenas , Paul-Sebastian Ungureanu , Alexandr Miloslavskiy Subject: Re: [PATCH v3] stash: don't show "git stash push" usage on bad "git stash" usage References: Date: Thu, 16 Dec 2021 14:03:10 -0800 In-Reply-To: (=?utf-8?B?IsOGdmFyIEFybmZqw7Zyw7A=?= Bjarmason"'s message of "Thu, 16 Dec 2021 13:54:21 +0100") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 X-Pobox-Relay-ID: F5CF3A48-5EBB-11EC-8B45-C85A9F429DF0-77302942!pb-smtp20.pobox.com Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org =C3=86var Arnfj=C3=B6r=C3=B0 Bjarmason 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 =3D !strcmp(argv[0], "-p"); > argc =3D 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 > =20 > . ./test-lib.sh > =20 > +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 subco= mmands' ' > + 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 usag= e' ' > + test_expect_code 129 git stash push -h >usage && > + grep -F "usage: git stash [push" usage > +' > + > diff_cmp () { > for i in "$1" "$2" > do