From: Junio C Hamano Date: Mon, 13 Apr 2026 15:09:16 GMT Subject: Re: [PATCH v4] stash: infer "push" when command line starts with an option Message-ID: In-Reply-To: <20260412195204.4636-1-deveshigurgaon@gmail.com> Deveshi Dwivedi writes: > 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. I think "run without the 'push' subcommand" above should be "run without any subcommand (on the command line)". "git stash pop -- paths" is run without the "push" subcommand, and obviously we do not want it to assume "push". > A command line that begins with an option cannot be naming a "git > stash" subcommand, so unconditionally assume "push" in that case and > allow pathspec arguments to follow without requiring "--". This is > simpler and more robust than checking a specific list of options, > and remains correct even if push or other subcommands gain new > options in the future. Good. > Note that this does not check for negated options, so "git stash > --no-staged []" is still rejected. Handling negated > options would require teaching the inference logic about them > explicitly. That is unexpected, and unfortunate. I would have expected, since we are now sending any thing that is not unrecognised to "push", it would largely be the matter of removing special casing code about push_assumed from push_stash() and adding some to its caller, which is cmd_stash(). It would first look at its table of subcommands and if it finds a hit, calls the handler. If not, and if there is no argument or if the first argument begins with a dash "if (argv[1] && argv[1][0] == '-')", then unshift "push" into the argv[] array, and call push_stash(), which would complain if the command line (with "push" prepended) does not make sense to it. If the above two conditions were not met, cmd_stash() would not call push_stash() but complain that it did not get a valid command. Or something like that. That way, there is nothing that makes "--no-something" any more special than "--something", no?