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

Re: [PATCH] push: do not add submodule odb as an alternate when recursing on demand

From
Heiko Voigt <hvoigt@hvoigt.net>
Date
Aug 16, 2017, 16:35 UTC
Message-ID
<20170816163554.GA4683@book.hvoigt.net>
In-Reply-To
<CAGZ79kZAkdiKHUweQK6U4dqAakfzReDMfiHKDmzsKGuAH3BgyA@mail.gmail.com>
Hi,

was about to write that we are maybe overly cautious here. Because the current way a submodule ends up in the list to be pushed is through:

    find_unpushed_submodules()

that itself collects all changed submodules when submodule_needs_pushing() is true. In there we have this:

    if (!submodule_has_commits(path, commits))
        /*
         * NOTE: We do consider it safe to return "no" here. The
         * correct answer would be "We do not know" instead of
         * "No push needed", but it is quite hard to change
         * the submodule pointer without having the submodule
         * around. If a user did however change the submodules
         * without having the submodule around, this indicates
         * an expert who knows what they are doing or a
         * maintainer integrating work from other people. In
         * both cases it should be safe to skip this check.
         */
        return 0;

So if the check, whether a submodule has commits, fails for any reason it will not end up in the list to be pushed.

As a side note: inside submodule_has_commits() there is an add_submodule_odb() followed by a process to really make sure that the commits are in the submodule.

So IMO at this point we can be sure that the *database* exists and this extra check could be dropped if we said that a caller to push_submodule() should make sure that the submodule exists. The current ones are doing it already (if I did not miss anything).

On Tue, Aug 15, 2017 at 06:05:25PM -0700, Stefan Beller wrote:
Show 25 quoted lines
> On Tue, Aug 15, 2017 at 5:11 PM, Junio C Hamano <gitster@pobox.com> wrote:
> > Stefan Beller <sbeller@google.com> writes:
> >
> >>> Is "is it populated" a good thing to check here, though?  IIRC,
> >>> add-submodule-odb allows you to add the object database of an
> >>> inactivated submodule, so this seems to change the behaviour.  I do
> >>> not know if the behaviour change is a good thing (i.e. bugfix) or
> >>> not (i.e. regression) offhand, though.
> >>
> >> Good point, we should be able to push non-populated, even inactive(?)
> >> submodules. For that we strictly need add_submodule_odb here
> >> (or the repo object of the submodule, eventually).
> >>
> >> So let's retract this patch for now.
> >
> > Not so fast.
> 
> Ok, I took another look at the code.
> 
> While we may desire that un-populated submodules can be pushed
> (due to checking out another revision where the submodule
> doesn't exist, before pushing), this is not supported currently, because
> the call to run the push in the submodule assumes there is a
> "<path>/.git" on which the child process can operate.
> So for now we HAVE to have the submodule populated.

That is a good point though. In the current form of push_submodule() we need to have a populated submodule. So IMO to check whether the submodule is actually *populated* instead of adding the odb is correct and a possible bug fix.

Cheers Heiko
Previous: Stefan Beller
Message 20 of 20 in “submodule: use cheaper check for submodule pushes”
  1. submodule: use cheaper check for submodule pushesStefan Beller, Jul 12, 2017
  2. Jonathan NiederJul 13, 2017
  3. Stefan BellerJul 13, 2017
  4. Junio C HamanoJul 13, 2017
  5. Stefan BellerJul 13, 2017
  6. Junio C HamanoJul 13, 2017
  7. Stefan BellerJul 13, 2017
  8. Jonathan NiederJul 13, 2017
  9. Stefan BellerJul 13, 2017
  10. push: do not add submodule odb as an alternate when recursing on demandStefan Beller, Aug 15, 2017
  11. Jonathan NiederAug 15, 2017
  12. Jonathan NiederAug 15, 2017
  13. Stefan BellerAug 15, 2017
  14. Junio C HamanoAug 15, 2017
  15. Stefan BellerAug 15, 2017
  16. Junio C HamanoAug 16, 2017
  17. Stefan BellerAug 16, 2017
  18. Jonathan NiederAug 16, 2017
  19. Stefan BellerAug 16, 2017
  20. Heiko VoigtAug 16, 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.