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

[PATCH 0/4] dir: Treat a repository without commits as a repository

From
Kyle Meyer <kyle@kyleam.com>
Date
Mar 14, 2019, 15:02 UTC
Message-ID
<20190314150219.2040-1-kyle@kyleam.com>

When the working tree contains a repository with no commits, it's treated as an empty directory, not a repository:

    $ git init
    $ git init no-commit && touch no-commit/untracked
    $ git init with-commit && touch with-commit/untracked
    $ git -C with-commit commit --allow-empty -mmsg
    $ git ls-files -o
    no-commit/untracked
    with-commit/

That's admittedly a weird case that is unlikely to happen in the wild, and indeed I didn't observe it in the wild. In DataLad, we rely on `ls-files -o` to stop at the boundary of a submodule (like it does with "with-commit" above), and we noticed the "repository with no commit" exception on a minimal snippet that was meant for debugging another issue [*].

This series makes the "is repository?" check in treat_directory() use is_nonbare_repository_dir() instead of resolve_gitlink_ref() so that a repository without any commits is treated like a repository rather than an empty directory. This makes the reporting from commands like ls-files consistent for the case shown above, and it also avoids the case where 'git add no-commit' (no trailing slash) adds the untracked files of the no-commit/ repository to the index of the current repository.

[*]: https://github.com/datalad/datalad/issues/3139#issuecomment-460542647
Kyle Meyer (4):
  submodule: refuse to add repository with no commits
  t3000: move non-submodule repo test to separate file
  t3009: test that ls-files -o traverses bogus repo
  dir: do not traverse repositories with no commits
 dir.c                                   |  6 ++-
 git-submodule.sh                        | 12 +++++-
 t/t3000-ls-files-others.sh              |  7 ----
 t/t3009-ls-files-others-nonsubmodule.sh | 56 +++++++++++++++++++++++++
 t/t3700-add.sh                          |  1 +
 t/t7400-submodule-basic.sh              | 11 ++++-
 6 files changed, 81 insertions(+), 12 deletions(-)
 create mode 100755 t/t3009-ls-files-others-nonsubmodule.sh
-- 
2.21.0
Next: Kyle Meyer
Message 1 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.