308b046875f745abb87b3ef9f0382029fe37b452

Author
Gianluca Recchia <gianluca.recchia97@gmail.com>
Committer
Gianluca Recchia <gianluca.recchia97@gmail.com>
Date

Message

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 greater than 2.13; it falls back to 'git stash save' otherwise.

Diff

 1diff --git a/plugins/git/git.plugin.zsh b/plugins/git/git.plugin.zsh
 2index 2251bae2e71d6513333d2d4936ada8ad01b8403d..17e4d4b9def4f63a9089739cbd01f6a10e6fec0b 100644
 3--- a/plugins/git/git.plugin.zsh
 4+++ b/plugins/git/git.plugin.zsh
 5@@ -33,6 +33,11 @@ function work_in_progress() {
 6   fi
 7 }
 8 
 9+function _omz_git_stash_command() {
10+  [[ `git --version 2>/dev/null` =~ '^git version ([[:digit:]]+.[[:digit:]]+)' && "$match[1]" >= '2.13' ]] \
11+  && echo push || echo save
12+}
13+
14 #
15 # Aliases
16 # (sorted alphabetically)
17@@ -238,7 +243,7 @@ alias gsps='git show --pretty=short --show-signature'
18 alias gsr='git svn rebase'
19 alias gss='git status -s'
20 alias gst='git status'
21-alias gsta='git stash save'
22+alias gsta="git stash $(_omz_git_stash_command)"
23 alias gstaa='git stash apply'
24 alias gstc='git stash clear'
25 alias gstd='git stash drop'