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

Re: [PATCH v2 4/4] dir: do not traverse repositories with no commits

From
Kyle Meyer <kyle@kyleam.com>
Date
Apr 3, 2019, 22:25 UTC
Message-ID
<87bm1mbua4.fsf@kyleam.com>
In-Reply-To
<xmqqef6jsedj.fsf@gitster-ct.c.googlers.com>
Junio C Hamano <gitster@pobox.com> writes:
> Kyle Meyer <kyle@kyleam.com> writes:
Show 21 quoted lines
>> As the required update to t3700-add shows, being looser with the check
>> means that we're stricter when adding empty repositories to the index:
>>
>>   % git add repo
>>   warning: adding embedded git repository: repo
>>   hint: You've added another git repository inside your current repository.
>>   hint: [...]
>>   error: unable to index file 'repo/'
>>   fatal: adding files failed
>
> Hmph, why should we have the initial "warning" with hint?  Shouldn't
> the above result in an outright error?  Something like:
>
>     $ git add repo ;# or git add repo/
>     error: repo does not have a commit checked out
>     fatal: adding files failed
>
> because the entire purpose of "git add repo" (or "git add repo/") when
> "repo" is a repository is to register the commit that is checked out
> in that sub-repository to the index of the top-level repository, as
> part of updating (or starting) a submodule.

Right, the hint makes no sense here. I'll look into adjusting the output to be appropriate.

As a minor note: I believe your "git add repo/" comments above describe what should be and not what currently is. The trailing slash results in adding the content from the specified repository to the current repository rather than registering the repository as a submodule:

  $ git --version
  git version 2.21.0
  $ git init
  $ git init a
  $ git -C a commit --allow-empty -mmsg
  $ touch a/f
  $ git add a/
  $ git status -s
  A  a/f

This behavior (and fixing it) was discussed at https://public-inbox.org/git/20180618111919.GA10085@book.hvoigt.net

Previous: Junio C Hamano
Message 16 of 16 in “dir: Treat a repository without commits as a repository”
  1. 0/4 dir: Treat a repository without commits as a repositoryKyle Meyer, Mar 14, 2019
  2. 2/4 t3000: move non-submodule repo test to separate fileKyle Meyer, Mar 14, 2019
  3. 4/4 dir: do not traverse repositories with no commitsKyle Meyer, Mar 14, 2019
  4. 3/4 t3009: test that ls-files -o traverses bogus repoKyle Meyer, Mar 14, 2019
  5. 1/4 submodule: refuse to add repository with no commitsKyle Meyer, Mar 14, 2019
  6. Kyle MeyerMar 16, 2019
  7. 0/4 dir: Treat a repository without commits as a repositoryKyle Meyer, Apr 2, 2019
  8. 1/4 submodule: refuse to add repository with no commitsKyle Meyer, Apr 2, 2019
  9. Junio C HamanoApr 4, 2019
  10. 2/4 t3000: move non-submodule repo test to separate fileKyle Meyer, Apr 2, 2019
  11. Junio C HamanoApr 3, 2019
  12. Kyle MeyerApr 3, 2019
  13. 3/4 t3009: test that ls-files -o traverses bogus repoKyle Meyer, Apr 2, 2019
  14. 4/4 dir: do not traverse repositories with no commitsKyle Meyer, Apr 2, 2019
  15. Junio C HamanoApr 3, 2019
  16. Kyle MeyerApr 3, 2019

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.