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

Re: Adding nested repository with slash adds files instead of gitlink

From
Junio C Hamano <gitster@pobox.com>
Date
Jun 19, 2018, 15:56 UTC
Message-ID
<xmqqmuvqwz07.fsf@gitster-ct.c.googlers.com>
In-Reply-To
<CACsJy8DQ-GGEDiV0iA2kTgNgHcT1sSX2Oqb7VZcjyK1nBOFv+A@mail.gmail.com>
Duy Nguyen <pclouds@gmail.com> writes:
Show 23 quoted lines
> On Tue, Jun 19, 2018 at 12:36 PM Heiko Voigt <hvoigt@hvoigt.net> wrote:
>>
>> On Mon, Jun 18, 2018 at 11:12:15AM -0700, Brandon Williams wrote:
>> > On 06/18, Duy Nguyen wrote:
>> > > This sounds like the submodule specific code in pathspec.c, which has
>> > > been replaced with something else in bw/pathspec-sans-the-index. If
>> > > you have time, try a version without those changes (e.g. v2.13 or
>> > > before) to see if it's a possible culprit.
>> >
>> > I just tested this with v2.13 and saw the same issue.  I don't actually
>> > think this ever worked in the way you want it to Heiko.  Maybe git add
>> > needs to be taught to be more intelligent when trying to add a submodule
>> > which doesn't exist in the index.
>>
>> That was also my guess, since my feeling is that this is a quite rare
>> use case. Adding submodules alone is not a daily thing, let alone
>> selecting different changes after 'git submodule add'.
>>
>> I also think git could be more intelligent here.
>
> Ah.. the "submodule not registered in index" case. I think I remember
> this (because I remember complaining about it once or two times).
> Definitely agreed that git-add should do the right thing here.

I am not sure if this even needs to be implemented as "look for the submodule in the index". Even before submodule was added, we knew that "git add foo/bar" should reject the request if we find foo is a symbolic link, and we should do the same when foo/ is a directory that is the top of a working tree under control of another repository, no?

Hmm, what happens when we do this?
	git init
	ln -s /tmp foo
	>foo/bar
	git add foo/

I think we should say either "let's add foo symlink" or "foo/. (directory) is beyond symlink" (the latter is preferrable, but the former is acceptable as long as foo is pointing at a directory; but foo could be a dangling symlink whose pointee's type may not be discernable by "git add").

Shouldn't we be reacting pretty much the same when we see this?
	git init
	git init foo
	>foo/bar
	git add foo/

That is, either drop '/' and add 'foo' as a submodule, or say "foo/. (directory) belongs to another repository, cannot add here" (again, the latter is preferrable for consistency with the symlink behaviour above).

Previous: Duy NguyenNext: Duy Nguyen
Message 6 of 22 in “Adding nested repository with slash adds files instead of gitlink”
  1. Heiko VoigtJun 18, 2018
  2. Duy NguyenJun 18, 2018
  3. Brandon WilliamsJun 18, 2018
  4. Heiko VoigtJun 19, 2018
  5. Duy NguyenJun 19, 2018
  6. Junio C HamanoJun 19, 2018
  7. Duy NguyenJun 19, 2018
  8. Duy NguyenJun 19, 2018
  9. Duy NguyenJun 19, 2018
  10. Kevin DaudtJun 18, 2018
  11. Heiko VoigtJun 19, 2018
  12. Rafael AscensãoJun 19, 2018
  13. Kevin DaudtJun 20, 2018
  14. Rafael AscensãoJun 20, 2018
  15. Duy NguyenJun 20, 2018
  16. Rafael AscensãoJun 20, 2018
  17. Phil SaintyAug 8, 2024
  18. Junio C HamanoAug 8, 2024
  19. Johannes SchindelinAug 13, 2024
  20. Junio C HamanoAug 13, 2024
  21. Phil SaintyAug 13, 2024
  22. Johannes SchindelinAug 14, 2024

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.