#!/bin/sh update_svn() { DIR=$(cd "$1" && pwd -P) [ -d "$DIR" ] || return 0 echo "== $DIR" # svn upgrade "$DIR" svn up "$DIR" } update_git() { local staged=false cd "$1" || return 1 echo "== $PWD" git fetch --all --prune git remote | xargs -r git fetch --multiple --prune --tags if [ -n "$(git ls -md)" ]; then if git stash; then staged=true fi fi git pull --rebase ! $staged || git stash pop cd - > /dev/null } update_repo() { cd "$1" || return 1 echo "== $PWD" repo sync cd - > /dev/null } if [ $# -eq 0 ]; then if git rev-parse --is-inside-work-tree > /dev/null; then set -- "$(git rev-parse --show-toplevel)" else set -- . fi fi for d; do if [ -e "$d/.git" ]; then mode=git elif [ -d "$d/.svn" ]; then mode=svn elif [ -d "$d/.repo" ]; then mode=repo else continue fi update_${mode} "$d" done