Re: [PATCH v5 6/6] stash: allow pathspecs in the no verb form
On 02/17, Jeff King wrote: > On Fri, Feb 17, 2017 at 10:41:41PM +, Thomas Gummerer wrote: > > > Now that stash_push is used in the no verb form of stash, allow > > specifying the command line for this form as well. Always use -- to > > disambiguate pathspecs from other non-option arguments. > > I think that makes sense. > > > Also make git stash -p an alias for git stash push -p. This allows > > users to use git stash -p . > > And I think of all the options we discussed for handling "-p", I think > this one makes the most sense. > > It may be worth calling out in the documentation that this is how it > works though, so people do not think that: > > git stash -k -p > > would work ("git stash -k -p" _does_ happen to work due to the old > options-only rule, but I think we should advertise the general form as > "-p is an alias for "push -p"). Yeah, I think adding something about this in the documentation would be good. I'll add a paragraph about this in the re-roll. > -Peff
Re: [PATCH v5 6/6] stash: allow pathspecs in the no verb form
On Fri, Feb 17, 2017 at 10:41:41PM +, Thomas Gummerer wrote: > Now that stash_push is used in the no verb form of stash, allow > specifying the command line for this form as well. Always use -- to > disambiguate pathspecs from other non-option arguments. I think that makes sense. > Also make git stash -p an alias for git stash push -p. This allows > users to use git stash -p . And I think of all the options we discussed for handling "-p", I think this one makes the most sense. It may be worth calling out in the documentation that this is how it works though, so people do not think that: git stash -k -p would work ("git stash -k -p" _does_ happen to work due to the old options-only rule, but I think we should advertise the general form as "-p is an alias for "push -p"). -Peff
[PATCH v5 6/6] stash: allow pathspecs in the no verb form
Now that stash_push is used in the no verb form of stash, allow specifying the command line for this form as well. Always use -- to disambiguate pathspecs from other non-option arguments. Also make git stash -p an alias for git stash push -p. This allows users to use git stash -p . Signed-off-by: Thomas Gummerer --- git-stash.sh | 3 +++ t/t3903-stash.sh | 15 +++ 2 files changed, 18 insertions(+) diff --git a/git-stash.sh b/git-stash.sh index 2a33614cb7..1446fbe2e8 100755 --- a/git-stash.sh +++ b/git-stash.sh @@ -667,12 +667,15 @@ apply_to_branch () { } } +test "$1" = "-p" && set "push" "$@" + PARSE_CACHE='--not-parsed' # The default command is "push" if nothing but options are given seen_non_option= for opt do case "$opt" in + --) break ;; -*) ;; *) seen_non_option=t; break ;; esac diff --git a/t/t3903-stash.sh b/t/t3903-stash.sh index 7f90a247b4..c0ae41e724 100755 --- a/t/t3903-stash.sh +++ b/t/t3903-stash.sh @@ -872,4 +872,19 @@ test_expect_success 'untracked files are left in place when -u is not given' ' test_path_is_file untracked ' +test_expect_success 'stash without verb with pathspec' ' + >"foo bar" && + >foo && + >bar && + git add foo* && + git stash -- "foo b*" && + test_path_is_missing "foo bar" && + test_path_is_file foo && + test_path_is_file bar && + git stash pop && + test_path_is_file "foo bar" && + test_path_is_file foo && + test_path_is_file bar +' + test_done -- 2.11.0.301.g27b9849079.dirty