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

git submodules implementation question

From
USUma Srinivasan <usrinivasan@twitter.com>
Date
Aug 28, 2016, 23:24 UTC
Message-ID
<CAN5XQftQH8B+hWVh4JQgZwAp+rkbz51P5NZDc_+Tfm0EB1zkew@mail.gmail.com>
Hi,

I am new to git source and internal development. Recently I've been looking at a problem where issuing "git status" in a corrupted workspace handed over to me by a user, forks several thousand child processes recursively.

The symptoms of the corrupted workspace to reproduce this problem are as follows:

there needs to be an entry in the index file that looks something like this.... 0 groc 160000 0 0.000000000

Also, there's a subdirectory under the source dir with the name in the index file above (i.e 'groc') that has a partially populated .git sub directory within it, not a .git file with the contents providing a link to the module subdirectory.

The "git submodule status" command returns "No submodule mapping found in .gitmodules for path 'groc'"

Doing a "git read-tree HEAD" will regenerate the index file and make the problem go away. Basically the line entry above relating to 'groc' goes away as it is not a submodule in the source repo.

This problem can be reproduced with all current versions of GIT including 2.4, 2.8 and the latest version v2.10.0-rc1.

In looking into the git source code for is_submodule_modified() which forks off the new child process, I see the following lines in submodule.c:

git_dir = read_gitfile(buf.buf); if (!git_dir)

                git_dir = buf.buf;

Can anyone explain to me why we are replacing a failed reading of a git file with the original sub directory name? When can we expect a .git directory under a submodule?

Thanks, Uma

Next: Junio C Hamano
Message 1 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.