From a79f5cf754abda00e605360611d81d685ca64f1d Mon Sep 17 00:00:00 2001 From: "szager@chromium.org" Date: Thu, 20 Dec 2012 23:57:46 +0000 Subject: [PATCH] Some polishing... If the working copy isn't on a named branch, don't try to pull; just fetch. Use --quiet flag to git-submodule, to prevent interleaving of terminal output. Check target os before updating a submodule. TBR'ing, since no one really has a stake in this, and maruel doesn't do bash :). TBR=maruel@chromium.org Review URL: https://codereview.chromium.org/11645056 git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@174280 0039d316-1c4b-4281-b951-d872f2087c98 --- crup-runner.sh | 30 ++++++++++++++++++++++++++++-- git-crup | 3 +-- 2 files changed, 29 insertions(+), 4 deletions(-) diff --git a/crup-runner.sh b/crup-runner.sh index 9b17413dcb..97e79ce453 100755 --- a/crup-runner.sh +++ b/crup-runner.sh @@ -9,13 +9,39 @@ solution="${1%%/*}" cd "$solution" if [ "$solution" = "$1" ]; then shift - $@ | sed "s/^/[$solution] /g" 1>&2 + # Don't "pull" if checkout is not on a named branch + if test "$2" = "pull" && ( ! git symbolic-ref HEAD >/dev/null 2>/dev/null ); then + first_args="$1 fetch" + else + first_args="$1 $2" + fi + shift 2 + $first_args $@ | sed "s/^/[$solution] /g" 1>&2 if [ $? -ne 0 ]; then exit $? fi "$GIT_EXE" submodule --quiet sync "$GIT_EXE" ls-files -s | grep ^160000 | awk '{print $4}' | - sed "s/^/$solution\//g" + while read submod; do + # Check whether this submodule should be ignored or updated. + # If it's a new submodule, match the os specified in .gitmodules against + # the os specified in .git/config. + update_policy=$(git config "submodule.$submod.update" 2>/dev/null) + if [ -z "$update_policy" ]; then + target_os=$(git config target.os 2>/dev/null) + submod_os=$(git config -f .gitmodules "submodule.$submod.os" 2>/dev/null) + if [ -n "$target_os" -a -n "$submod_os" ] && + [ "$submod_os" != "all" -a "$submod_os" != "$target_os" ]; then + update_policy=none + else + update_policy=checkout + fi + git config "submodule.$submod.update" $update_policy 2>/dev/null + fi + if [ "$update_policy" != "none" ]; then + echo "$solution/$submod" + fi + done status=$? else submodule="${1#*/}" diff --git a/git-crup b/git-crup index fd81c893df..8633aa20d0 100755 --- a/git-crup +++ b/git-crup @@ -53,7 +53,7 @@ serial_update() { $GIT_EXE submodule --quiet sync $GIT_EXE ls-files -s | grep ^160000 | awk '{print $4}' | while read submod; do - $GIT_EXE submodule update --init "$submod" | sed "s|^|[$1/$submod] |g" + "$crup_runner" "$1/$submod" done ) } @@ -119,7 +119,6 @@ else fi set -o pipefail - if test "$xargs_parallel" = "yes"; then ( ls -d */.git | sed 's/\/\.git$//' | xargs $max_lines $replace_arg -P "$j" \