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

Re: [RFD] Long term plan with submodule refs?

From
Jacob Keller <jacob.keller@gmail.com>
Date
Nov 9, 2017, 06:54 UTC
Message-ID
<CA+P7+xpTCHHNG1tAhysOFV5jFHpXdzRk5zfYNHUUVdYiGY55cA@mail.gmail.com>
In-Reply-To
<20171109001007.11894-1-sbeller@google.com>
On Wed, Nov 8, 2017 at 4:10 PM, Stefan Beller <sbeller@google.com> wrote:
Show 7 quoted lines
>> The relationship is indeed currently useful, but if the long term plan
>> is to strongly discourage detached submodule HEAD, then I would think
>> that these patches are in the wrong direction. (If the long term plan is
>> to end up supporting both detached and linked submodule HEAD, then these
>> patches are fine, of course.) So I think that the plan referenced in
>> Junio's email (that you linked above) still needs to be discussed.
>
Show 29 quoted lines
> New type of symbolic refs
> =========================
> A symbolic ref can currently only point at a ref or another symbolic ref.
> This proposal showcases different scenarios on how this could change in the
> future.
>
> HEAD pointing at the superprojects index
> ----------------------------------------
> Introduce a new symbolic ref that points at the superprojects
> index of the gitlink. The format is
>
>   "repo:" <superprojects gitdir> '\0' <gitlink-path> '\0'
>
> Just like existing symrefs, the content of the ref will be read and followed.
> On reading "repo:", the sha1 will be obtained equivalent to:
>
>     git -C <superproject> ls-files -s <gitlink-path> | awk '{ print $2}'
>
> Ref write operations driven by the submodule, affecting symrefs
>   e.g. git checkout <other branch> (in the submodule)
>
> In this scenario only the HEAD is optionally attached to the superproject,
> so we can rewrite the HEAD to be anything else, such as a branch just fine.
> Once the HEAD is not pointing at the superproject any more, we'll leave the
> submodule alone in operations driven by the superproject.
> To get back on the superproject branch, we’d need to invent new UX, such as
>    git checkout --attach-superproject
> as that is similar to --detach
>

Some of the idea trimmed for brevity, but I like this aspect the most. Currently, I work on several projects which have multiple repositories, which are essentially submodules.

However, historically, we kept them separate. 99% of the time, you can use all 3 projects on "master" and everything works. But if you go back in time, there's no correlation to "what did the parent project want this "COMMON" folder to be at?

I started promoting using submodules for this, since it seemed quite natural.

The core problem, is that several developers never quite understood or grasped how submodules worked. There's problems like "but what if I wanna work on master?" or people assume submodules need to be checked out at master instead of in a detached HEAD state.

So we often get people who don't run git submodule update and thus are confused about why their submodules are often out of date. (This can be solved by recursive options to commands to more often recurse into submodules and checkout and update them).

We also often get people who accidentally commit the old version of the repository, or commit an update to the parent project pointing the submodule at some commit which isn't yet in the upstream of the common repository.

The proposal here seems to match the intuition about how submodules should work, with the ability to "attach" or "detach" the submodule when working on the submodule directly.

Ideally, I'd like for more ways to say "ignore what my submodule is checked out at, since I will have something else checked out, and don't intend to commit just yet."

Basically, a workflow where it's easier to have each submodule checked out at master, and we can still keep track of historical relationship of what commit was the submodule at some time ago, but without causing some of these headaches.

I've often tried to use the "--skip-worktree" bit to have people set their repository to ignore the submodule. Unfortunately, this is pretty complex, and most of the time, developers never remember to do this again on a fresh clone.

Thanks, Jake

Previous: Stefan BellerNext: Stefan Beller
Message 12 of 16 in “git-status reports relation to superproject”
  1. 0/4 git-status reports relation to superprojectStefan Beller, Nov 8, 2017
  2. 1/4 remote, revision: factor out exclusive counting between two commitsStefan Beller, Nov 8, 2017
  3. 3/4 submodule.c: get superprojects gitlink valueStefan Beller, Nov 8, 2017
  4. 4/4 git-status: report reference to superprojectStefan Beller, Nov 8, 2017
  5. 2/4 submodule.c: factor start_ls_files_dot_dot out of get_superproject_working_treeStefan Beller, Nov 8, 2017
  6. Jonathan TanNov 8, 2017
  7. [RFD] Long term plan with submodule refs?Stefan Beller, Nov 9, 2017
  8. Jonathan TanNov 9, 2017
  9. Junio C HamanoNov 9, 2017
  10. Junio C HamanoNov 9, 2017
  11. Stefan BellerNov 9, 2017
  12. Jacob KellerNov 9, 2017
  13. Stefan BellerNov 9, 2017
  14. Jacob KellerNov 10, 2017
  15. Stefan BellerNov 10, 2017
  16. Jacob KellerNov 11, 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.