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

Re: Integrating submodules with no side effects

From
Stefan Beller <sbeller@google.com>
Date
Oct 19, 2016, 19:45 UTC
Message-ID
<CAGZ79kZWaShG9iG565bD3aVYFcb53+opbpnJH-v3G6hrQL2tzA@mail.gmail.com>
In-Reply-To
<CAHd499D_fehBHsNdH9PLQj+H_WAJqbbMhDwv_nCT3fZcX60ENA@mail.gmail.com>

On Wed, Oct 19, 2016 at 12:19 PM, Robert Dailey <rcdailey.lists@gmail.com> wrote:

Show 21 quoted lines
> On Wed, Oct 19, 2016 at 11:23 AM, Stefan Beller <sbeller@google.com> wrote:
>> You could try this patch series:
>> https://github.com/jlehmann/git-submod-enhancements/tree/git-checkout-recurse-submodules
>> (rebased to a newer version; no functional changes:)
>> https://github.com/stefanbeller/git/tree/submodule-co
>> (I'll rebase that later to origin/master)
>>
>>>
>>> Do you have any info on how I can prevent that error? Ideally I want
>>> the integration to go smoothly and transparently, not just for the
>>> person doing the actual transition (me) but for everyone else that
>>> gets those changes from upstream. They should not even notice that it
>>> happened (i.e. no failed commands, awkward behavior, or manual steps).
>>
>> It depends on how long you want to postpone the transition, but I plan to
>> upstream the series referenced above in the near future,
>> which would enable your situation to Just Work (tm). ;)
>
> At first glance, what you've linked to essentially looks like
> automated `git submodule update` for every `git checkout`. Am I
> misunderstanding?

Essentially yes, except with stricter rules than the actual submodule update IIRC.

>
> If I'm correct, this is not the same as what I'm talking about. The
> problem appears to be more internal: When a submodule is removed, the
> physical files that were there are not removed by Git.

That is also done by that series: submodules ought to be treated as files: If you checkout a new version where a file is deleted, the checkout command will actually remove the file for you (and e.g. solve any directory/file conflicts that may happen in the transition.)

> It leaves them
> there in the working copy as untracked files.
That is the current behavior as checkout tries hard to ignore submodules.
Show 12 quoted lines
> The next step Git takes
> (again, just from outside observation) is to add those very same files
> to the working copy, since they were added to a commit. However, at
> this point Git fails because it's trying to create (write) files to
> the working copy when an exact file of that name already exists there.
> Git will not overwrite untracked files, so at this point it fails.
>
> What needs to happen, somehow, is Git sees that the files were
> actually part of a submodule (which was removed) and remove the
> physical files as well, assuming that they were not modified in the
> submodule itself. This will ensure that the next step (creating the
> files) will succeed since the files no longer block it.
Yep.
Previous: Robert DaileyNext: Robert Dailey
Message 6 of 8 in “Integrating submodules with no side effects”
  1. Robert DaileyOct 18, 2016
  2. Stefan BellerOct 18, 2016
  3. Robert DaileyOct 19, 2016
  4. Stefan BellerOct 19, 2016
  5. Robert DaileyOct 19, 2016
  6. Stefan BellerOct 19, 2016
  7. Robert DaileyOct 19, 2016
  8. Robert DaileyOct 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.