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

Re: git submodules implementation question

From
USUma Srinivasan <usrinivasan@twitter.com>
Date
Sep 1, 2016, 19:56 UTC
Message-ID
<CAN5XQft1YFEdxcB8Q_qFG4iYmSaSX_JXDCESzeEyYqPO0BUbaw@mail.gmail.com>
In-Reply-To
<xmqqa8frwhpr.fsf@gitster.mtv.corp.google.com>
>>> The final version needs to be accompanied with tests to show the
>>> effect of this change for callers.  A test would set up a top-level
>>> and submodule, deliberately break submodule/.git/ repository and
>>> show what breaks and how without this change.
Agreed!

The repo where the original problem surfaced is huge and in fact "git status" appears to go into an infinite loop forking a zillion processes on the system. If the dev system is small, it brings it to a standstill. However, the good news is that I could build myself a smaller reproducer by doing the following:

1) mkdir sm_test
2) cd sm_test
3) git clone git://git.mysociety.org/commonlib commonlib
4) git init
5) git submodule add ./commonlib/
6) cd commonlib/.git
7) rm -f all files

After this "git status" will fork several thousand processes but it will ultimately fail as it runs into the path length max limit. I still don't know why this doesn't happen with my original problem repo. Perhaps I have to let it run overnight or perhaps it runs into other system limitations before then....

Anyway, with the fix "git status" fails quickly both in my reproducer (and original repo) with the following message..... fatal: Not a git repository: '.git' fatal: 'git status --porcelain' failed in submodule commonlib

Hope this helps.
Uma
On Thu, Sep 1, 2016 at 12:19 PM, Junio C Hamano <gitster@pobox.com> wrote:
Show 24 quoted lines
> Stefan Beller <sbeller@google.com> writes:
>
>>> The final version needs to be accompanied with tests to show the
>>> effect of this change for callers.  A test would set up a top-level
>>> and submodule, deliberately break submodule/.git/ repository and
>>> show what breaks and how without this change.
>>
>> Tests are really good at providing this context as well, or to communicate
>> the actual underlying problem, which is not quite clear to me.
>> That is why I refrained from jumping into the discussion as I think the
>> first few emails were dropped from the mailing list and I am missing context.
>
> I do not know where you started reading, but the gist of it is that
> submodule.c spawns subprocess to run in the submodule's context by
> assuming that chdir'ing into the <path> of the submodule and running
> it (i.e. cp.dir set to <path> to drive start_command(&cp)) is
> sufficient.  When <path>/.git (either it is a directory itself or it
> points at a directory in .git/module/<name> in the superproject) is
> a corrupt repository, running "git -C <path> command" would try to
> auto-detect the repository, because it thinks <path>/.git is not a
> repository and it thinks it is not at the top-level of the working
> tree, and instead finds the repository of the top-level, which is
> almost never what we want.
>
Previous: Junio C HamanoNext: Junio C Hamano
Message 30 of 31 in “git submodules implementation question”
  1. Uma SrinivasanAug 28, 2016
  2. Junio C HamanoAug 29, 2016
  3. Uma SrinivasanAug 29, 2016
  4. Junio C HamanoAug 29, 2016
  5. Uma SrinivasanAug 29, 2016
  6. Uma SrinivasanAug 29, 2016
  7. Junio C HamanoAug 29, 2016
  8. Uma SrinivasanAug 29, 2016
  9. Jacob KellerAug 30, 2016
  10. Uma SrinivasanAug 30, 2016
  11. Jacob KellerAug 30, 2016
  12. Jacob KellerAug 30, 2016
  13. Uma SrinivasanAug 30, 2016
  14. Junio C HamanoAug 30, 2016
  15. Uma SrinivasanAug 31, 2016
  16. Junio C HamanoAug 31, 2016
  17. Uma SrinivasanAug 31, 2016
  18. Junio C HamanoAug 31, 2016
  19. Uma SrinivasanAug 31, 2016
  20. Uma SrinivasanSep 1, 2016
  21. Junio C HamanoSep 1, 2016
  22. Uma SrinivasanSep 1, 2016
  23. Junio C HamanoSep 1, 2016
  24. Stefan BellerSep 1, 2016
  25. Junio C HamanoSep 1, 2016
  26. Junio C HamanoSep 1, 2016
  27. Junio C HamanoSep 1, 2016
  28. Stefan BellerSep 1, 2016
  29. Junio C HamanoSep 1, 2016
  30. Uma SrinivasanSep 1, 2016
  31. Junio C HamanoSep 1, 2016

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.