35dc26a2c091e90de1274bd4b9993e403d1c6642

Author
Marc Cornellà <marc.cornella@live.com>
Committer
GitHub <noreply@github.com>
Date

Message

git: use stash 'push' instead of the deprecated 'save' (#7486)

* Use stash 'push' or 'save' depending on Git version

A utility function now parses the output of git --version and set the
alias for git stash to 'git stash push' iff the current version of Git
is 2.13 or greater; it falls back to 'git stash save' otherwise.

Diff

 1diff --git a/plugins/git/git.plugin.zsh b/plugins/git/git.plugin.zsh
 2index a4b6eb9777e4d150e76cc67079ead4bc6403013c..344419f1eccb838167df89bddb9893da5034f1db 100644
 3--- a/plugins/git/git.plugin.zsh
 4+++ b/plugins/git/git.plugin.zsh
 5@@ -239,7 +239,12 @@ alias gsps='git show --pretty=short --show-signature'
 6 alias gsr='git svn rebase'
 7 alias gss='git status -s'
 8 alias gst='git status'
 9-alias gsta='git stash save'
10+
11+# use the default stash push on git 2.13 and newer
12+[[ "$(git --version 2>/dev/null)" =~ '^git version ([0-9]+.[0-9]+)' && "$match" -ge '2.13' ]] \
13+  && alias gsta='git stash push'
14+  || alias gsta='git stash save'
15+
16 alias gstaa='git stash apply'
17 alias gstc='git stash clear'
18 alias gstd='git stash drop'