# Creates a new git repository in $1, adds a new remote named $2 and fetches
# the master on $3. If the git repository already exists a new remote $2 for
# $3 is added. If the remote already exists nothing happens.
-function git_remote_init_update() {
+git_remote_init_update() {
# Make sure the requested directory exists.
mkdir -p "$1"
# Go to the target directory.
echo "Adding remote '$2' to '$1'."
git remote add -t master "$2" "$3/$1"
git fetch "$2" > /dev/null
- # Remove the remote if the fetch was unsuccessful.
+ # Remove the remote and abort if the fetch was unsuccessful.
if [ "$?" -ne "0" ]; then
git remote rm "$2"
+ exit 1
fi
# Pushing to the remote pushes only the master branch in remotes named
# Run setup.sh in each project.
if [ "$#" -eq "0" ]; then
- for project in `find . -name .git -type d`; do
+ for path in `find . -name setup.sh -type f`; do
# Skip this directory to prevent an infinite loop.
- [ "$project" = "./.git" ] && continue
+ [ "$path" = "./setup.sh" ] && continue
+ # Skip non executable setup.sh files as an easy way to deactivate one.
+ [ ! -x "$path" ] && continue
- [ -d "$project" ] && (echo "running setup.sh in '$project'";
- cd "$project/.."; ./setup.sh > /dev/null)
+ project=`echo "$path" | sed 's|/setup.sh$||'`
+
+ echo "running setup.sh in '$project'"
+ ( cd "$project"; ./setup.sh > /dev/null )
done
# Create git repository if necessary and/or additional remotes and fetch them.
elif [ "$#" -ge "2" ]; then