git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: Should "git submodule update" accepts --init?

From
Nazri Ramliy <ayiehere@gmail.com>
Date
May 11, 2017, 07:59 UTC
Message-ID
<CAEY4ZpO108t=2TxmzeFrzHxeXzJ3V_MGv+fy2gH-ZtOXfP8zUw@mail.gmail.com>
In-Reply-To
<xmqqk25nc2s9.fsf@gitster.mtv.corp.google.com>
On Thu, May 11, 2017 at 2:42 PM, Junio C Hamano <gitster@pobox.com> wrote:
Show 6 quoted lines
> I am not a heavy submodule user so what I think may not count, but I
> think the "upstream" changing the URL of the submodule should be a
> rare and notable event.  Making it easy to automatically run "sync"
> without thinking would be a huge mistake---it will make it likely
> for users to blindly follow what the upstream has in .gitmodules
> without checking if the new URL is sensible.

Yes that would be a mistake for the case when we don't trust upstream. But for the case that we do trust upstream, I would argue that we should always follow what upstream told us to use when it comes to getting the content of the submodule.

Show 5 quoted lines
> Also doesn't "submodule sync" blindly overwrite URL, even the ones
> that you tweaked in your configuration to override to point at a
> mirror that is closer to you than the one suggested in .gitmodules?
> If that is the case, sucn a change to make it easier to run "sync"
> without thinking is doubly bad, I would think.

For such use cases I would suggest using url.<pattern>.insteadOf, instead of changing what submodule.<name>.url.

My recent use case that prompted this question (I just realized that I typo'ed the mail subject s/--init/--sync/) is this:

We are using git submodule for vendoring our Go dependencies. We've been using it since 2015 and it has been great for this role. There comes a time when we have to patch the vendored version so we do what is normally done - we fork the code at github and made a pull request. This pull request may get rejected, or accepted. For the latter case it may take some time for the acceptance to happen - upstream owner may be away, or there are some cosmetic changes needed etc, while on our side we need the changes in place for our build (and on developer machines) to succeed so that it can be used in production (after testing it in our staging). It is during this time that we want to switch the submodule url (upstream github repo) to point to another submodule url (our github repo)

Hmm after writing all of the above I wonder if we can't just use url.<pattern>.insteadOf to achieve this. But then url.<pattern>.insteadOf feels less official than submodule.name.<url> so that's another point to think about.

nazri
Previous: Junio C Hamano
Message 3 of 3 in “Should "git submodule update" accepts --init?”
  1. Nazri RamliyMay 11, 2017
  2. Junio C HamanoMay 11, 2017
  3. Nazri RamliyMay 11, 2017

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.