All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/4] dir: Treat a repository without commits as a repository
@ 2019-03-14 15:02 Kyle Meyer
  2019-03-14 15:02 ` [PATCH 1/4] submodule: refuse to add repository with no commits Kyle Meyer
                   ` (3 more replies)
  0 siblings, 4 replies; 16+ messages in thread
From: Kyle Meyer @ 2019-03-14 15:02 UTC (permalink / raw)
  To: git; +Cc: debian, Kyle Meyer

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


^ permalink raw reply	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2019-04-04  7:24 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-03-14 15:02 [PATCH 0/4] dir: Treat a repository without commits as a repository Kyle Meyer
2019-03-14 15:02 ` [PATCH 1/4] submodule: refuse to add repository with no commits Kyle Meyer
2019-03-16 15:40   ` Kyle Meyer
2019-04-02 18:35     ` [PATCH v2 0/4] dir: Treat a repository without commits as a repository Kyle Meyer
2019-04-02 18:35       ` [PATCH v2 1/4] submodule: refuse to add repository with no commits Kyle Meyer
2019-04-04  7:24         ` Junio C Hamano
2019-04-02 18:35       ` [PATCH v2 2/4] t3000: move non-submodule repo test to separate file Kyle Meyer
2019-04-03  7:59         ` Junio C Hamano
2019-04-03 22:21           ` Kyle Meyer
2019-04-02 18:35       ` [PATCH v2 3/4] t3009: test that ls-files -o traverses bogus repo Kyle Meyer
2019-04-02 18:35       ` [PATCH v2 4/4] dir: do not traverse repositories with no commits Kyle Meyer
2019-04-03  8:05         ` Junio C Hamano
2019-04-03 22:25           ` Kyle Meyer
2019-03-14 15:02 ` [PATCH 2/4] t3000: move non-submodule repo test to separate file Kyle Meyer
2019-03-14 15:02 ` [PATCH 3/4] t3009: test that ls-files -o traverses bogus repo Kyle Meyer
2019-03-14 15:02 ` [PATCH 4/4] dir: do not traverse repositories with no commits Kyle Meyer

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.