From: Mark Levedahl <mlevedahl@gmail.com>
To: Johannes Schindelin <Johannes.Schindelin@gmx.de>
Cc: git@vger.kernel.org
Subject: Re: [PATCH 1/3] git-submodule - Follow top-level remote on init/update/clone
Date: Mon, 11 Feb 2008 20:00:18 -0500 [thread overview]
Message-ID: <47B0EFA2.9070903@gmail.com> (raw)
In-Reply-To: <alpine.LSU.1.00.0802112152050.3870@racer.site>
Johannes Schindelin wrote:
>> @@ -40,11 +42,13 @@ get_repo_base() {
>> # Resolve relative url by appending to parent's url
>> resolve_relative_url ()
>> {
>> - branch="$(git symbolic-ref HEAD 2>/dev/null)"
>> - remote="$(git config branch.${branch#refs/heads/}.remote)"
>> - remote="${remote:-origin}"
>> - remoteurl="$(git config remote.$remote.url)" ||
>> - die "remote ($remote) does not have a url in .git/config"
>>
>
> I did not really look at this code before, but does that not mean that
> git-submodule does already what you want?
>
> Because usually, you clone the superproject from the URL that you actually
> want to use, and in that case, the initial branch's default remote will
> have exactly that URL.
>
> So I have to admit that I do not see the reason why you remove that code,
> replace it with another (that I think does the same), and claim that you
> introduce that behaviour.
>
>
There were three changes:
1) Eliminate die() in a subshell - it doesn't work. Instead, must have a
return code and pass that up to top-level shell before exit can be done.
2) Eliminated duplication of get_default_remote(), instead using the
definition in git-parse-remote.
Suggestions? (Separate patches, don't do 2)?
3) Use the user specified $remote if given.
>> @@ -107,7 +112,7 @@ module_clone()
>> test -e "$path" &&
>> die "A file already exist at path '$path'"
>>
>> - git-clone -n "$url" "$path" ||
>> + git-clone -n -o "$remote" "$url" "$path" ||
>> die "Clone of '$url' into submodule path '$path' failed"
>> }
>>
>>
>
> If you do _that_, you will _force_ the submodule to have no "origin"
> remote. As discussed _at length_, this is not what you should do. The
> only reason to use "-o <other-nick-name>" is if you plan _not_ to use the
> same URL for the default remote.
>
This *must* define the remote using the same name as flowed down from
top-level, whatever that name is. Otherwise, subsequent fetch / update
following top-level just won't work. Consider if top-level
branch.<name>.remote = frotz and we define not frotz but origin in the
submodule. Later, on different branch, top-level branch.<name>.remote =
origin. The submodule has origin defined but it points to a server
different than top-level's origin. Now what?
The same holds true if user gave -r frotz: ignoring that and defining
origin instead is an outright bug.
>
> Why do you need the "realremote" here? Why is "$remote" not enough?
>
Good catch - there was a reason in an earlier version of this, no longer
relevant.
>
>> @@ -235,7 +259,7 @@ cmd_init()
>> # Possibly a url relative to parent
>> case "$url" in
>> ./*|../*)
>> - url="$(resolve_relative_url "$url")"
>> + url=$(resolve_relative_url "$url") || exit 1
>>
>
> Yes for the "|| exit 1". No for the removal of the quotes: keep in mind:
> you are possibly getting a url from the _config_, which is supposed to be
> user-editable.
>
Works fine as is (You need the quotes when using the variable, not when
defining it):
git>git config foo.name "some string
> with cr"
git>z=$(git config foo.name)
git>echo "$z"
some string
with cr
As written, the old code had the perverse effect of *not* quoting $url,
and that was the part that needed to be quoted.
>> @@ -274,6 +308,7 @@ cmd_update()
>> shift
>> done
>>
>> + remote=${remote:-$(get_default_remote)}
>>
>
> You have this paradigm so often, but AFAICS you only use it for the call
> to module_clone. Why not let module_clone figure it out, if $remote is
> empty?
>
>
Will do.
>> @@ -298,9 +333,24 @@ cmd_update()
>> die "Unable to find current revision in submodule path '$path'"
>>
> Wasn't the whole _point_ of having a two-stage init/update that you could
> _change_ the remote in the config?
>
> Now you override those settings if .gitmodules says that the path is
> relative? Shouldn't you respect the setting in the config (which the user
> can change freely), rather than .gitmodules (which the user cannot change
> without either committing it or having a permanently dirty working
> directory)?
>
Ok, I was trying to avoid defining another config variable. The
"relativeness" of a submodule is not knowable from submodule.<path>.url
as that is always absolute (if relative in .gitmodules, it is resolved
into an absolute url during git init). I see two choices:
1) define variable submodule.<path>.isrelative during init, and use
that instead. The user would have to modify that and the url to override.
2) always resolve the relative url from .gitmodules, compare with
submodule.<path>.url and decide it was relative if those two agree. More
overhead, enough complexity that I fear for strange failure modes later on.
Any preferences or other suggestions?
Mark
next prev parent reply other threads:[~2008-02-12 1:01 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-02-09 16:57 [PATCH 1/3] git-submodule - Follow top-level remote on init/update/clone Mark Levedahl
2008-02-09 16:57 ` [PATCH 2/3] git-submodule - Allow adding a submodule in-place Mark Levedahl
2008-02-09 16:57 ` [PATCH 3/3] Add t/t7401 - test submodule interaction with remotes machinery Mark Levedahl
2008-03-03 13:14 ` [PATCH 2/3] git-submodule - Allow adding a submodule in-place Ping Yin
2008-02-11 22:09 ` [PATCH 1/3] git-submodule - Follow top-level remote on init/update/clone Johannes Schindelin
2008-02-12 1:00 ` Mark Levedahl [this message]
2008-02-12 1:10 ` Johannes Schindelin
2008-02-12 1:34 ` Mark Levedahl
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=47B0EFA2.9070903@gmail.com \
--to=mlevedahl@gmail.com \
--cc=Johannes.Schindelin@gmx.de \
--cc=git@vger.kernel.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.