From: Junio C Hamano Date: Mon, 9 Apr 2018 23:25:45 +0000 (+0900) Subject: Merge branch 'tg/stash-untracked-with-pathspec-fix' X-Git-Tag: v2.18.0-rc0~161 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/cbf033943978fca4aed24fc107485eb74c63ddde?hp=-c Merge branch 'tg/stash-untracked-with-pathspec-fix' "git stash push -u -- " gave an unnecessary and confusing error message when there was no tracked files that match the , which has been fixed. * tg/stash-untracked-with-pathspec-fix: stash: drop superfluos pathspec parameter stash push -u: don't create empty stash stash push: avoid printing errors stash: fix nonsense pipeline --- cbf033943978fca4aed24fc107485eb74c63ddde diff --combined git-stash.sh index fc8f8ae640,d31924aea3..94793c1a91 --- a/git-stash.sh +++ b/git-stash.sh @@@ -39,7 -39,7 +39,7 @@@ f no_changes () { git diff-index --quiet --cached HEAD --ignore-submodules -- "$@" && git diff-files --quiet --ignore-submodules -- "$@" && - (test -z "$untracked" || test -z "$(untracked_files)") + (test -z "$untracked" || test -z "$(untracked_files "$@")") } untracked_files () { @@@ -76,12 -76,6 +76,12 @@@ create_stash () shift stash_msg=${1?"BUG: create_stash () -m requires an argument"} ;; + -m*) + stash_msg=${1#-m} + ;; + --message=*) + stash_msg=${1#--message=} + ;; -u|--include-untracked) shift untracked=${1?"BUG: create_stash () -u requires an argument"} @@@ -199,12 -193,6 +199,12 @@@ store_stash () shift stash_msg="$1" ;; + -m*) + stash_msg=${1#-m} + ;; + --message=*) + stash_msg=${1#--message=} + ;; -q|--quiet) quiet=t ;; @@@ -263,12 -251,6 +263,12 @@@ push_stash () test -z ${1+x} && usage stash_msg=$1 ;; + -m*) + stash_msg=${1#-m} + ;; + --message=*) + stash_msg=${1#--message=} + ;; --help) show_help ;; @@@ -278,7 -260,18 +278,7 @@@ ;; -*) option="$1" - # TRANSLATORS: $option is an invalid option, like - # `--blah-blah'. The 7 spaces at the beginning of the - # second line correspond to "error: ". So you should line - # up the second line with however many characters the - # translation of "error: " takes in your language. E.g. in - # English this is: - # - # $ git stash save --blah-blah 2>&1 | head -n 2 - # error: unknown option for 'stash save': --blah-blah - # To provide a message, use git stash save -- '--blah-blah' - eval_gettextln "error: unknown option for 'stash save': \$option - To provide a message, use git stash save -- '\$option'" + eval_gettextln "error: unknown option for 'stash push': \$option" usage ;; *) @@@ -315,16 -308,18 +315,18 @@@ if test -z "$patch_mode" then test "$untracked" = "all" && CLEAN_X_OPTION=-x || CLEAN_X_OPTION= - if test -n "$untracked" + if test -n "$untracked" && test $# = 0 then - git clean --force --quiet -d $CLEAN_X_OPTION -- "$@" + git clean --force --quiet -d $CLEAN_X_OPTION fi if test $# != 0 then - git add -u -- "$@" | - git checkout-index -z --force --stdin - git diff-index -p --cached --binary HEAD -- "$@" | git apply --index -R + test -z "$untracked" && UPDATE_OPTION="-u" || UPDATE_OPTION= + test "$untracked" = "all" && FORCE_OPTION="--force" || FORCE_OPTION= + git add $UPDATE_OPTION $FORCE_OPTION -- "$@" + git diff-index -p --cached --binary HEAD -- "$@" | + git apply --index -R else git reset --hard -q fi