path: root/dir.c
diff options
authorJunio C Hamano <>2019-05-08 15:37:23 (GMT)
committerJunio C Hamano <>2019-05-08 15:37:23 (GMT)
commit4ab701b2eec46ab5cbfe8c9732897e5d100184d8 (patch)
tree9e2001084537775407d1e4376ec9a0f5791d32d6 /dir.c
parenta1985623415223662a51b240e814d5f22b231830 (diff)
parentf937bc2f86ba2c2956b4228bd2386aaafc9afe83 (diff)
Merge branch 'km/empty-repo-is-still-a-repo'
Running "git add" on a repository created inside the current repository is an explicit indication that the user wants to add it as a submodule, but when the HEAD of the inner repository is on an unborn branch, it cannot be added as a submodule. Worse, the files in its working tree can be added as if they are a part of the outer repository, which is not what the user wants. These problems are being addressed. * km/empty-repo-is-still-a-repo: add: error appropriately on repository with no commits dir: do not traverse repositories with no commits submodule: refuse to add repository with no commits
Diffstat (limited to 'dir.c')
1 files changed, 4 insertions, 2 deletions
diff --git a/dir.c b/dir.c
index ad30a5a..0a3ddcf 100644
--- a/dir.c
+++ b/dir.c
@@ -1466,9 +1466,11 @@ static enum path_treatment treat_directory(struct dir_struct *dir,
return path_none;
if (!(dir->flags & DIR_NO_GITLINKS)) {
- struct object_id oid;
- if (resolve_gitlink_ref(dirname, "HEAD", &oid) == 0)
+ struct strbuf sb = STRBUF_INIT;
+ strbuf_addstr(&sb, dirname);
+ if (is_nonbare_repository_dir(&sb))
return exclude ? path_excluded : path_untracked;
+ strbuf_release(&sb);
return path_recurse;