aboutsummaryrefslogtreecommitdiff
path: root/git-submodule.sh
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2013-12-02 13:31:55 -0800
committerJunio C Hamano <gitster@pobox.com>2013-12-02 13:48:06 -0800
commitac1fbbda2013416b6c6a93d65c5dcf6662a60579 (patch)
tree29202f37d2eb45ca3df630f6cc7d58c4e7e77340 /git-submodule.sh
parent5c1d2e8af99c1cf24a38fe830d96a4aedce30e2b (diff)
downloadgit-ac1fbbda2013416b6c6a93d65c5dcf6662a60579.tar.gz
git-ac1fbbda2013416b6c6a93d65c5dcf6662a60579.tar.xz
submodule: do not copy unknown update mode from .gitmodules
When submodule.$name.update is given as hint from the upstream in the .gitmodules file, we used to blindly copy it to .git/config, unless there already is a value defined for the submodule. However, there is no reason to expect that the update mode hinted by the upstream is available in the version of Git the user is using, and a really custom "!cmd" prepared by an upstream person running on Linux may not even be available to a user on Windows. It is simply irresponsible to copy the setting blindly and to attempt to use it during a later "submodule update" without validating it first. Just show the suggested value to the diagnostic output, and set the value to 'none' in the configuration, if it is not one of the ones that are known to be supported by this version of Git. Helped-by: Jens Lehmann <Jens.Lehmann@web.de> Helped-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'git-submodule.sh')
-rwxr-xr-xgit-submodule.sh20
1 files changed, 15 insertions, 5 deletions
diff --git a/git-submodule.sh b/git-submodule.sh
index 297919708..83917d805 100755
--- a/git-submodule.sh
+++ b/git-submodule.sh
@@ -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
}