ulib/vcs: corriger le code de git_track_branch. Utiliser ce code dans pdev --sync

This commit is contained in:
Jephté Clain 2016-05-25 19:43:17 +04:00
parent fc75fcd960
commit 01b9a6804f
2 changed files with 21 additions and 18 deletions

View File

@ -673,16 +673,21 @@ function git_track_branch() {
[ -n "$branch" ] || return
git_have_remote "$origin" || return
[ "$(git config --get branch.$branch.remote)" == "$origin" ] && return
if ! git_have_rbranch "$branch" "$origin"; then
git push "$origin" "$branch" || return
fi
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"
if git_have_rbranch "$branch" "$origin"; then
if git_have_branch "$branch"; then
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
else
git branch -t "$branch" "$origin/$branch"
fi
elif git_have_branch "$branch"; then
git push -u "$origin" "$branch" || return
fi
}
function git_ensure_branch() {

14
pdev
View File

@ -135,14 +135,13 @@ git_ensure_gitvcs
if [ "$action" == sync ]; then
[ -z "$UTOOLS_VCS_OFFLINE" ] || die "L'option --sync nécessite le mode --online"
version="$(LANG=C git version)"
version="${version#git version }"
eval "version=(${version//./ })"
setx -a branches=list_feature_branches "$origin"
for branch in "${branches[@]}"; do
if git_have_branch "$branch"; then
git_track_branch "$branch" "$origin"
else
git branch -t "$branch" "$origin/$branch"
fi
git_track_branch "$branch" "$origin"
done
exit $?
@ -177,9 +176,7 @@ if [ "$action" == branch ]; then
# On est peut-être déjà sur la bonne branche
if git_is_branch "$feature"; then
if [ -z "$UTOOLS_VCS_OFFLINE" ]; then
git_track_branch "$feature" "$origin"
fi
[ -z "$UTOOLS_VCS_OFFLINE" ] && git_track_branch "$feature" "$origin"
git_fast_forward "$feature" "" "$origin"
exit 0
fi
@ -202,6 +199,7 @@ Vous allez créer la nouvelle feature branch ${COULEUR_VERTE}$feature${COULEUR_N
[ $? -eq 2 ] && die "Impossible de créer la branche $feature. Veuillez vérifier que la branche $source existe"
git checkout "$feature" || r=$?
fi
[ -z "$UTOOLS_VCS_OFFLINE" ] && git_track_branch "$feature" "$origin"
if [ "$r" -eq 0 ]; then
# éventuellement fast-forwarder automatiquement
git_fast_forward "$feature" "" "$origin"