git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Relative url values in .gitmodules confusingly sensitive to clone via ssh vs https.
@ 2020-03-17 18:34 Benjamin Shropshire
  2020-03-18  0:26 ` brian m. carlson
  2020-03-23  1:11 ` brian m. carlson
  0 siblings, 2 replies; 7+ messages in thread
From: Benjamin Shropshire @ 2020-03-17 18:34 UTC (permalink / raw)
  To: git

From my perspective, this is a bug.

If I clone a repo twice like this:

git clone https://github.com/user/repo.git ./https
git clone git@github.com:user/repo.git ./ssh

And if it contains a .gitmodules like this:

[submodule "x"]
    path = xxx
    url = ../../different-user/something.git

When I `git submodule update --init --recursive` in each, only the
HTTPS version works. the SSH version confusingly seems to try to find
something at ~/different-user/something.git or some other path in the
local file system.

this seems consistent with the URL parsing resulting in different
segmentation and thus the ../../ ending up in different places:

https =[..., 'github.com', 'user', 'repo.git']
ssh=['git@github.com:user', 'repo.git']

# ../../
https[:-2] -> [..., 'github.com']
ssh[:-2] -> []

This theory is supported by the fact that this works:

git clone ssh://git@github.com/user/repo.git ./ssh
cd ssh
git submodule update --init --recursive

----
See also: https://stackoverflow.com/questions/36564696/how-to-use-same-protocol-for-git-submodules

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2020-03-23 23:54 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-03-17 18:34 Relative url values in .gitmodules confusingly sensitive to clone via ssh vs https Benjamin Shropshire
2020-03-18  0:26 ` brian m. carlson
2020-03-18 16:02   ` Benjamin Shropshire
2020-03-20  1:18     ` brian m. carlson
2020-03-23  1:11 ` brian m. carlson
2020-03-23 15:09   ` Benjamin Shropshire
2020-03-23 23:53     ` brian m. carlson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).