git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Jens Lehmann <Jens.Lehmann@web.de>
To: Stefan Beller <sbeller@google.com>
Cc: "git@vger.kernel.org" <git@vger.kernel.org>,
	Junio C Hamano <gitster@pobox.com>,
	Jonathan Nieder <jrnieder@gmail.com>,
	Sebastian Schuberth <sschuberth@gmail.com>
Subject: Re: [RFC/PATCH 0/5] [WAS: Submodule Groups] Labels and submodule.autoInitialize
Date: Tue, 26 Jan 2016 21:59:24 +0100	[thread overview]
Message-ID: <56A7DE2C.3020308@web.de> (raw)
In-Reply-To: <CAGZ79kY1Wa7kHh7GaCTAAmyaRgrT4_91XLaHZFrko9umEbNYkw@mail.gmail.com>

Am 25.01.2016 um 19:59 schrieb Stefan Beller:
> On Sun, Jan 24, 2016 at 11:38 AM, Jens Lehmann <Jens.Lehmann@web.de> wrote:
>> Am 23.01.2016 um 01:31 schrieb Stefan Beller:
>>>
>>> This series introduces labels which you can attach to submodules like so:
>>>
>>>       $ cat .gitmodules
>>>       [submodule "gcc"]
>>>           path = gcc
>>>           url = git://...
>>>           label = default
>>>           label = devel
>>>       [submodule "linux"]
>>>           path = linux
>>>           url = git://...
>>>           label = default
>>>
>>>       $ git submodule add --name emacs --label "editor" --label default
>>> git://...
>>>
>>>       # If upstream has submodules properly labeled, you can make use of
>>> them:
>>
>>
>> Cool. Without having looked at the code I assume you also can label
>> submodules yourself in .git/config (or your global config) to override
>> upstream's settings (or use your own labels if .gitmodules does not
>> contain any)?
>
> I am not sure. I'll add a test for that in a reroll and make sure it passes.

Thanks.

>>
>>>       $ git config --add submodule.autoInitialize "*default"
>>>       $ git config --add submodule.autoInitialize ":name"
>>>       $ git config --add submodule.autoInitialize "./by/path"
>>
>>
>> Ok. Though we might wanna call it submodule.autoUpdate, as initializing
>> it is only the prerequisite for automatically updating submodules. And
>> I believe automatically updating is the thing we're after here, right?
>
> I am not sure here, too. I would not mind an occasional "git submodule update"
> for whenever I want upstream to come down on my disk.
 >
> However that's what I
> do with "git pull" in the non-submodule case, so you'd expect git pull to
> also run the update strategies for all submodules which are configured to
> autoUpdate?
>
> That makes sense to me. Though I never use "git pull" to begin with.
> I always use fetch and see how to go from there (merge or rebase
> after inspecting the code I fetched). That would mean we want to
> add the autoUpdate strategy to merge/rebase and the fetching of
> submodules to the fetch command?

Hmm, maybe autoUpdate promises too much. After all this config is
just about which submodules are chosen to be updated on clone and
submodule update, not on all the other work tree manipulating
commands.

And it's similar to what sparse does. So what about calling that
"submodule.updateSparse"? Or maybe "submodule.sparseCheckout"?
Suggestions welcome.

>> I'll try to explain why I believe we should be generous in initializing
>> submodules: If a submodule in one branch has a label configured to be
>> automatically updated and hasn't got the same label in another branch,
>> we still need to initialize the submodule even when we are on the latter
>> branch in case the user switches to the first branch, right?
>
> No. "git checkout" ought to autoInitalize the submodule in question when
> switching branches. I don't want to see initialized, but unused submodules
> around (neither empty dirs nor in the .git/config ideally)?

Why not? Empty dirs is what unpopulated submodules look like from day
one (and they make the user aware she cannot add a file of the same
name). And you'll see initialized, but unused submodules around every
time you switch to a branch that doesn't contain this submodule at all.

And keeping them initialized even if they aren't currently checked out
is the only way they can keep their settings when the user is switching
between branches.

>> And the
>> fetch command needs to fetch submodule changes too when they happen in
>> a branch where this submodule is part of a label group configured to be
>> updated automatically, no matter what is currently found in the work
>> tree.
>
> Right, as said above fetch needs to fetch all the submodules as well. I wonder
> if it needs to fetch all submodule sha1s only or just try to get as
> much from the
> submodule as possible.

Right now we just do a simple fetch, but only fetching the SHA-1s could
be an optimization useful for busy submodules later on.

>> So I'd propose to:
>>
>> *) Initialize every submodule present on clone or newly fetched when
>>     the autoUpdate config is set.
>
> What if you clone branch A and then switch to B ? B has a submodule which
> was not initialized in A. I do not think initializing on clone/fetch
> is the right thing
> to do, but rather the branch switching command (checkout) shall make sure
> all its autoUpdate/autoInitialze submodules are setup properly, no?

