X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=scripts%2Fgit-update.sh;h=dc0465339bb252e87c86250631cdfd828da237b1;hb=66c2736f0ba1a34dfb713070f39bc15bc85c67e0;hp=bd555e377a345676d4683c18f58e02a94dba624e;hpb=8481e3c8b6f6776f08bece291044e478a530f5ae;p=infrastructure.git diff --git a/scripts/git-update.sh b/scripts/git-update.sh index bd555e3..dc04653 100755 --- a/scripts/git-update.sh +++ b/scripts/git-update.sh @@ -20,6 +20,15 @@ fi ########## cd $DIRNAME +### xxx ideally we should not need to git checkout anything +# which would in addition remove the need for a non-bare repo +# this would take a bit more time though + +# make sure we keep track of the current branch upon exit +function current_branch () { + git branch | grep '^\*' | cut -d' ' -f2 +} + function all_branches () { remote=$1; shift git branch -r | grep $remote | fgrep -v -- '->' | sed "s/.*\///g" @@ -27,6 +36,7 @@ function all_branches () { function git_update () { + current_branch=$(current_branch) echo Running $COMMAND remote=origin for branch in $(all_branches $remote); do @@ -34,6 +44,8 @@ function git_update () { git branch | grep -q ' '$branch'$' || git branch --track $branch $remote/$branch git checkout $branch git merge --ff $remote/$branch + done + git checkout $current_branch } git_update >& .git-update.log