]> git.ipfire.org Git - thirdparty/git.git/commit - git-submodule.sh
Teach "git submodule add" the --name option
authorJens Lehmann <Jens.Lehmann@web.de>
Sat, 29 Sep 2012 23:05:58 +0000 (01:05 +0200)
committerJunio C Hamano <gitster@pobox.com>
Sun, 30 Sep 2012 04:49:11 +0000 (21:49 -0700)
commit73b0898d0d04d432525f9d56e29bf70fc7bf6ea9
tree29633187baa2b1a42edf17639017440fcae391f4
parent652398a88e7c3d18b6820a2ae369b05d26dc757f
Teach "git submodule add" the --name option

"git submodule add" initializes the name of a submodule to its path. This
was ok as long as the .git directory lived inside the submodule's work
tree, but since 1.7.8 it is stored in the .git/modules/<name> directory of
the superproject, making the submodule name survive the removal of the
submodule's work tree. This leads to problems when the user tries to add a
different submodule at the same path - and thus the same name - later, as
that will happily try to restore the submodule from the old repository
instead of the one the user specified and will lead to a checkout of the
wrong repository.

Add the new "--name" option to let the user provide a name for the
submodule. This enables the user to solve this conflict without having to
remove .git/modules/<name> by hand (which is no viable solution as it
makes it impossible to checkout a commit that records the old submodule
and populate it, as that will still check out the new submodule for the
same reason).

To achieve that the submodule's name is added to the parameter list of
the module_clone() helper function. This makes it possible to remove the
call of module_name() there because both callers of module_clone() already
know the name and can provide it as argument number two.

Reported-by: Jonathan Johnson <me@jondavidjohn.com>
Signed-off-by: Jens Lehmann <Jens.Lehmann@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Documentation/git-submodule.txt
Documentation/gitmodules.txt
git-submodule.sh
t/t7400-submodule-basic.sh