X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=scripts%2Fgit-update.sh;h=dc0465339bb252e87c86250631cdfd828da237b1;hb=a8aa1baef6f4d1df60f44d1d542912acff913226;hp=93b8ffd46da911554830233f17ced631351b825f;hpb=4e0a9e9be4d29de53686031b956f1997ac02bfea;p=infrastructure.git diff --git a/scripts/git-update.sh b/scripts/git-update.sh index 93b8ffd..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 @@ -35,6 +45,7 @@ function git_update () { git checkout $branch git merge --ff $remote/$branch done + git checkout $current_branch } git_update >& .git-update.log