'What is meant by including "-p" as a "non-option argument" in the git stash push documentation?

The git stash push documentation states:

For quickly making a snapshot, you can omit "push". In this mode, non-option arguments are not allowed to prevent a misspelled subcommand from making an unwanted stash entry. The two exceptions to this are stash -p which acts as alias for stash push -p and pathspec elements, which are allowed after a double hyphen -- for disambiguation.

However, I'm confused by the stash -p example being listed as an exception to the non-option arguments. Isn't -p an option argument?

For instance, the following also appears to be a valid use of omitting "push", and it creates a stash with the given message:

git stash -m "some commit message"

Am I misunderstanding something here? Is this an issue with the documentation?

What is meant by including stash -p as an exception to disallowing the non-option arguments, when it appears to be an option argument.?



Solution 1:[1]

A nonoption argument is, say, a filename.

Suppose you have an edited file called clea. Then it is forbidden to say

git stash clea

because, as the documentation says, we can't tell if clea is a misspelling for some subcommand such as clear. It would have been legal to say

git stash push clea

but Git is not about to assume you mean that.

But if you say

git stash -p -- clea

that's fine; you have disambiguated sufficiently, so it is just as if you had said

git stash push -p clea

and the success of the command depends merely on whether you do in fact have a file called clea.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 matt