| OLD | NEW |
| 1 #!/bin/bash | 1 #!/bin/bash |
| 2 | 2 |
| 3 update_toplevel () { | 3 update_toplevel () { |
| 4 # Don't "pull" if checkout is not on a named branch | 4 # Don't "pull" if checkout is not on a named branch |
| 5 if test "$2" = "pull" && ( ! git symbolic-ref HEAD >/dev/null 2>/dev/null ); t
hen | 5 if test "$2" = "pull" && ( ! git symbolic-ref HEAD >/dev/null 2>/dev/null ); t
hen |
| 6 first_args="$1 fetch" | 6 first_args="$1 fetch" |
| 7 else | 7 else |
| 8 first_args="$1 $2" | 8 first_args="$1 $2" |
| 9 fi | 9 fi |
| 10 shift 2 | 10 shift 2 |
| 11 echo "[$solution] $first_args $@" 1>&2 | 11 echo "[$solution] $first_args $@" 1>&2 |
| 12 $first_args $@ | sed "s/^/[$solution] /g" 1>&2 | 12 $first_args $@ | sed "s/^/[$solution] /g" 1>&2 |
| 13 status=$? | 13 status=$? |
| 14 if [ "$status" -ne 0 ]; then | 14 if [ "$status" -ne 0 ]; then |
| 15 exit $status | 15 exit $status |
| 16 fi | 16 fi |
| 17 } | 17 } |
| 18 | 18 |
| 19 set_target_os () { | 19 set_target_os () { |
| 20 # Get the os we're building for. On first run, this will be unset. | 20 # Get the os we're building for. On first run, this will be unset. |
| 21 target_os=$(git config target.os 2>/dev/null) | 21 target_os=$(git config --get-all target.os 2>/dev/null) |
| 22 if [ -z "$target_os" ]; then | 22 if [ -z "$target_os" ]; then |
| 23 case $(uname -s) in | 23 case $(uname -s) in |
| 24 Linux) target_os=unix ;; | 24 Linux) target_os=unix ;; |
| 25 Darwin) target_os=mac ;; | 25 Darwin) target_os=mac ;; |
| 26 CYGWIN*|MINGW*) target_os=win ;; | 26 CYGWIN*|MINGW*) target_os=win ;; |
| 27 *) | 27 *) |
| 28 echo "[$solution] *** No target.os set in .git/config, and I can't" 1>&2 | 28 echo "[$solution] *** No target.os set in .git/config, and I can't" 1>&2 |
| 29 echo "[$solution] *** figure it out from 'uname -s'" 1>&2 | 29 echo "[$solution] *** figure it out from 'uname -s'" 1>&2 |
| 30 exit 1 | 30 exit 1 |
| 31 ;; | 31 ;; |
| (...skipping 16 matching lines...) Expand all Loading... |
| 48 fi | 48 fi |
| 49 } | 49 } |
| 50 | 50 |
| 51 process_submodule () { | 51 process_submodule () { |
| 52 # Check whether this submodule should be ignored or updated. | 52 # Check whether this submodule should be ignored or updated. |
| 53 # If it's a new submodule, match the os specified in .gitmodules against | 53 # If it's a new submodule, match the os specified in .gitmodules against |
| 54 # the os specified in .git/config. | 54 # the os specified in .git/config. |
| 55 update_policy=$(git config --get "submodule.$1.update") | 55 update_policy=$(git config --get "submodule.$1.update") |
| 56 if [ -z "$update_policy" ]; then | 56 if [ -z "$update_policy" ]; then |
| 57 submod_os=$(git config -f .gitmodules --get "submodule.$1.os") | 57 submod_os=$(git config -f .gitmodules --get "submodule.$1.os") |
| 58 if [ -n "$submod_os" -a \ | 58 if [ -n "$submod_os" -a "$submod_os" != "all" ]; then |
| 59 "$submod_os" != "all" -a \ | |
| 60 "${submod_os/${target_os}/}" = "${submod_os}" ]; then | |
| 61 update_policy=none | 59 update_policy=none |
| 60 for os in $target_os; do |
| 61 if [ "${submod_os/${os}/}" != "${submod_os}" ]; then |
| 62 update_policy=checkout |
| 63 fi |
| 64 done |
| 62 else | 65 else |
| 66 update_policy=checkout |
| 67 fi |
| 68 if [ "$update_policy" != "none" ]; then |
| 63 git submodule --quiet init "$1" | 69 git submodule --quiet init "$1" |
| 64 update_policy=checkout | |
| 65 fi | 70 fi |
| 66 git config "submodule.$1.update" $update_policy | 71 git config "submodule.$1.update" $update_policy |
| 67 fi | 72 fi |
| 68 ignore_policy=$(git config --get "submodule.$1.ignore") | 73 ignore_policy=$(git config --get "submodule.$1.ignore") |
| 69 if [ -z "$ignore_policy" ]; then | 74 if [ -z "$ignore_policy" ]; then |
| 70 git config "submodule.$1.ignore" all | 75 git config "submodule.$1.ignore" all |
| 71 fi | 76 fi |
| 72 if [ "$update_policy" != "none" ]; then | 77 if [ "$update_policy" != "none" ]; then |
| 73 update_submodule_url "$1" | 78 update_submodule_url "$1" |
| 74 echo "$solution/$1" | 79 echo "$solution/$1" |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 113 submodule="${1#*/}" | 118 submodule="${1#*/}" |
| 114 echo "[$solution] updating $submodule" | 119 echo "[$solution] updating $submodule" |
| 115 git submodule update --recursive --quiet "$submodule" | | 120 git submodule update --recursive --quiet "$submodule" | |
| 116 ( grep -v '^Skipping submodule' || true ) | sed "s|^|[$1] |g" 2>/dev/null | 121 ( grep -v '^Skipping submodule' || true ) | sed "s|^|[$1] |g" 2>/dev/null |
| 117 status=$? | 122 status=$? |
| 118 if [ "$status" -ne "0" ]; then | 123 if [ "$status" -ne "0" ]; then |
| 119 echo "[$solution] FAILED to update $submodule" | 124 echo "[$solution] FAILED to update $submodule" |
| 120 fi | 125 fi |
| 121 fi | 126 fi |
| 122 exit $status | 127 exit $status |
| OLD | NEW |