From: Kyle Meyer <kyle@kyleam.com>
To: git@vger.kernel.org
Cc: debian@onerussian.com, Kyle Meyer <kyle@kyleam.com>
Subject: [PATCH 0/4] dir: Treat a repository without commits as a repository
Date: Thu, 14 Mar 2019 11:02:15 -0400 [thread overview]
Message-ID: <20190314150219.2040-1-kyle@kyleam.com> (raw)
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 reply other threads:[~2019-03-14 15:09 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-03-14 15:02 Kyle Meyer [this message]
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190314150219.2040-1-kyle@kyleam.com \
--to=kyle@kyleam.com \
--cc=debian@onerussian.com \
--cc=git@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).