Merge branch 'fp/submodule-checkout-mode'
authorJunio C Hamano <gitster@pobox.com>
Fri, 17 Jan 2014 20:21:20 +0000 (12:21 -0800)
committerJunio C Hamano <gitster@pobox.com>
Fri, 17 Jan 2014 20:21:20 +0000 (12:21 -0800)
"submodule.*.update=checkout", when propagated from .gitmodules to
.git/config, turned into a "submodule.*.update=none", which did not
make much sense.

* fp/submodule-checkout-mode:
git-submodule.sh: 'checkout' is a valid update mode

1  2 
git-submodule.sh
diff --combined git-submodule.sh
index 2677f2e8b3c57dc5c1a632e5705b26f74cbd7137,5247f78f35455036a17914623d531e02a5fb617d..4a30087768a16d77bfcec41889f58b64fdf5f89c
@@@ -156,7 -156,7 +156,7 @@@ module_list(
                git ls-files -z --error-unmatch --stage -- "$@" ||
                echo "unmatched pathspec exists"
        ) |
 -      perl -e '
 +      @@PERL@@ -e '
        my %unmerged = ();
        my ($null_sha1) = ("0" x 40);
        my @out = ();
@@@ -545,12 -545,7 +545,12 @@@ cmd_foreach(
                                sm_path=$(relative_path "$sm_path") &&
                                # we make $path available to scripts ...
                                path=$sm_path &&
 -                              eval "$@" &&
 +                              if test $# -eq 1
 +                              then
 +                                      eval "$1"
 +                              else
 +                                      "$@"
 +                              fi &&
                                if test -n "$recursive"
                                then
                                        cmd_foreach "--recursive" "$@"
@@@ -622,7 -617,7 +622,7 @@@ cmd_init(
                   test -z "$(git config submodule."$name".update)"
                then
                        case "$upd" in
-                       rebase | merge | none)
+                       checkout | rebase | merge | none)
                                ;; # known modes of updating
                        *)
                                echo >&2 "warning: unknown update mode '$upd' suggested for submodule '$name'"
@@@ -721,6 -716,7 +721,6 @@@ cmd_deinit(
  cmd_update()
  {
        # parse $args after "submodule ... update".
 -      orig_flags=
        while test $# -ne 0
        do
                case "$1" in
                --reference)
                        case "$2" in '') usage ;; esac
                        reference="--reference=$2"
 -                      orig_flags="$orig_flags $(git rev-parse --sq-quote "$1")"
                        shift
                        ;;
                --reference=*)
                        break
                        ;;
                esac
 -              orig_flags="$orig_flags $(git rev-parse --sq-quote "$1")"
                shift
        done
  
                        update_module=$update
                else
                        update_module=$(git config submodule."$name".update)
+                       case "$update_module" in
+                       '')
+                               ;; # Unset update mode
+                       checkout | rebase | merge | none)
+                               ;; # Known update modes
+                       !*)
+                               ;; # Custom update command
+                       *)
+                               die "$(eval_gettext "Invalid update mode '$update_module' for submodule '$name'")"
+                               ;;
+                       esac
                fi
  
                displaypath=$(relative_path "$prefix$sm_path")
@@@ -921,7 -930,7 +932,7 @@@ Maybe you want to use 'update --init'?"
                                prefix="$prefix$sm_path/"
                                clear_local_git_env
                                cd "$sm_path" &&
 -                              eval cmd_update "$orig_flags"
 +                              eval cmd_update
                        )
                        res=$?
                        if test $res -gt 0