Subject: Re: [PATCH v3] submodule: teach set-url subcommand

From: Denton Liu <[email-masked]>
Date: Wed, 30 Oct 2019 10:58:17 -0700

Hi Junio,

On Wed, Oct 30, 2019 at 02:54:58PM +0900, Junio C Hamano wrote:
> Denton Liu <[email-masked]> writes:
> 
> > Currently, in the event that a submodule's upstream URL changes, users
> > have to manually alter the URL in the .gitmodules file then run
> > `git submodule sync`. Let's make that process easier.
> 
> Right now, submodule.<name>.url might be the only thing that gets
> synched down to .git/config of the submodule; we may not learn any
> more things that needs "edit in .gitmodules and then run sync".  Can
> we sately say that "sync" is now obsolete and what it has been used
> for can now be done with "set-url"?  In other words, does "set-url"
> makes "sync" unnecessary and deprecated?

"sync" isn't deprecated quite yet. If upstream edits the .gitmodules and
we pull in the change, then we still need to run "sync" to update our
.git/config.

> 
> Or is it expected that we would learn more things end users can edit
> in .gitmodules and run sync to propagate necessary pieces of
> information down?  If so, do we want to add an extra command like
> set-url for each of these new things, or do we tell users "if you
> are editing url, use set-url, otherwise edit .gitmodules and run
> sync"?  If the former, that would make the set of subcommands quite
> noisy, and if the latter, the users need to learn two things,
> i.e. it is not making it easier but harder to learn the system.

I was running under the assumption that we weren't planning on adding
new information to .gitmodules. I don't think we'll be making changes to
the submodule file format without careful thought so _if_ that ever
comes up, we should discuss it then but I don't think it's a discussion
that's going to happen any time soon, if ever.

Either way, though, the sync workflow isn't going away so users still
need to know how to do that (unfortunately). We'll just add a
convenience function on top to make people's lives easier but it's not
strictly _necessary_ to use "set-url".

> 
> There is nothing _wrong_ to introduce the new subcommand per-se, but
> given that the URL should not change that often, and due to above
> concerns, I am not sure if I want to back this change.

I think it changes often enough to cause problems. Seems like at least
936 people on StackOverflow agree with me[1].

I think that the problem is that it's a common enough use-case but not
common enough that people often forget to "sync" after editing the
.gitmodules. I know that it's bitten me the few times I've done this and
I've had to go back to that SO post each time.

[1]: https://stackoverflow.com/questions/913701/how-to-change-the-remote-repository-for-a-git-submodule