git@vger.kernel.org list mirror (unofficial, one of many)
 help / color / mirror / code / Atom feed
From: Philippe Blain <levraiphilippeblain@gmail.com>
To: Ben Avison <bavison@riscosopen.org>,
	Atharva Raykar <raykar.ath@gmail.com>,
	Christian Couder <christian.couder@gmail.com>,
	Shourya Shukla <periperidip@gmail.com>,
	Emily Shaffer <emilyshaffer@google.com>
Cc: git@vger.kernel.org
Subject: Re: Bug in git submodule update --remote
Date: Sat, 22 May 2021 15:15:51 -0400	[thread overview]
Message-ID: <ae3baa2a-2f30-8e8a-f3cf-d8210e7225b0@gmail.com> (raw)
In-Reply-To: <a727c1af-4993-684d-d299-00bf1a47cfc7@riscosopen.org>

Hi Ben,

Le 2021-05-19 à 10:41, Ben Avison a écrit :
> On 19/05/2021 11:49, Atharva Raykar wrote:
>> If I understood you correctly, you'd prefer that the updating of the
>> submodule should be independent of the ref that is checked out in the
>> submodule's directory.
>>
>> While I am not sure of the reason why the design of 'update
>> --remote' uses the remote-tracking branch of the submodule, I can
>> imagine adding a switch like 'submodule.<name>.remote' that defaults
>> to 'origin'. Then the behaviour could be changed such that it always
>> pulls from the remote specified in that option.
>>
>> This would help make the behaviour consistent in all the cases you
>> mentioned, while also giving the option for a user to update the
>> submodule from the remote of their choice (which may not be origin).
> 
> I like that solution. 

I also think a new config is a good solution.

> Although, I should note that if the user has set
> submodule.<name>.remote to something other than 'origin', they will need
> to ensure that submodule.<name>.branch is also set, or they will still
> hit the "Unable to find current <remote>/HEAD revision in submodule"
> error that I initially stumbled on.
> 
> How about an implementation like the following? I introduced a new "git
> submodule--helper" command rather than modify "print-default-remote" for
> a couple of reasons:
> 
> 1) "print-default-remote" is also used for "git submodule sync" (I'm not
> sure if we should change its behaviour too)
> 
> 2) "print-default-remote" needs to be executed from within the
> submodule, and takes no arguments, whereas I need to parse the
> superproject's .git/config so need to be executed from the superproject
> and take the submodule path as an argument
> 
> The two functions I added are heavily based on "git submodule--helper
> remote-branch". However:
> 
> * Unlike with the branch name, I don't fall back to using the name for
> the remote cached from when we read the .gitmodules file, if it isn't
> found in .git/config. It doesn't make sense to me for the .gitmodules
> file to include this information, as any new clones will only contain
> "origin" remotes anyway.
> 
> * I removed "struct strbuf sb" since I don't think it's used.
> 
> Ben

I think that we would want to careful examine every use of 'get_default_remote'
(and the NEEDSWORK in submodule.c:get_next_submodule)
and decide for each one if it makes sense to respect that new config before failing
back to 'origin'. So I'm not sure about the approach here since it just fixes the behaviour
for 'git submodule update --remote' but not other scenarios where the user would like
another remote than 'origin' to be used for some operations in the submodule.

There was also another bug report recently [1] around the new 'clone.defaultRemoteName'
config and 'git submodule update --remote', so it might be good to also keep that in
mind when working on a solution.

Cheers,

Philippe.
P.S. I've CC'ed Emily who has plans for a big overhaul of submodule functionality
over the next months [2] so might be interested.

[1] https://lore.kernel.org/git/2d58fe40-9e8c-4653-8170-5411fd3cf6f4@www.fastmail.com/t/#u
[2] https://lore.kernel.org/git/0fc5c0f7-52f7-fb36-f654-ff5223a8809b@gmail.com/t/#u

  parent reply	other threads:[~2021-05-22 19:15 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-14 18:11 Bug in git submodule update --remote Ben Avison
2021-05-19 10:49 ` Atharva Raykar
2021-05-19 14:41   ` Ben Avison
2021-05-21 11:47     ` Atharva Raykar
2021-05-21 18:36       ` Christian Couder
2021-05-22 19:15     ` Philippe Blain [this message]
2021-05-19 11:19 ` Atharva Raykar
2021-05-22 18:02 ` Philippe Blain

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

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ae3baa2a-2f30-8e8a-f3cf-d8210e7225b0@gmail.com \
    --to=levraiphilippeblain@gmail.com \
    --cc=bavison@riscosopen.org \
    --cc=christian.couder@gmail.com \
    --cc=emilyshaffer@google.com \
    --cc=git@vger.kernel.org \
    --cc=periperidip@gmail.com \
    --cc=raykar.ath@gmail.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.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

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 read-only IMAP folder(s) and NNTP newsgroup(s).