]> git.ipfire.org Git - thirdparty/git.git/blobdiff - git-submodule.sh
submodule: do not copy unknown update mode from .gitmodules
[thirdparty/git.git] / git-submodule.sh
index 2979197087f2c6d97e2945008394d50c16a195a5..83917d8055d4c009664a88cfb97eeb5f5b2577b5 100755 (executable)
@@ -612,11 +612,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
+                       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
 }