diff options
author | Marc Cornellà <marc.cornella@live.com> | 2019-04-09 18:33:15 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-04-09 18:33:15 +0200 |
commit | 35dc26a2c091e90de1274bd4b9993e403d1c6642 (patch) | |
tree | b6cdad26df0423d6fb2adfcf07bef3ec04af103e | |
parent | 4aa545abedb430df2fa1ae2cc7cc502a5be1a80b (diff) | |
parent | 1bd72f588cb2e4950ea513aa4315ce77c792e43b (diff) | |
download | zsh-35dc26a2c091e90de1274bd4b9993e403d1c6642.tar.gz zsh-35dc26a2c091e90de1274bd4b9993e403d1c6642.tar.bz2 zsh-35dc26a2c091e90de1274bd4b9993e403d1c6642.zip |
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.
-rw-r--r-- | plugins/git/git.plugin.zsh | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/plugins/git/git.plugin.zsh b/plugins/git/git.plugin.zsh index a4b6eb977..344419f1e 100644 --- a/plugins/git/git.plugin.zsh +++ b/plugins/git/git.plugin.zsh @@ -239,7 +239,12 @@ alias gsps='git show --pretty=short --show-signature' alias gsr='git svn rebase' alias gss='git status -s' alias gst='git status' -alias gsta='git stash save' + +# use the default stash push on git 2.13 and newer +[[ "$(git --version 2>/dev/null)" =~ '^git version ([0-9]+.[0-9]+)' && "$match" -ge '2.13' ]] \ + && alias gsta='git stash push' + || alias gsta='git stash save' + alias gstaa='git stash apply' alias gstc='git stash clear' alias gstd='git stash drop' |