Code

submodules: always use a relative path to gitdir
authorJens Lehmann <Jens.Lehmann@web.de>
Sun, 4 Mar 2012 21:14:30 +0000 (22:14 +0100)
committerJunio C Hamano <gitster@pobox.com>
Mon, 5 Mar 2012 05:19:41 +0000 (21:19 -0800)
commitea115a0d43d176f873855f9a7372376161dd8e65
treec8a942d7bb1531492ce8db1368fa7bdc91e840c1
parent1017c1abcb6d733e1de83eb5a1cf7e1bf4ad6aca
submodules: always use a relative path to gitdir

Since recently a submodule with name <name> has its git directory in the
.git/modules/<name> directory of the superproject while the work tree
contains a gitfile pointing there. When the submodule git directory needs
to be cloned because it is not found in .git/modules/<name> the clone
command will write an absolute path into the gitfile. When no clone is
necessary the git directory will be reactivated by the git-submodule.sh
script by writing a relative path into the gitfile.

This is inconsistent, as the behavior depends on the submodule having been
cloned before into the .git/modules of the superproject. A relative path
is preferable here because it allows the superproject to be moved around
without invalidating the gitfile. We do that by always writing the
relative path into the gitfile, which overwrites the absolute path the
clone command may have written there.

This is only the first step to make superprojects movable again like they
were before the separate-git-dir approach was introduced. The second step
is to use a relative path in core.worktree too.

Enhance t7400 to ensure that future versions won't re-add absolute paths
by accident.

While at it also replace an if/else construct evaluating the presence
of the 'reference' option with a single line of bash code.

Reported-by: Antony Male <antony.male@gmail.com>
Signed-off-by: Jens Lehmann <Jens.Lehmann@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
git-submodule.sh
t/t7400-submodule-basic.sh