I disagree. If you init all submodules on clone/fetch you might need
to change the upstream URL right after that. You can't do that on a
subsequent branch switch which needs to initialize the submodule again,
as the former deinit did nuke that configuration.

>> *) Automatically fetch only those submodules that are changed in
>>     a commit where they have a label configured (in the commit's
>>     .gitmodules or locally) that is to be checked out.
>
> Not sure I follow here.

We could restrict fetch to not fetch everything but just those changes
needed for sparse submodule update. To be able to do that it would
have to examine the fetched superproject commits if a submodule changed
and if it is configured to be automatically updated in that commit.

>> *) Let "git submodule update" update only those submodules that
>>     have an autoupdate label configured.
>
> Why not update all initialized submodules? (In my imagination
> "all initialized submodules" are equal to "all submodules the user is
> interested in", i.e. when going from branch A to B, the checkout will
> (de-)init submodules as necessary.

And throw away any customization the user did (to the URL or other
configurations)?

Without this sparse/label/group functionality, init is the way the
user tells us he is interested in a submodule. But when configuring
a label/name/path to update, the old meaning of init is obsolete
and superseded by the new mechanism.

>> That will make switching between branches with different label
>> configurations work fine. Or am I missing something here?
>>
>> And we need to teach diff and status to complain about empty work
>> trees and missing initialization of submodules that are to be
>> automatically updated too.
>
> What about empty work trees?
>
> I'll add "git status" complaining about missing initialized submodules.

If they are to be updated on the next "git submodule update" ;-)

>>
>>>       # The prefix * denotes a label as found in .gitmodules
>>>       # : goes before names
>>>       # path are prefixed ./ currently
>>>       # both path and names need work
>>
>>
>> Question: how do I configure all submodules to be automatically
>> initialized without having to give them a label? "./*"? Or just
>> setting the option without a specific value?
>
> I'd guess ./* should do. Path wildcard patterns are not supported in this
> series, but I think it would be a viable way.

Ok.

>>>       # no --init necessary, partially initializes submodules (only those
>>> which
>>>       # were specified by label, name or path)
>>>       $ git submodule update
>>
>>
>> Yup. Just like they will be fetched if they haven't been yet they
>> should be initialized if they haven't been yet but are configured
>> to be automatically updated.
>>
>>>       # time passes, upstream may have added new submodules and we get them
>>> without
>>>       # extra commands!
>>>       $ git submodule update
>>>
>>>       # The above configuration can be given to git clone directly via:
>>>       $ git clone --init-submodule=*labelA ...
>>
>>
>> Ok. Expecially nice is the ability to also give names and paths to
>> "--init-submodule". (but maybe that option should be called
>> "--autoupdate-submodule" for the reasons stated above?)
>
> If I can understand the discussion above a bit further, I'd be happy
> to rename the option.
>
> I think we have some different opinions on when
> submodules are initialized (the invariant of what an initalized submodules
> means), and resulting from that we also have different opinions on when
> to do the (de-)init.

Yes. But I hope my arguments will convince you ;-)

  reply	other threads:[~2016-01-26 20:59 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-01-23  0:31 [RFC/PATCH 0/5] [WAS: Submodule Groups] Labels and submodule.autoInitialize Stefan Beller
2016-01-23  0:31 ` [PATCH 1/5] submodule init: Write submodule registration to stderr Stefan Beller
2016-01-23  0:31 ` [PATCH 2/5] git submodule: Teach add to label submodules Stefan Beller
2016-01-23  0:31 ` [PATCH 3/5] submodule-config: keep labels around Stefan Beller
2016-01-24 18:06   ` Sebastian Schuberth
2016-01-25 18:06     ` Stefan Beller
2016-01-23  0:31 ` [PATCH 4/5] submodule update: respect submodule.autoInitialize Stefan Beller
2016-01-23  0:31 ` [PATCH 5/5] builtin/clone: Configure submodule.autoInitialize via --init-submodule Stefan Beller
2016-01-24 19:38 ` [RFC/PATCH 0/5] [WAS: Submodule Groups] Labels and submodule.autoInitialize Jens Lehmann
2016-01-25 18:59   ` Stefan Beller
2016-01-26 20:59     ` Jens Lehmann [this message]
2016-01-26 21:50       ` Stefan Beller
2016-01-31 21:09         ` Jens Lehmann
2016-02-01 20:21           ` Stefan Beller

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=56A7DE2C.3020308@web.de \
    --to=jens.lehmann@web.de \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=jrnieder@gmail.com \
    --cc=sbeller@google.com \
    --cc=sschuberth@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).