Git development
 help / color / mirror / Atom feed
From: Phillip Wood <phillip.wood123@gmail.com>
To: Mirko Faina <mroik@delayed.space>,
	Deveshi Dwivedi <deveshigurgaon@gmail.com>
Cc: git@vger.kernel.org, ben.knoble@gmail.com,
	quentin.bernet@bluewin.ch, gitster@pobox.com
Subject: Re: [PATCH v3] stash: infer "push" when push-specific options are given
Date: Tue, 7 Apr 2026 10:36:13 +0100	[thread overview]
Message-ID: <a280c7de-1357-44a9-afdd-bd473fd4e2a4@gmail.com> (raw)
In-Reply-To: <adP3JZhS7IHDuUxm@exploit>

On 06/04/2026 19:15, Mirko Faina wrote:
> On Sun, Apr 05, 2026 at 11:09:53AM +0000, Deveshi Dwivedi wrote:
>> When "git stash" is run without the "push" subcommand, the command
>> tries to assume "push" but rejects any non-option arguments (i.e.,
>> pathspecs without "--") to avoid treating a misspelled subcommand
>> name as a pathspec.  The only exception is "-p", which sets
>> force_assume and allows pathspecs to follow.
>>
>> This means "git stash -m foo file" is rejected even though "-m" is
>> unambiguously a "push" option, and the user's intent is clear.  The
>> same applies to other push-specific options like "--staged",
>> "--keep-index", "--include-untracked", and "--pathspec-from-file".
>>
>> Expand the set of options that force the "push" assumption to
>> include all push-specific options, so that pathspec arguments are
>> accepted without requiring "--" or the explicit "push" subcommand
>> when the command line already contains a push-only option.
>>
>> This was marked as #leftoverbits in [1].
>>
>> [1] https://lore.kernel.org/git/xmqqtsu1jipp.fsf@gitster.g/
>>
>> Signed-off-by: Deveshi Dwivedi <deveshigurgaon@gmail.com>
> 
> Just realized, "--include-untracked" is not specific only to 'push' as
> 'show' accepts it too as an argument.

"create" accepts "-m" as well so that's not unique either. I agree with 
Junio's suggestion in the link above that we should assume "push" when 
there is no subcommand given and error out if we see an unsupported 
option. That does not require the arguments to be unique to "push". A 
complete implementation would also support negated options like "git 
stash --no-stage [<pathspec>]". What is implemented in this patch maybe 
sufficient in practice but it would be good to mention the limitations 
in the commit message.

Thanks

Phillip

> "--keep-index" as well, but since
> 'save' is deprecated I don't think anyone would mind and should be fine
> to leave it as is (though this is my opinion, should wait for others to
> see what they think).
> 


  reply	other threads:[~2026-04-07  9:36 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-04-04 14:36 [PATCH] stash: infer "push" when push-specific options are given Deveshi Dwivedi
2026-04-04 15:19 ` Mirko Faina
2026-04-04 16:03 ` [PATCH v2] " Deveshi Dwivedi
2026-04-04 23:40   ` Mirko Faina
2026-04-05  7:02     ` Deveshi Dwivedi
2026-04-05 11:09 ` [PATCH v3] " Deveshi Dwivedi
2026-04-06 18:15   ` Mirko Faina
2026-04-07  9:36     ` Phillip Wood [this message]
2026-04-09 19:22       ` Deveshi Dwivedi
2026-04-09 19:37         ` Mirko Faina
2026-04-09 20:31       ` Junio C Hamano
2026-04-09 20:22   ` Junio C Hamano
2026-04-12 19:52 ` [PATCH v4] stash: infer "push" when command line starts with an option Deveshi Dwivedi
2026-04-13  9:08   ` Phillip Wood
2026-04-13 15:09   ` Junio C Hamano
2026-04-19 16:54 ` [PATCH v5] stash: assume " Deveshi Dwivedi
2026-04-21 15:28   ` Phillip Wood

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=a280c7de-1357-44a9-afdd-bd473fd4e2a4@gmail.com \
    --to=phillip.wood123@gmail.com \
    --cc=ben.knoble@gmail.com \
    --cc=deveshigurgaon@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=mroik@delayed.space \
    --cc=phillip.wood@dunelm.org.uk \
    --cc=quentin.bernet@bluewin.ch \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox