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

Re: [PATCH] submodules: allow empty working-tree dirs in merge/cherry-pick

From
Stefan Beller <sbeller@google.com>
Date
Nov 7, 2016, 20:48 UTC
Message-ID
<CAGZ79kb8XM_j37H-j3fUz9a0DFXn_v+S4P4r-QyuQOKM3xqhRw@mail.gmail.com>
In-Reply-To
<378e63aa70e54fe9b839acf90680917a@exmbdft7.ad.twosigma.com>
On Mon, Nov 7, 2016 at 12:38 PM, David Turner <David.Turner@twosigma.com> wrote:
Show 45 quoted lines
>> -----Original Message-----
>> From: Stefan Beller [mailto:sbeller@google.com]
>> Sent: Monday, November 07, 2016 2:14 PM
>> To: David Turner
>> Cc: git@vger.kernel.org
>> Subject: Re: [PATCH] submodules: allow empty working-tree dirs in
>> merge/cherry-pick
>>
>> On Mon, Nov 7, 2016 at 10:31 AM, David Turner <dturner@twosigma.com>
>> wrote:
>> > When a submodule is being merged or cherry-picked into a working tree
>> > that already contains a corresponding empty directory, do not record a
>> > conflict.
>> >
>> > One situation where this bug appears is:
>> >
>> > - Commit 1 adds a submodule
>>
>> "... at sub1" as inferred by text below.
>>
>> > - Commit 2 removes that submodule and re-adds it into a subdirectory
>> >        (sub1 to sub1/sub1).
>> > - Commit 3 adds an unrelated file.
>> >
>> > Now the user checks out commit 1 (first deinitializing the submodule),
>> > and attempts to cherry-pick commit 3.  Previously, this would fail,
>> > because the incoming submodule sub1/sub1 would falsely conflict with
>> > the empty sub1 directory.
>>
>> So you'd want to achieve:
>>   $ # on commit 3:
>>   git checkout <commit 1>
>>   git cherry-pick <commit 3>
>>
>> which essentially moves the gitlink back to its original place (from
>> sub1/sub1 -> sub1).  This sounds reasonable.
>> But what if the submodule contains a (file/directory) named sub1? We'd
>> first remove the sub1/sub1 submodule (and even delete the inner
>> directory?), such that "sub1/"
>> becomes an empty dir, which is perfect for having a submodule right there
>> at "sub1/"
>
> I'm confused about the "what if" here.
>
> In our particular situation, the submodule in question was not initialized.

oops. That explains it. I somehow assumed we were talking about initialized submodules.

>
> If your approach also fixes the same tests that mine fixes, then I am happy to use your series over mine.  Please CC me so I can take a peek.

No, my series seems to be orthogonal to this one. I plan on cc'ing you nevertheless as it is still nearby.

> basically nobody needs two copies of one submodule in the same repo.

IIRC this is how gitlinks were used in very early days :/ (kernel people were using gitlinks to track different kernel versions and see if they were interoperable or working at all. e.g. see d92a39590d1126e195f1bbccf182a2cdb79218e7, which only makes sense (for the update command) if the referenced repository contains references of all submodules, which either means a huge reference pile that contains different projects at the same time, or the same project at different versions.

>  I think that case fails for other reasons anyway.
>

Yes. I agree that the patch as-is is applicable. I did not try to oppose your approach, but rather give some thoughts I had.

Stefan
Previous: David TurnerNext: Junio C Hamano
Message 4 of 5 in “submodules: allow empty working-tree dirs in merge/cherry-pick”
  1. submodules: allow empty working-tree dirs in merge/cherry-pickDavid Turner, Nov 7, 2016
  2. Stefan BellerNov 7, 2016
  3. David TurnerNov 7, 2016
  4. Stefan BellerNov 7, 2016
  5. Junio C HamanoNov 18, 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.