Subject: Re: [RFC PATCH 0/2] Teach fetch and pull to recursively fetch submodules too

From: Jens Lehmann <[email-masked]>
Date: Wed, 15 Sep 2010 13:32:46 +0200

Am 15.09.2010 02:18, schrieb Kevin Ballard:
> The first is `git remote update`, which I am fond of using, causes buggy behavior where it fetches all submodules twice.

I'll look into that, fetching the same submodule twice should not
happen. (But I'm not sure what you mean by "buggy behavior where it
fetches all submodules twice" though, is there something else going
wrong?)

> The second is this submodule fetch doesn't appear to be recursive.

That is strange as fetch now executes a 'git fetch' inside each
populated submodule, which should automagically recurse. So I assume
that you don't have a .gitmodules file inside your first level of
submodules which describes the deeper nested ones?

> The third issue is `git fetch` doesn't have any business fetching submodules when the submodule reference was never changed as part of the fetch, especially if the main fetch itself didn't even find any changes. It seems to me that the correct behavior would be to look at all the fetched commits to see if any of them change the submodule reference, and only in that case should it automatically fetch any submodules whose references were modified. The stated desire of avoiding "(commits not present)" when doing a diff will still be met, but it will avoid slowing down the normal case of a `git fetch`.

I was thinking about implementing that optimization too but came to
the conclusion that you always have to fetch submodules too no matter
if the superproject has any new commits fetched for them. Because
when you don't do that you wouldn't get a chance to test and commit
e.g. a new feature added by a colleague in a submodule and pushed by
him, as that would not be fetched into your repo before it was
committed inside the superproject. That leads to a 'chicken or the
egg' problem.

> It also seems like there ought to be a config variable one can set for the default behavior if submodule.<name>.fetch is not present in .gitmodules or in .git/config.

I'll take this as a 'yes' to my question if such an option is wanted.

In your other mail you wrote that the output of the recursive fetch
does not prepend the names of the higher level submodules. I did not
think about that and will post a fix for that problem soon.

Thanks for your feedback!