git-sh-setup.sh: add variable to use the stuck-long mode
[gitweb.git] / git-submodule.sh
index 74cbc53b53cef2e482726e82d547f8425cd073da..4a30087768a16d77bfcec41889f58b64fdf5f89c 100755 (executable)
@@ -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,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" "$@"
@@ -612,11 +617,21 @@ cmd_init()
                fi
 
                # Copy "update" setting when it is not set yet
-               upd="$(git config -f .gitmodules submodule."$name".update)"
-               test -z "$upd" ||
-               test -n "$(git config submodule."$name".update)" ||
-               git config submodule."$name".update "$upd" ||
-               die "$(eval_gettext "Failed to register update mode for submodule path '\$displaypath'")"
+               if upd="$(git config -f .gitmodules submodule."$name".update)" &&
+                  test -n "$upd" &&
+                  test -z "$(git config submodule."$name".update)"
+               then
+                       case "$upd" in
+                       checkout | rebase | merge | none)
+                               ;; # known modes of updating
+                       *)
+                               echo >&2 "warning: unknown update mode '$upd' suggested for submodule '$name'"
+                               upd=none
+                               ;;
+                       esac
+                       git config submodule."$name".update "$upd" ||
+                       die "$(eval_gettext "Failed to register update mode for submodule path '\$displaypath'")"
+               fi
        done
 }
 
@@ -790,6 +805,17 @@ cmd_update()
                        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")