# of some repositories
# instead of hacking this script that is already scary, I preferred to write
# a separate script git-update.sh that runs a bit like auto-update.sh
-# and that additionally takes care of remote branches
-# the layout is as follows
+# and that also takes care of remote branches
+# so the overall the layout is as follows
# * manually created the local mirror by running
# cd /git-slave
# git clone ssh://tophat@git.top-hat.info/tophat.git
# * create a symlink for git-daemon
# cd /git
# ln -s /git-slave/tophat/.git tophat.git
-# * enable updates by just dropping a symlink there
-# cd /git-slave/tophat
-# ln -s /root/infrastructure/scripts/git-udate.sh
function slave_repo () {
git_slave=$1; shift
cd $git_slave
for subdir in *; do
- [ -x $subdir/git-update.sh ] && $subdir/git-update.sh
+ [ -d $subdir/.git ] && git-update.sh $subdir
done
}
##########
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"
function git_update () {
+ current_branch=$(current_branch)
echo Running $COMMAND
remote=origin
for branch in $(all_branches $remote); do
git checkout $branch
git merge --ff $remote/$branch
done
+ git checkout $current_branch
}
git_update >& .git-update.log