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

Re: Feature Request: Branch-Aware Submodules

From
Stefan Beller <sbeller@google.com>
Date
Aug 25, 2016, 17:45 UTC
Message-ID
<CAGZ79kbHfofmowHnwzFrumc1XJHE=ZMQEwNSeOSyF7YDG+aSjw@mail.gmail.com>
In-Reply-To
<7B5AD16B-9729-453E-839C-2A2FDB07F8E9@student.ethz.ch>
+cc Jacob and Lars who work with submodules as well.

On Thu, Aug 25, 2016 at 2:00 AM, Hedges Alexander <ahedges@student.ethz.ch> wrote:

Show 6 quoted lines
>
> Right now updating a submodule in a topic branch and merging it into master
> will not change the submodule index in master leading to at least two commit
> for the same change (one in any active branch). This happened to me quite a few
> times. To a newcomer this behavior is confusing and it leads to unnecessary
> commits.
So you roughly do
    git checkout -b new-topic
    # change the submodule to point at the latest upstream version:
    git submodule update --remote <submodule-path>
    git commit -a -m "update submodule"
    git checkout master
    git merge new-topic
    # here seems to be your point of critic?
    # now the submodule pointer would still point to the latest
upstream version?
Show 9 quoted lines
>
>
> The proposed change would be to have a submodule either ignored or tracked by
> the .gitmodules file.
> If it is ignored, as for instance after a clone of the superproject, git simply
> ignores all files in the submodule directory. The content of the gitmodules
> file is then also not updated by git.
> If it is not ignored, the .gitmodules is updated every time a commit happens in
> the submodule.
So
    git -C <submodule-path> commit

should trigger a commit in the superproject as well, that changes the gitmodules file? What do you record in the git modules file that needs updating? As the version is tracked via the gitlink entry, I do not see the information that needs tracking here?

> On branch switches the revision shown in the gitmodules from
> that branch is checked out.

So you are proposing to put the revision into the gitmodules file? That would be redundant with the actual gitlink entry in your tree. (as shown via `git submodule status`) What would happen if the recorded revision in the gitmodules file and the gitlink are out of sync?

Oh, are you just proposing to actually make `git checkout` aware of the submodules? See[1]. I would welcome such a change and be happy th

[1] https://github.com/jlehmann/git-submod-enhancements which has some attempts for checkout including the submodules. I also tried writing some patches which integrate checking out submodules via checkout as well. A quicker `solution` would be a config option that just runs `git submodule update` after each checkout/pull etc.

Show 6 quoted lines
> This change would have submodules conceptually behave more like files to the
> superproject.
>
>
> Like current behavior, git status would display whether the submodule has
> uncommitted changes or is at a new commit.
See config options diff.submodule and status.submoduleSummary.
Show 5 quoted lines
>
> I couldn't find any discussions on the initial implementation of git-submodule
> or any previous proposals related to this in nature due to gmane being down
> right now and the mailing list archives on the other sites are not great for
> searching. So please excuse me if I'm bringing up already discussed stuff.
https://public-inbox.org/git for reading on the web, or
    git clone https://public-inbox.org/git
for reading offline.
Show 6 quoted lines
>
> Until now I only worked on projects with few submodules. I expect the
> proposed changes to have a larger effect on projects containing lots of
> submodules. So it would be nice if maybe somebody with experience working on
> projects with lots of submodules could weigh into the discussion.
>
Previous: Hedges AlexanderNext: Junio C Hamano
Message 2 of 6 in “Feature Request: Branch-Aware Submodules”
  1. Hedges AlexanderAug 25, 2016
  2. Stefan BellerAug 25, 2016
  3. Junio C HamanoAug 25, 2016
  4. Stefan BellerAug 25, 2016
  5. Junio C HamanoAug 25, 2016
  6. Junio C HamanoAug 25, 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.