diff --git a/crup-runner.sh b/crup-runner.sh index 65fec79bf..e97d36456 100755 --- a/crup-runner.sh +++ b/crup-runner.sh @@ -1,5 +1,21 @@ #!/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 () { # Get the os we're building for. On first run, this will be unset. target_os=$(git config target.os 2>/dev/null) @@ -70,18 +86,9 @@ if [ "$solution" = "$1" ]; then exit 0 fi - # Don't "pull" if checkout is not on a named branch shift - 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 - status=$? - if [ "$status" -ne 0 ]; then - exit $status + if test $# -ne 0; then + update_toplevel "$@" fi set_target_os diff --git a/git-crsync b/git-crsync new file mode 100755 index 000000000..edeb20e77 --- /dev/null +++ b/git-crsync @@ -0,0 +1,3 @@ +#!/bin/bash + +exec bash git-crup --sync "$@" diff --git a/git-crup b/git-crup index d07a4283d..155afda63 100755 --- a/git-crup +++ b/git-crup @@ -45,16 +45,18 @@ fi usage() { cat <] EOF } serial_update() { ( cd "$1" - $GIT_EXE $pull $pull_args -q origin | sed "s/^/[$1] /g" - if [ $? -ne 0 ]; then - return $? + if test -n "$toplevel_cmd"; then + $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}' | @@ -93,6 +95,9 @@ while test $# -ne 0; do --fetch) pull=fetch ;; + --sync) + pull= + ;; --no-hooks|--nohooks) hooks=no ;; @@ -124,11 +129,17 @@ else xargs_parallel=no fi +if test -n "$pull"; then + toplevel_cmd="$GIT_EXE $pull $pull_args -q origin" +else + toplevel_cmd= +fi + 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 $GIT_EXE $pull $pull_args -q origin | + "$crup_runner" replace_arg $toplevel_cmd | xargs $max_lines -P "$j" "$crup_runner" ) else ls -d */.git |