Chromium Code Reviews| Index: git-crup |
| diff --git a/git-crup b/git-crup |
| index 155afda63c6629f86336d0076851b00ed1bb4d53..9ab2977ebfba092b065367915f88e06973fc71c4 100755 |
| --- a/git-crup |
| +++ b/git-crup |
| @@ -7,61 +7,40 @@ |
| # submodule-based checkout. Fetches latest commits for top-level solutions; |
| # updates submodules; and runs post-sync hooks. |
| -# Auto-update depot_tools |
| -if [ -z "$GIT_CRUP_REINVOKE" ]; then |
| - update_depot_tools || exit 1 |
| - GIT_CRUP_REINVOKE=1 exec bash "$0" "$@" |
| -fi |
| - |
| -export GIT_MERGE_AUTOEDIT=0 |
| - |
| +orig_args="$@" |
| ECHO= |
| pull=pull |
| pull_args= |
| hooks=yes |
| j=10 |
| crup_runner="crup-runner.sh" |
| -runhooks="git-runhooks" |
| - |
| -kernel_name=$(uname -s) |
| -if [ "${kernel_name:0:5}" = "MINGW" -o "${kernel_name:0:6}" = "CYGWIN" ]; then |
| - GIT_EXE=git.exe |
| -else |
| - GIT_EXE=git |
| -fi |
| -export GIT_EXE |
| - |
| -if ( echo test | xargs --max-lines=1 true 2>/dev/null ); then |
| - max_lines="--max-lines=1" |
| -else |
| - max_lines="-L 1" |
| -fi |
| - |
| -if ( echo test | xargs -I bar true 2>/dev/null ); then |
| - replace_arg="-I replace_arg" |
| -else |
| - replace_arg="-ireplace_arg" |
| -fi |
| usage() { |
| cat <<EOF |
| Usage: git-crup [-n|--dry-run] [--fetch|--sync] [-j|--jobs [jobs]] |
| [--no-hooks] [<args to git-pull or git-fetch>] |
| + |
| + -n, --dry-run Don't do anything; just show what would have been done. |
| + --fetch Run 'git fetch' on top-level sources, but don't merge. |
| + --sync Don't do anything at all to the top-level sources. |
| + -j, --jobs Run this many jobs in parallel. |
| + --no-hooks Don't run hooks (e.g., to generate build files) after |
| + updating. |
| EOF |
| } |
| serial_update() { |
| ( cd "$1" |
| if test -n "$toplevel_cmd"; then |
| - $toplevel_cmd | sed "s/^/[$1] /g" |
| + $ECHO $toplevel_cmd | sed "s/^/[$1] /g" |
| if [ $? -ne 0 ]; then |
| return $? |
| fi |
| fi |
| - $GIT_EXE submodule --quiet sync |
| - $GIT_EXE ls-files -s | grep ^160000 | awk '{print $4}' | |
| + $ECHO git submodule --quiet sync |
| + $ECHO git ls-files -s | grep ^160000 | awk '{print $4}' | |
| while read submod; do |
| - "$crup_runner" "$1/$submod" |
| + $ECHO "$crup_runner" "$1/$submod" |
| done |
| ) |
| } |
| @@ -109,6 +88,28 @@ while test $# -ne 0; do |
| shift |
| done |
| +# Auto-update depot_tools. Windows behaves badly if you rewrite a file while |
| +# it's being executed, which might happen to this file when update_depot_tools |
| +# runs. So, we re-exec from a temporary script. |
|
iannucci
2013/03/20 23:41:19
Are we absolutely sure that this happens? Doesn't
szager1
2013/03/21 00:06:08
By golly, you're right! I'll nuke this code.
|
| +if [ -z "$GIT_CRUP_REINVOKE" ]; then |
| + if [ -z "$TEMP" ]; then |
| + TEMP="/tmp" |
| + fi |
| + tmp_script="${TEMP}/git_crup_reinvoke.sh" |
| + cat <<EOF > "$tmp_script" |
| +#!/bin/bash |
| + |
| +kernel_name="\$(uname -s)" |
| +if [ "\${kernel_name:0:5}" = "MINGW" ]; then |
| + cmd '/C update_depot_tools.bat' |
| +else |
| + update_depot_tools |
| +fi |
| +GIT_CRUP_REINVOKE=1 exec bash "$0" $orig_args |
| +EOF |
| + exec bash "$tmp_script" "$kernel_name" |
| +fi |
| + |
| while test "$PWD" != "/"; do |
| if test -f "$PWD/src/.gitmodules"; then |
| break |
| @@ -120,6 +121,20 @@ if test "$PWD" = "/"; then |
| exit 1 |
| fi |
| +export GIT_MERGE_AUTOEDIT=no |
| + |
| +if ( echo test | xargs --max-lines=1 true 2>/dev/null ); then |
| + max_lines="--max-lines=1" |
| +else |
| + max_lines="-L 1" |
| +fi |
| + |
| +if ( echo test | xargs -I bar true 2>/dev/null ); then |
| + replace_arg="-I replace_arg" |
| +else |
| + replace_arg="-ireplace_arg" |
| +fi |
| + |
| if ( echo test test | xargs -P 2 true 2>/dev/null ); then |
| xargs_parallel=yes |
| else |
| @@ -130,7 +145,7 @@ else |
| fi |
| if test -n "$pull"; then |
| - toplevel_cmd="$GIT_EXE $pull $pull_args -q origin" |
| + toplevel_cmd="git $pull $pull_args -q origin" |
| else |
| toplevel_cmd= |
| fi |
| @@ -139,8 +154,8 @@ set -o pipefail |
| if test "$xargs_parallel" = "yes"; then |
| ( ls -d */.git | sed 's/\/\.git$//' | |
| xargs $max_lines $replace_arg -P "$j" \ |
| - "$crup_runner" replace_arg $toplevel_cmd | |
| - xargs $max_lines -P "$j" "$crup_runner" ) |
| + "$crup_runner" replace_arg $ECHO $toplevel_cmd | |
| + xargs $max_lines -P "$j" $ECHO "$crup_runner" ) |
| else |
| ls -d */.git | |
| while read gitdir; do |
| @@ -159,7 +174,7 @@ EOF |
| fi |
| if [ "$hooks" = "yes" ]; then |
| - "$runhooks" |
| + $ECHO git runhooks |
| status=$? |
| fi |