From: Marc Branchaud <marcnarc@xiplink.com>
To: Phil Hord <hordp@cisco.com>
Cc: Jens Lehmann <Jens.Lehmann@web.de>,
git@vger.kernel.org, Junio C Hamano <gitster@pobox.com>
Subject: Re: [PATCH] submodule add: improve message when resolving a relative url fails
Date: Wed, 01 Jun 2011 11:55:14 -0400 [thread overview]
Message-ID: <4DE660E2.9080500@xiplink.com> (raw)
In-Reply-To: <4DE565DF.7050207@cisco.com>
On 11-05-31 06:04 PM, Phil Hord wrote:
> On 05/31/2011 04:57 PM, Marc Branchaud wrote:
>> Thanks for the cogent explanation & patch. I think the message could be
>> improved a bit:
>>
>> Cannot resolve "../sub" relative to this repository's "origin"
>> remote: The remote's URL is not set in .git/config
>>
>> However, overall I think this is a pretty fragile way to handle relative
>> paths. Consider:
>>
>> - The super-repo must be a clone in order for this to work at all.
>
> Yes, but that constraint (mostly) makes sense to me. But if 'git
> submodule add' did not initialize .git/config, this constraint could be
> dropped.
>
>> - The super-repo cannot be checked out on a detached HEAD.
>
> Why do you think that? I just tried this and it worked fine for me. I
> can't think of a reason for it to fail.
Whoops, right. I was confusing a different error with the fact that "git
symbolic-ref HEAD" fails on a detached HEAD. The code defaults to "origin"
as the remote name in this case (perhaps that's not strictly the right thing
to do, but I'm sure this isn't the only part of git that assumes there's a
remote called "origin").
>> - The current code rewrites the URL so that any relative path is either
>> rejected or munged into an absolute remote URL.
>
> I don't see the URL getting munged away from being relative. Can you
> point to an example?
I reached this conclusion because if I go into my clone of git.git and do
git submodule add ../MyThing
where ../MyThing is a regular git repo, I get
Cloning into MyThing...
fatal: The remote end hung up unexpectedly
Clone of 'git://git.kernel.org/pub/scm/git/MyThing' into submodule path
'MyThing' failed
So it seemed the relative URL became an absolute URL.
Looking more closely at a working example, I can see that (as you show below)
the URL in the super-repo's .gitmodules file retains the relative path, but
the submodule's remote.origin.url is an absolute path.
In any case, "submodule add" isn't doing what I expected: make my local
MyThing repo a submodule of my git.git clone.
>> It seems to me that this feature will only work in a fairly narrow set of
>> circumstances, and even when it does work it's likely to do something
>> unexpected (think of a super-repo with several remotes).
>
> I use it this way with several remotes.
>
>> Back when Junio accepted the original patch, he said "If you maintain and
>> serve a set related projects you need to give the users a single URL (per
>> where the user is and how to reach the server)." I'm not sure I understand
>> that: Why would the users be adding their own submodules to the
>> superproject? Wouldn't the superproject define the submodules in for them?
> I am a user. I admin a super-project for other users. This project
> lives at three remotes, remotes/public, remotes/shared and remotes/build.
>
> I add a new submodule to the superproject like this:
>
> mkdir sub && cd sub && git init
> cd ..
> git submodule add ../sub sub
>
> This results in the new submodule being inserted into my .gitmodules
> file and my .git/config:
>
> tail -3 .gitmodules
> [submodule "sub"]
> path = sub
> url = ../sub
>
> tail -2 .git/config
> [submodule "sub"]
> url = public:git/sub
>
> I do have to make sure to push my submodule to the correct location on
> each remote before pushing my new .gitmodules.
>
> But the exact same commands work for me if I do this first and then do
> 'git submodule add ../sub' afterwards.
>
> So, I don't understand your objections. Do you understand my use case
> any better?
It's not so much an objection as confusion over how "submodule add" works.
I believe your case works smoothly only because in your super-project you're
careful to make sure you have checked out a branch that remotely tracks a
something in remotes/public. If you checked out a branch that tracks a
different remote you'd get different results. This seems fragile to me.
When you tried the detached-HEAD scenario, did you get URLs for
"public:git/sub" or "origin:git/sub"? Does "origin" just happen to be the
remote you want to use in any case?
My fundamental point is that "git submodule add" seems to do confusing things
with relative paths. Maybe all that's needed is to clarify the
documentation. I'll post a patch.
M.
next prev parent reply other threads:[~2011-06-01 15:55 UTC|newest]
Thread overview: 40+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-05-30 21:51 [PATCH 0/2] Tests for some submodule corner cases Marc Branchaud
2011-05-30 21:51 ` [PATCH 1/2] Added a test for "submodule add" using a ../relative/path/to/the/submodule/repo Marc Branchaud
2011-05-30 21:51 ` [PATCH 2/2] Added a test for "submodule status" when the submodule's working directory has deleted files Marc Branchaud
2011-05-31 19:30 ` [PATCH 0/2] Tests for some submodule corner cases Jens Lehmann
2011-05-31 20:00 ` [PATCH] submodule add: improve message when resolving a relative url fails Jens Lehmann
2011-05-31 20:57 ` Marc Branchaud
2011-05-31 21:34 ` [PATCH v2] " Jens Lehmann
2011-05-31 22:04 ` [PATCH] " Phil Hord
2011-06-01 15:55 ` Marc Branchaud [this message]
2011-07-27 19:00 ` Phil Hord
2011-07-29 20:10 ` Marc Branchaud
2011-05-31 23:23 ` Junio C Hamano
2011-06-01 15:56 ` [PATCH] Clarified how "git submodule add" handles relative paths Marc Branchaud
2011-06-01 16:59 ` Junio C Hamano
2011-06-01 19:55 ` Jens Lehmann
2011-06-02 17:14 ` Junio C Hamano
2011-06-03 19:51 ` Jens Lehmann
2011-06-03 23:16 ` Junio C Hamano
2011-06-04 2:23 ` Mark Levedahl
2011-06-04 15:39 ` Jens Lehmann
2011-06-04 16:19 ` Jens Lehmann
2011-06-05 18:27 ` Junio C Hamano
2011-06-06 19:56 ` [PATCH 0/3] submodule add: allow relative repository path even when no url is set Jens Lehmann
2011-06-06 19:57 ` [PATCH 1/3] submodule add: test failure when url is not configured in superproject Jens Lehmann
2011-06-06 19:58 ` [PATCH 2/3] submodule add: allow relative repository path even when no url is set Jens Lehmann
2011-06-06 20:49 ` [PATCH 0/2] Improve "git submodule add" documentation Marc Branchaud
2011-06-06 20:49 ` [PATCH 1/2] More precisely described how "git submodule add" handles relative submodule URLs Marc Branchaud
2011-06-06 20:49 ` [PATCH 2/2] Moved paragraph describing the utility of " Marc Branchaud
2011-06-06 19:58 ` [PATCH 3/3] submodule add: clean up duplicated code Jens Lehmann
2011-06-06 21:00 ` [PATCH 0/3] submodule add: allow relative repository path even when no url is set Junio C Hamano
2011-06-06 21:23 ` Marc Branchaud
2011-06-06 21:39 ` Jens Lehmann
2011-06-07 21:03 ` Jens Lehmann
2011-06-08 13:16 ` Phil Hord
2011-06-02 14:21 ` [PATCHv2] Clarified how "git submodule add" handles relative paths Marc Branchaud
2011-05-31 21:06 ` [PATCH 0/2] Tests for some submodule corner cases Marc Branchaud
2011-05-31 21:26 ` Jens Lehmann
2011-06-01 16:11 ` Marc Branchaud
2011-06-01 17:44 ` Junio C Hamano
2011-06-01 19:26 ` Jens Lehmann
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4DE660E2.9080500@xiplink.com \
--to=marcnarc@xiplink.com \
--cc=Jens.Lehmann@web.de \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=hordp@cisco.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).