• Matthieu Moy's avatar
    stash: simplify defaulting to "save" and reject unknown options · 3c2eb80f
    Matthieu Moy authored
    With the earlier DWIM patches, certain combination of options defaulted
    to the "save" command correctly while certain equally valid combination
    did not.  For example, "git stash -k" were Ok but "git stash -q -k" did
    not work.
    
    This makes the logic of defaulting to "save" much simpler. If there are no
    non-flag arguments, it is clear that there is no command word, and we
    default to "save" subcommand.  This rule prevents "git stash -q apply"
    from quietly creating a stash with "apply" as the message.
    
    This also teaches "git stash save" to reject an unknown option.  This is
    to keep a mistyped "git stash save --quite" from creating a stash with a
    message "--quite", and this safety is more important with the new logic
    to default to "save" with any option-looking argument without an explicit
    comand word.
    
    [jc: this is based on Matthieu's 3-patch series, and a follow-up
    discussion, and he and Peff take all the credit; if I have introduced bugs
    while reworking, they are mine.]
    Signed-off-by: default avatarMatthieu Moy <[email protected]>
    Signed-off-by: default avatarJunio C Hamano <[email protected]>
    3c2eb80f
git-stash.sh 8.42 KB