Now that we have stash_push, which accepts pathspec arguments, use it instead of stash_save in git stash without any additional verbs. This does introduce a small regression. Previously we allowed git stash -- -message, with a hyphen in front of the message. However git stash -- message without the hyphen was not allowed. After this change adding a message to the stash, with or without hyphen is no longer allowed. While this now allows specifying a message with the -m flag, it also disallows messages without a hyphen. This is to prevent user errors, where a user tries to stash something with a message, but changes their mind, and now would like to apply a stash, but forgets to remove the -m flag. E.g. git stash -m mes^H^H^Happly would result in a stash with the message apply, while the user might have intended to apply a previous stash. Signed-off-by: Thomas Gummerer <t.gummerer@xxxxxxxxx> --- If this kind of regression introduced here is not acceptable, I think we could hide this change between some kind of config option, and transition users over later after a warning period. Documentation/git-stash.txt | 8 ++++---- git-stash.sh | 16 ++++++++-------- t/t3903-stash.sh | 4 +--- 3 files changed, 13 insertions(+), 15 deletions(-) diff --git a/Documentation/git-stash.txt b/Documentation/git-stash.txt index f462f393b0..b0825f4aca 100644 --- a/Documentation/git-stash.txt +++ b/Documentation/git-stash.txt @@ -13,11 +13,11 @@ SYNOPSIS 'git stash' drop [-q|--quiet] [<stash>] 'git stash' ( pop | apply ) [--index] [-q|--quiet] [<stash>] 'git stash' branch <branchname> [<stash>] -'git stash' [save [-p|--patch] [-k|--[no-]keep-index] [-q|--quiet] - [-u|--include-untracked] [-a|--all] [<message>]] -'git stash' push [-p|--patch] [-k|--[no-]keep-index] [-q|--quiet] +'git stash' save [-p|--patch] [-k|--[no-]keep-index] [-q|--quiet] + [-u|--include-untracked] [-a|--all] [<message>] +'git stash' [push [-p|--patch] [-k|--[no-]keep-index] [-q|--quiet] [-u|--include-untracked] [-a|--all] [-m|--message <message>]] - [--] [<pathspec>...] + [--] [<pathspec>...]] 'git stash' clear 'git stash' create [<message>] 'git stash' create [-m <message>] [-u|--include-untracked <untracked|all>] diff --git a/git-stash.sh b/git-stash.sh index db56cf2c66..769cee9fd8 100755 --- a/git-stash.sh +++ b/git-stash.sh @@ -7,11 +7,11 @@ USAGE="list [<options>] or: $dashless drop [-q|--quiet] [<stash>] or: $dashless ( pop | apply ) [--index] [-q|--quiet] [<stash>] or: $dashless branch <branchname> [<stash>] - or: $dashless [save [--patch] [-k|--[no-]keep-index] [-q|--quiet] - [-u|--include-untracked] [-a|--all] [<message>]] - or: $dashless push [--patch] [-k|--[no-]keep-index] [-q|--quiet] - [-u|--include-untracked] [-a|--all] [-m <message>] - [-- <pathspec>...] + or: $dashless save [--patch] [-k|--[no-]keep-index] [-q|--quiet] + [-u|--include-untracked] [-a|--all] [<message>] + or: $dashless [push [--patch] [-k|--[no-]keep-index] [-q|--quiet] + [-u|--include-untracked] [-a|--all] [-m <message>] + [-- <pathspec>...]] or: $dashless clear" SUBDIRECTORY_OK=Yes @@ -699,7 +699,7 @@ apply_to_branch () { } PARSE_CACHE='--not-parsed' -# The default command is "save" if nothing but options are given +# The default command is "push" if nothing but options are given seen_non_option= for opt do @@ -709,7 +709,7 @@ do esac done -test -n "$seen_non_option" || set "save" "$@" +test -n "$seen_non_option" || set "push" "$@" # Main command set case "$1" in @@ -760,7 +760,7 @@ branch) *) case $# in 0) - save_stash && + push_stash && say "$(gettext "(To restore them type \"git stash apply\")")" ;; *) diff --git a/t/t3903-stash.sh b/t/t3903-stash.sh index 8b372c35fb..d568799da9 100755 --- a/t/t3903-stash.sh +++ b/t/t3903-stash.sh @@ -274,9 +274,7 @@ test_expect_success 'stash --invalid-option' ' git add file2 && test_must_fail git stash --invalid-option && test_must_fail git stash save --invalid-option && - test bar5,bar6 = $(cat file),$(cat file2) && - git stash -- -message-starting-with-dash && - test bar,bar2 = $(cat file),$(cat file2) + test bar5,bar6 = $(cat file),$(cat file2) ' test_expect_success 'stash an added file' ' -- 2.11.0.301.g86e6ecc671.dirty