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

Re: [PATCH 0/5] Some submodule bugfixes and "reattaching detached HEADs"

From
Stefan Beller <sbeller@google.com>
Date
May 31, 2017, 22:09 UTC
Message-ID
<CAGZ79kYEGQit+7Dqs7ggzRMq9y=pHFhpn-Spk3zVw2ffsc2nXw@mail.gmail.com>
In-Reply-To
<CAGZ79kb52QDUG0RtTXNEEpMJR1CSMYMrRHTRRvGn0-cF=HnzWw@mail.gmail.com>
On Mon, May 1, 2017 at 9:04 PM, Stefan Beller <sbeller@google.com> wrote:
Show 8 quoted lines
>>
>>> I don't know why submodules were originally designed to be in a
>>> detached HEAD state but I much prefer working on branches (as I'm sure
>>> many other developers do) so the prospect of this becoming the norm is
>>> exciting! :D
>>
>
> I'll think about this more.

What the current model is missing is the possibility to have a symbolic link not just to a ref within a repository, but to the outside of a repository (such as the superproject in this case).

So we could have a HEAD with a content like:
    "super: <superprojects git dir> [LF <path inside superproject>]"

Then we would use the HEAD to determine if the superproject would touch a submodule at all. Example workflow:

    git -C <sub> checkout --reattach-to-superproject
    # hack away in the submodule
    # This will make a commit in <sub> and add the
    # resulting object to the index of the superproject
    # because HEAD is tracking the superproject.
    # so in order to have HEAD containing the new
    # commit we have to change the superproject:
    git -C <sub> commit -a -m "message"
    # This has also interesting consequences for
    # submodule related commands:
    git checkout --recurse-submodules <tree-ish>
    # Any submodule whose HEAD is attached to the
    # superproject would be touched, the others would
    # not.

By being directly attached to the superproject, it would be easy to find all submodules that are changed, via a

    git -C <super> status # no need to recurse, even!

The whole "checkout --recurse-submodules" series is based on assumptions of the current mental model of how branches and detached HEADs work.

A submodule would have a symref
Previous: Stefan BellerNext: Stefan Beller
Message 17 of 22 in “Some submodule bugfixes and "reattaching detached HEADs"”
  1. 0/5 Some submodule bugfixes and "reattaching detached HEADs"Stefan Beller, May 1, 2017
  2. 1/5 submodule_move_head: fix leak of struct child_processStefan Beller, May 1, 2017
  3. Brandon WilliamsMay 1, 2017
  4. Junio C HamanoMay 2, 2017
  5. Stefan BellerMay 2, 2017
  6. 3/5 submodule: avoid auto-discovery in new working tree manipulator codeStefan Beller, May 1, 2017
  7. 2/5 submodule_move_head: prepare env for child correctlyStefan Beller, May 1, 2017
  8. Junio C HamanoMay 2, 2017
  9. Stefan BellerMay 2, 2017
  10. 4/5 submodule--helper: reattach-HEADStefan Beller, May 1, 2017
  11. Brandon WilliamsMay 1, 2017
  12. Stefan BellerMay 1, 2017
  13. 5/5 submodule_move_head: reattach submodule HEAD to branch if possible.Stefan Beller, May 1, 2017
  14. Brandon WilliamsMay 1, 2017
  15. Junio C HamanoMay 2, 2017
  16. Stefan BellerMay 2, 2017
  17. Stefan BellerMay 31, 2017
  18. 0/3 Some submodule bugfixesStefan Beller, May 2, 2017
  19. 1/3 submodule_move_head: reuse child_process structure for futher commandsStefan Beller, May 2, 2017
  20. 2/3 submodule: avoid auto-discovery in new working tree manipulator codeStefan Beller, May 2, 2017
  21. 3/3 submodule: properly recurse for read-tree and checkoutStefan Beller, May 2, 2017
  22. Brandon WilliamsMay 2, 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.