Commit 69aea165 authored by szager@chromium.org's avatar szager@chromium.org

Add --sync option, to only sync submodules.

Also add git-crsync as shorthand for `git crup --sync`.

TBR=iannucci@chromium.org

BUG=

Review URL: https://codereview.chromium.org/12279006

git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@182767 0039d316-1c4b-4281-b951-d872f2087c98
parent 0ecad9c0
#!/bin/bash #!/bin/bash
update_toplevel () {
# 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
echo "[$solution] $first_args $@" 1>&2
$first_args $@ | sed "s/^/[$solution] /g" 1>&2
status=$?
if [ "$status" -ne 0 ]; then
exit $status
fi
}
set_target_os () { set_target_os () {
# Get the os we're building for. On first run, this will be unset. # Get the os we're building for. On first run, this will be unset.
target_os=$(git config target.os 2>/dev/null) target_os=$(git config target.os 2>/dev/null)
...@@ -70,18 +86,9 @@ if [ "$solution" = "$1" ]; then ...@@ -70,18 +86,9 @@ if [ "$solution" = "$1" ]; then
exit 0 exit 0
fi fi
# Don't "pull" if checkout is not on a named branch
shift shift
if test "$2" = "pull" && ( ! git symbolic-ref HEAD >/dev/null 2>/dev/null ); then if test $# -ne 0; then
first_args="$1 fetch" update_toplevel "$@"
else
first_args="$1 $2"
fi
shift 2
$first_args $@ | sed "s/^/[$solution] /g" 1>&2
status=$?
if [ "$status" -ne 0 ]; then
exit $status
fi fi
set_target_os set_target_os
......
#!/bin/bash
exec bash git-crup --sync "$@"
...@@ -45,16 +45,18 @@ fi ...@@ -45,16 +45,18 @@ fi
usage() { usage() {
cat <<EOF cat <<EOF
Usage: git-crup [-n|--dry-run] [--fetch] [-j|--jobs [jobs]] Usage: git-crup [-n|--dry-run] [--fetch|--sync] [-j|--jobs [jobs]]
[--no-hooks] [<args to git-pull or git-fetch>] [--no-hooks] [<args to git-pull or git-fetch>]
EOF EOF
} }
serial_update() { serial_update() {
( cd "$1" ( cd "$1"
$GIT_EXE $pull $pull_args -q origin | sed "s/^/[$1] /g" if test -n "$toplevel_cmd"; then
if [ $? -ne 0 ]; then $toplevel_cmd | sed "s/^/[$1] /g"
return $? if [ $? -ne 0 ]; then
return $?
fi
fi fi
$GIT_EXE submodule --quiet sync $GIT_EXE submodule --quiet sync
$GIT_EXE ls-files -s | grep ^160000 | awk '{print $4}' | $GIT_EXE ls-files -s | grep ^160000 | awk '{print $4}' |
...@@ -93,6 +95,9 @@ while test $# -ne 0; do ...@@ -93,6 +95,9 @@ while test $# -ne 0; do
--fetch) --fetch)
pull=fetch pull=fetch
;; ;;
--sync)
pull=
;;
--no-hooks|--nohooks) --no-hooks|--nohooks)
hooks=no hooks=no
;; ;;
...@@ -124,11 +129,17 @@ else ...@@ -124,11 +129,17 @@ else
xargs_parallel=no xargs_parallel=no
fi fi
if test -n "$pull"; then
toplevel_cmd="$GIT_EXE $pull $pull_args -q origin"
else
toplevel_cmd=
fi
set -o pipefail set -o pipefail
if test "$xargs_parallel" = "yes"; then if test "$xargs_parallel" = "yes"; then
( ls -d */.git | sed 's/\/\.git$//' | ( ls -d */.git | sed 's/\/\.git$//' |
xargs $max_lines $replace_arg -P "$j" \ xargs $max_lines $replace_arg -P "$j" \
"$crup_runner" replace_arg $GIT_EXE $pull $pull_args -q origin | "$crup_runner" replace_arg $toplevel_cmd |
xargs $max_lines -P "$j" "$crup_runner" ) xargs $max_lines -P "$j" "$crup_runner" )
else else
ls -d */.git | ls -d */.git |
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment