git_track_branch(): support de git >= 1.8.x

This commit is contained in:
Jephté Clain 2016-04-14 14:39:05 +04:00
parent 130b4d1618
commit 2f60fece01
1 changed files with 8 additions and 1 deletions

View File

@ -676,7 +676,14 @@ function git_track_branch() {
if ! git_have_rbranch "$branch" "$origin"; then
git push "$origin" "$branch" || return
fi
git branch -t --set-upstream "$branch" "$origin/$branch"
local version="$(LANG=C git version)"
version="${version#git version }"
eval "version=(${version//./ })"
if [ ${version[0]} -le 1 -a ${version[1]} -le 7 ]; then
git branch -t --set-upstream "$branch" "$origin/$branch"
else
git branch -u "$origin/$branch" "$branch"
fi
}
function git_ensure_branch() {
# retourner 0 si la branche a été créée, 1 si elle existait déjà, 2 en cas d'erreur