{"thread":{"id":"50907","subject":"[PATCH v3 1/3] submodule: refuse to add repository with no commits","startedAt":"2019-04-09T23:08:02Z","lastAt":"2019-04-10T03:57:06Z","messageCount":5,"participants":["Kyle Meyer","Junio C Hamano"],"isPatch":true,"patchVersion":3,"patchTotal":3},"messages":[{"id":"373540","messageId":"20190409230737.26809-2-kyle@kyleam.com","threadId":"50907","inReplyTo":"20190409230737.26809-1-kyle@kyleam.com","subject":"[PATCH v3 1/3] submodule: refuse to add repository with no commits","fromName":"Kyle Meyer","fromEmail":"kyle@kyleam.com","sentAt":"2019-04-09T23:07:35Z","receivedAt":"2019-04-09T23:08:02Z","isPatch":true,"sender":{"key":"kyle@kyleam.com","avatar":"https://avatars.githubusercontent.com/u/1297788?v=4"},"body":"When the path given to 'git submodule add' is an existing repository\nthat is not in the index, the repository is passed to 'git add'.  If\nthis repository doesn't have a commit checked out, we don't get a\nuseful result: there is no subproject OID to track, and any untracked\nfiles in the sub-repository are added as blobs in the top-level\nrepository.\n\nTo avoid getting into this state, abort if the path is a repository\nthat doesn't have a commit checked out.  Note that this check must\ncome before the 'git add --dry-run' check because the next commit will\nmake 'git add' fail when given a repository that doesn't have a commit\nchecked out.\n\nSigned-off-by: Kyle Meyer <kyle@kyleam.com>\n---\n git-submodule.sh           |  7 +++++++\n t/t7400-submodule-basic.sh | 11 ++++++++++-\n 2 files changed, 17 insertions(+), 1 deletion(-)\n\ndiff --git a/git-submodule.sh b/git-submodule.sh\nindex 2c0fb6d723..c88a05086e 100755\n--- a/git-submodule.sh\n+++ b/git-submodule.sh\n@@ -231,6 +231,13 @@ cmd_add()\n \t\tdie \"$(eval_gettext \"'\\$sm_path' already exists in the index and is not a submodule\")\"\n \tfi\n \n+\tif test -d \"$sm_path\" &&\n+\t\ttest -z $(git -C \"$sm_path\" rev-parse --show-cdup 2>/dev/null)\n+\tthen\n+\t    git -C \"$sm_path\" rev-parse --verify -q HEAD >/dev/null ||\n+\t    die \"$(eval_gettext \"'\\$sm_path' does not have a commit checked out\")\"\n+\tfi\n+\n \tif test -z \"$force\" &&\n \t\t! git add --dry-run --ignore-missing --no-warn-embedded-repo \"$sm_path\" > /dev/null 2>&1\n \tthen\ndiff --git a/t/t7400-submodule-basic.sh b/t/t7400-submodule-basic.sh\nindex aba2d4d6ee..a208cb26e1 100755\n--- a/t/t7400-submodule-basic.sh\n+++ b/t/t7400-submodule-basic.sh\n@@ -46,6 +46,15 @@ test_expect_success 'submodule update aborts on missing gitmodules url' '\n \ttest_must_fail git submodule init\n '\n \n+test_expect_success 'add aborts on repository with no commits' '\n+\tcat >expect <<-\\EOF &&\n+\t'\"'repo-no-commits'\"' does not have a commit checked out\n+\tEOF\n+\tgit init repo-no-commits &&\n+\ttest_must_fail git submodule add ../a ./repo-no-commits 2>actual &&\n+\ttest_i18ncmp expect actual\n+'\n+\n test_expect_success 'setup - repository in init subdirectory' '\n \tmkdir init &&\n \t(\n@@ -809,7 +818,7 @@ test_expect_success '../bar/a/b/c works with relative local path - ../foo/bar.gi\n \t\tcp pristine-.git-config .git/config &&\n \t\tcp pristine-.gitmodules .gitmodules &&\n \t\tmkdir -p a/b/c &&\n-\t\t(cd a/b/c && git init) &&\n+\t\t(cd a/b/c && git init && test_commit msg) &&\n \t\tgit config remote.origin.url ../foo/bar.git &&\n \t\tgit submodule add ../bar/a/b/c ./a/b/c &&\n \t\tgit submodule init &&\n-- \n2.21.0\n\n"},{"id":"373541","messageId":"20190409230737.26809-1-kyle@kyleam.com","threadId":"50907","inReplyTo":null,"subject":"[PATCH v3 0/3] dir: treat a repository without commits as a repository","fromName":"Kyle Meyer","fromEmail":"kyle@kyleam.com","sentAt":"2019-04-09T23:07:34Z","receivedAt":"2019-04-09T23:08:08Z","isPatch":true,"sender":{"key":"kyle@kyleam.com","avatar":"https://avatars.githubusercontent.com/u/1297788?v=4"},"body":"This is a reroll of <20190402183505.31512-1-kyle@kyleam.com>.  Thanks,\nJunio, for your comments on v2.\n\nThe series improves the handling of sub-repositories that don't have a\ncommit checked out.  In particular, it addresses the following issues:\n\n  * Calling 'git add repo' is meant to register the repository as a\n    submodule, but, for a sub-repository that doesn't have a commit\n    checked out, it is at best a no-op.  If the sub-repository has any\n    untracked files, they are added as blobs in the top-level\n    repository.\n\n    Instead error in this situation.\n\n  * 'git submodule add' calls 'git add' on a sub-repository, so it has\n    the same issues as above.  Plus it modifies .gitmodules even\n    though there is no sub-project OID to register.\n\n    Instead error in this situation.\n\n  * Commands like 'ls-files -o' and 'status -uall' usually stop\n    traversing at sub-repository boundaries, but they don't if the\n    sub-repository doesn't have a commit checked out.\n\n    Instead stop traversing at a sub-repository even if it doesn't\n    have a commit checked out.\n\nMain changes from v2:\n\n  * Leave be the \"non-submodule .git\" test from\n    t3000-ls-files-others.sh rather than confusingly using it as the\n    basis for the new t3009-ls-files-others-nonsubmodule.sh\n    (<87d0m2bui0.fsf@kyleam.com>).\n\n  * Drop unneeded setup function in test (<87d0m2bui0.fsf@kyleam.com>).\n\n  * Provide appropriate output for the 'git add repo-no-commits'\n    failure (<87bm1mbua4.fsf@kyleam.com>).\n\nOther changes from v2:\n\n  * Commit message tweaks.  These include replacing wording like \"no\n    commits\" with something like \"no commit checked out\" because,\n    technically, this series also concerns repositories that have\n    commit objects but are on an unborn branch.\n\n  * Change the \"git submodule add\" error message to match the wording\n    of the new error message added in add_to_index().\n\n  * Consistently use \"expect\" rather than \"expected\" as the output\n    file name for expected test output.\n\n\nKyle Meyer (3):\n  submodule: refuse to add repository with no commits\n  dir: do not traverse repositories with no commits\n  add: error appropriately on repository with no commits\n\n builtin/add.c                           |  3 +-\n dir.c                                   |  6 ++-\n git-submodule.sh                        |  7 ++++\n read-cache.c                            |  3 ++\n t/t3009-ls-files-others-nonsubmodule.sh | 50 +++++++++++++++++++++++++\n t/t3700-add.sh                          | 12 ++++++\n t/t7400-submodule-basic.sh              | 11 +++++-\n 7 files changed, 88 insertions(+), 4 deletions(-)\n create mode 100755 t/t3009-ls-files-others-nonsubmodule.sh\n\nRange-diff against v2:\n1:  b080e2c557 ! 1:  ad1b0b44e8 submodule: refuse to add repository with no commits\n    @@ -4,14 +4,16 @@\n     \n         When the path given to 'git submodule add' is an existing repository\n         that is not in the index, the repository is passed to 'git add'.  If\n    -    this repository doesn't have any commits, we don't get a useful\n    -    result: there is no subproject OID to track, and any untracked files\n    -    in the sub-repository are added to the current repository.\n    +    this repository doesn't have a commit checked out, we don't get a\n    +    useful result: there is no subproject OID to track, and any untracked\n    +    files in the sub-repository are added as blobs in the top-level\n    +    repository.\n     \n    -    Detect if the path is a repository with no commits and abort to avoid\n    -    getting into this state.  Note that this check must come before the\n    -    'git add --dry-run' check because an upcoming commit will make 'git\n    -    add' fail in this situation.\n    +    To avoid getting into this state, abort if the path is a repository\n    +    that doesn't have a commit checked out.  Note that this check must\n    +    come before the 'git add --dry-run' check because the next commit will\n    +    make 'git add' fail when given a repository that doesn't have a commit\n    +    checked out.\n     \n         Signed-off-by: Kyle Meyer <kyle@kyleam.com>\n     \n    @@ -26,7 +28,7 @@\n     +\t\ttest -z $(git -C \"$sm_path\" rev-parse --show-cdup 2>/dev/null)\n     +\tthen\n     +\t    git -C \"$sm_path\" rev-parse --verify -q HEAD >/dev/null ||\n    -+\t    die \"$(eval_gettext \"'\\$sm_path' does not have any commits\")\"\n    ++\t    die \"$(eval_gettext \"'\\$sm_path' does not have a commit checked out\")\"\n     +\tfi\n     +\n      \tif test -z \"$force\" &&\n    @@ -41,12 +43,12 @@\n      '\n      \n     +test_expect_success 'add aborts on repository with no commits' '\n    -+\tcat >expected <<-\\EOF &&\n    -+\t'\"'repo-no-commits'\"' does not have any commits\n    ++\tcat >expect <<-\\EOF &&\n    ++\t'\"'repo-no-commits'\"' does not have a commit checked out\n     +\tEOF\n     +\tgit init repo-no-commits &&\n     +\ttest_must_fail git submodule add ../a ./repo-no-commits 2>actual &&\n    -+\ttest_i18ncmp expected actual\n    ++\ttest_i18ncmp expect actual\n     +'\n     +\n      test_expect_success 'setup - repository in init subdirectory' '\n2:  c027701842 < -:  ---------- t3000: move non-submodule repo test to separate file\n3:  97f53e30c0 < -:  ---------- t3009: test that ls-files -o traverses bogus repo\n4:  a926b87102 ! 2:  1bf762bbd3 dir: do not traverse repositories with no commits\n    @@ -9,12 +9,15 @@\n         will show only the directory, even when there are untracked files\n         within the directory.\n     \n    -    For the unusual case where a repository doesn't have any commits,\n    -    resolve_gitlink_ref() returns -1 because HEAD cannot be resolved, and\n    -    the directory is treated as a normal directory (i.e. traversal does\n    -    not stop at the repository boundary).  The status and ls-files\n    +    For the unusual case where a repository doesn't have a commit checked\n    +    out, resolve_gitlink_ref() returns -1 because HEAD cannot be resolved,\n    +    and the directory is treated as a normal directory (i.e. traversal\n    +    does not stop at the repository boundary).  The status and ls-files\n         commands above list untracked files within the repository rather than\n    -    showing only the top-level directory.\n    +    showing only the top-level directory.  And if 'git add' is called on a\n    +    repository with no commit checked out, any untracked files under the\n    +    repository are added as blobs in the top-level project, a behavior\n    +    that is unlikely to be what the caller intended.\n     \n         The above case is a corner case in an already unusual situation of the\n         working tree containing a repository that is not a tracked submodule,\n    @@ -22,23 +25,12 @@\n         consistently.  Loosen the \"looks like a repository\" criteria in\n         treat_directory() by replacing resolve_gitlink_ref() with\n         is_nonbare_repository_dir(), one of the checks that is performed\n    -    downstream when resolve_gitlink_ref() is called with an empty\n    -    repository.\n    +    downstream when resolve_gitlink_ref() is called.\n     \n    -    As the required update to t3700-add shows, being looser with the check\n    -    means that we're stricter when adding empty repositories to the index:\n    -\n    -      % git add repo\n    -      warning: adding embedded git repository: repo\n    -      hint: You've added another git repository inside your current repository.\n    -      hint: [...]\n    -      error: unable to index file 'repo/'\n    -      fatal: adding files failed\n    -\n    -    That error message isn't particularly helpful in this situation, but\n    -    it seems preferable to the old behavior of adding the repository's\n    -    untracked files.  And if the caller really wants the previous\n    -    behavior, they can get it by adding a trailing slash.\n    +    As the required update to t3700-add shows, calling 'git add' on a\n    +    repository with no commit checked out will now raise an error.  While\n    +    this is the desired behavior, note that the output isn't yet\n    +    appropriate.  The next commit will improve this output.\n     \n         Signed-off-by: Kyle Meyer <kyle@kyleam.com>\n     \n    @@ -61,12 +53,20 @@\n      \t}\n     \n      diff --git a/t/t3009-ls-files-others-nonsubmodule.sh b/t/t3009-ls-files-others-nonsubmodule.sh\n    - --- a/t/t3009-ls-files-others-nonsubmodule.sh\n    + new file mode 100755\n    + --- /dev/null\n      +++ b/t/t3009-ls-files-others-nonsubmodule.sh\n     @@\n    -       directory with no files aside from a bogus .git file\n    -     repo-bogus-untracked-file/\n    -       directory with a bogus .git file and another untracked file\n    ++#!/bin/sh\n    ++\n    ++test_description='test git ls-files --others with non-submodule repositories\n    ++\n    ++This test runs git ls-files --others with the following working tree:\n    ++\n    ++    nonrepo-no-files/\n    ++      plain directory with no files\n    ++    nonrepo-untracked-file/\n    ++      plain directory with an untracked file\n     +    repo-no-commit-no-files/\n     +      git repository without a commit or a file\n     +    repo-no-commit-untracked-file/\n    @@ -75,26 +75,14 @@\n     +      git repository with a commit and no untracked files\n     +    repo-with-commit-untracked-file/\n     +      git repository with a commit and an untracked file\n    - '\n    - \n    - . ./test-lib.sh\n    -@@\n    - \texpected\n    - \toutput\n    - \trepo-bogus-untracked-file/untracked\n    -+\trepo-no-commit-no-files/\n    -+\trepo-no-commit-untracked-file/\n    -+\trepo-with-commit-no-files/\n    -+\trepo-with-commit-untracked-file/\n    - \tEOF\n    - '\n    - \n    -@@\n    - \techo foo >repo-bogus-no-files/.git &&\n    - \tmkdir repo-bogus-untracked-file &&\n    - \techo foo >repo-bogus-untracked-file/.git &&\n    --\t: >repo-bogus-untracked-file/untracked\n    -+\t: >repo-bogus-untracked-file/untracked &&\n    ++'\n    ++\n    ++. ./test-lib.sh\n    ++\n    ++test_expect_success 'setup: directories' '\n    ++\tmkdir nonrepo-no-files/ &&\n    ++\tmkdir nonrepo-untracked-file &&\n    ++\t: >nonrepo-untracked-file/untracked &&\n     +\tgit init repo-no-commit-no-files &&\n     +\tgit init repo-no-commit-untracked-file &&\n     +\t: >repo-no-commit-untracked-file/untracked &&\n    @@ -103,9 +91,22 @@\n     +\tgit init repo-with-commit-untracked-file &&\n     +\ttest_commit -C repo-with-commit-untracked-file msg &&\n     +\t: >repo-with-commit-untracked-file/untracked\n    - '\n    - \n    - test_expect_success 'ls-files --others handles non-submodule .git' '\n    ++'\n    ++\n    ++test_expect_success 'ls-files --others handles untracked git repositories' '\n    ++\tgit ls-files -o >output &&\n    ++\tcat >expect <<-EOF &&\n    ++\tnonrepo-untracked-file/untracked\n    ++\toutput\n    ++\trepo-no-commit-no-files/\n    ++\trepo-no-commit-untracked-file/\n    ++\trepo-with-commit-no-files/\n    ++\trepo-with-commit-untracked-file/\n    ++\tEOF\n    ++\ttest_cmp expect output\n    ++'\n    ++\n    ++test_done\n     \n      diff --git a/t/t3700-add.sh b/t/t3700-add.sh\n      --- a/t/t3700-add.sh\n-:  ---------- > 3:  a2f9af5448 add: error appropriately on repository with no commits\n-- \n2.21.0\n\n"},{"id":"373542","messageId":"20190409230737.26809-4-kyle@kyleam.com","threadId":"50907","inReplyTo":"20190409230737.26809-1-kyle@kyleam.com","subject":"[PATCH v3 3/3] add: error appropriately on repository with no commits","fromName":"Kyle Meyer","fromEmail":"kyle@kyleam.com","sentAt":"2019-04-09T23:07:37Z","receivedAt":"2019-04-09T23:08:10Z","isPatch":true,"sender":{"key":"kyle@kyleam.com","avatar":"https://avatars.githubusercontent.com/u/1297788?v=4"},"body":"The previous commit made 'git add' abort when given a repository that\ndoesn't have a commit checked out.  However, the output upon failure\nisn't appropriate:\n\n  % git add repo\n  warning: adding embedded git repository: repo\n  hint: You've added another git repository inside your current repository.\n  hint: [...]\n  error: unable to index file 'repo/'\n  fatal: adding files failed\n\nThe hint doesn't apply in this case, and the error message doesn't\ntell the user why 'repo' couldn't be added to the index.\n\nProvide better output by teaching add_to_index() to error when given a\ngit directory where HEAD can't be resolved.  To avoid the embedded\nrepository warning and hint, call check_embedded_repo() only after\nadd_file_to_index() succeeds because, in general, its output doesn't\nmake sense if adding to the index fails.\n\nSigned-off-by: Kyle Meyer <kyle@kyleam.com>\n---\n builtin/add.c  |  3 ++-\n read-cache.c   |  3 +++\n t/t3700-add.sh | 11 +++++++++++\n 3 files changed, 16 insertions(+), 1 deletion(-)\n\ndiff --git a/builtin/add.c b/builtin/add.c\nindex db2dfa4350..dd18e5c9b6 100644\n--- a/builtin/add.c\n+++ b/builtin/add.c\n@@ -374,11 +374,12 @@ static int add_files(struct dir_struct *dir, int flags)\n \t}\n \n \tfor (i = 0; i < dir->nr; i++) {\n-\t\tcheck_embedded_repo(dir->entries[i]->name);\n \t\tif (add_file_to_index(&the_index, dir->entries[i]->name, flags)) {\n \t\t\tif (!ignore_add_errors)\n \t\t\t\tdie(_(\"adding files failed\"));\n \t\t\texit_status = 1;\n+\t\t} else {\n+\t\t\tcheck_embedded_repo(dir->entries[i]->name);\n \t\t}\n \t}\n \treturn exit_status;\ndiff --git a/read-cache.c b/read-cache.c\nindex 4dc6de1b55..b4b68d6ec8 100644\n--- a/read-cache.c\n+++ b/read-cache.c\n@@ -708,6 +708,7 @@ int add_to_index(struct index_state *istate, const char *path, struct stat *st,\n \tint add_option = (ADD_CACHE_OK_TO_ADD|ADD_CACHE_OK_TO_REPLACE|\n \t\t\t  (intent_only ? ADD_CACHE_NEW_ONLY : 0));\n \tint hash_flags = HASH_WRITE_OBJECT;\n+\tstruct object_id oid;\n \n \tif (flags & ADD_CACHE_RENORMALIZE)\n \t\thash_flags |= HASH_RENORMALIZE;\n@@ -717,6 +718,8 @@ int add_to_index(struct index_state *istate, const char *path, struct stat *st,\n \n \tnamelen = strlen(path);\n \tif (S_ISDIR(st_mode)) {\n+\t\tif (resolve_gitlink_ref(path, \"HEAD\", &oid) < 0)\n+\t\t\treturn error(_(\"'%s' does not have a commit checked out\"), path);\n \t\twhile (namelen && path[namelen-1] == '/')\n \t\t\tnamelen--;\n \t}\ndiff --git a/t/t3700-add.sh b/t/t3700-add.sh\nindex 5a8425962b..c325167b90 100755\n--- a/t/t3700-add.sh\n+++ b/t/t3700-add.sh\n@@ -296,6 +296,17 @@ test_expect_success '\"git add .\" in empty repo' '\n \t)\n '\n \n+test_expect_success 'error on a repository with no commits' '\n+\trm -fr empty &&\n+\tgit init empty &&\n+\ttest_must_fail git add empty >actual 2>&1 &&\n+\tcat >expect <<-EOF &&\n+\terror: '\"'empty/'\"' does not have a commit checked out\n+\tfatal: adding files failed\n+\tEOF\n+\ttest_i18ncmp expect actual\n+'\n+\n test_expect_success 'git add --dry-run of existing changed file' \"\n \techo new >>track-this &&\n \tgit add --dry-run track-this >actual 2>&1 &&\n-- \n2.21.0\n\n"},{"id":"373543","messageId":"20190409230737.26809-3-kyle@kyleam.com","threadId":"50907","inReplyTo":"20190409230737.26809-1-kyle@kyleam.com","subject":"[PATCH v3 2/3] dir: do not traverse repositories with no commits","fromName":"Kyle Meyer","fromEmail":"kyle@kyleam.com","sentAt":"2019-04-09T23:07:36Z","receivedAt":"2019-04-09T23:08:11Z","isPatch":true,"sender":{"key":"kyle@kyleam.com","avatar":"https://avatars.githubusercontent.com/u/1297788?v=4"},"body":"When treat_directory() encounters a directory that is not in the index\nand DIR_NO_GITLINKS is unset, it calls resolve_gitlink_ref() to decide\nif a directory looks like a repository, in which case the directory\nwon't be traversed.  As a result, 'status -uall' and 'ls-files -o'\nwill show only the directory, even when there are untracked files\nwithin the directory.\n\nFor the unusual case where a repository doesn't have a commit checked\nout, resolve_gitlink_ref() returns -1 because HEAD cannot be resolved,\nand the directory is treated as a normal directory (i.e. traversal\ndoes not stop at the repository boundary).  The status and ls-files\ncommands above list untracked files within the repository rather than\nshowing only the top-level directory.  And if 'git add' is called on a\nrepository with no commit checked out, any untracked files under the\nrepository are added as blobs in the top-level project, a behavior\nthat is unlikely to be what the caller intended.\n\nThe above case is a corner case in an already unusual situation of the\nworking tree containing a repository that is not a tracked submodule,\nbut we might as well treat anything that looks like a repository\nconsistently.  Loosen the \"looks like a repository\" criteria in\ntreat_directory() by replacing resolve_gitlink_ref() with\nis_nonbare_repository_dir(), one of the checks that is performed\ndownstream when resolve_gitlink_ref() is called.\n\nAs the required update to t3700-add shows, calling 'git add' on a\nrepository with no commit checked out will now raise an error.  While\nthis is the desired behavior, note that the output isn't yet\nappropriate.  The next commit will improve this output.\n\nSigned-off-by: Kyle Meyer <kyle@kyleam.com>\n---\n dir.c                                   |  6 ++-\n t/t3009-ls-files-others-nonsubmodule.sh | 50 +++++++++++++++++++++++++\n t/t3700-add.sh                          |  1 +\n 3 files changed, 55 insertions(+), 2 deletions(-)\n create mode 100755 t/t3009-ls-files-others-nonsubmodule.sh\n\ndiff --git a/dir.c b/dir.c\nindex b2cabadf25..a4e59eb351 100644\n--- a/dir.c\n+++ b/dir.c\n@@ -1467,9 +1467,11 @@ static enum path_treatment treat_directory(struct dir_struct *dir,\n \t\t\treturn path_none;\n \t\t}\n \t\tif (!(dir->flags & DIR_NO_GITLINKS)) {\n-\t\t\tstruct object_id oid;\n-\t\t\tif (resolve_gitlink_ref(dirname, \"HEAD\", &oid) == 0)\n+\t\t\tstruct strbuf sb = STRBUF_INIT;\n+\t\t\tstrbuf_addstr(&sb, dirname);\n+\t\t\tif (is_nonbare_repository_dir(&sb))\n \t\t\t\treturn exclude ? path_excluded : path_untracked;\n+\t\t\tstrbuf_release(&sb);\n \t\t}\n \t\treturn path_recurse;\n \t}\ndiff --git a/t/t3009-ls-files-others-nonsubmodule.sh b/t/t3009-ls-files-others-nonsubmodule.sh\nnew file mode 100755\nindex 0000000000..963f3462b7\n--- /dev/null\n+++ b/t/t3009-ls-files-others-nonsubmodule.sh\n@@ -0,0 +1,50 @@\n+#!/bin/sh\n+\n+test_description='test git ls-files --others with non-submodule repositories\n+\n+This test runs git ls-files --others with the following working tree:\n+\n+    nonrepo-no-files/\n+      plain directory with no files\n+    nonrepo-untracked-file/\n+      plain directory with an untracked file\n+    repo-no-commit-no-files/\n+      git repository without a commit or a file\n+    repo-no-commit-untracked-file/\n+      git repository without a commit but with an untracked file\n+    repo-with-commit-no-files/\n+      git repository with a commit and no untracked files\n+    repo-with-commit-untracked-file/\n+      git repository with a commit and an untracked file\n+'\n+\n+. ./test-lib.sh\n+\n+test_expect_success 'setup: directories' '\n+\tmkdir nonrepo-no-files/ &&\n+\tmkdir nonrepo-untracked-file &&\n+\t: >nonrepo-untracked-file/untracked &&\n+\tgit init repo-no-commit-no-files &&\n+\tgit init repo-no-commit-untracked-file &&\n+\t: >repo-no-commit-untracked-file/untracked &&\n+\tgit init repo-with-commit-no-files &&\n+\tgit -C repo-with-commit-no-files commit --allow-empty -mmsg &&\n+\tgit init repo-with-commit-untracked-file &&\n+\ttest_commit -C repo-with-commit-untracked-file msg &&\n+\t: >repo-with-commit-untracked-file/untracked\n+'\n+\n+test_expect_success 'ls-files --others handles untracked git repositories' '\n+\tgit ls-files -o >output &&\n+\tcat >expect <<-EOF &&\n+\tnonrepo-untracked-file/untracked\n+\toutput\n+\trepo-no-commit-no-files/\n+\trepo-no-commit-untracked-file/\n+\trepo-with-commit-no-files/\n+\trepo-with-commit-untracked-file/\n+\tEOF\n+\ttest_cmp expect output\n+'\n+\n+test_done\ndiff --git a/t/t3700-add.sh b/t/t3700-add.sh\nindex be582a513b..5a8425962b 100755\n--- a/t/t3700-add.sh\n+++ b/t/t3700-add.sh\n@@ -396,6 +396,7 @@ test_expect_success 'no file status change if no pathspec is given in subdir' '\n '\n \n test_expect_success 'all statuses changed in folder if . is given' '\n+\trm -fr empty &&\n \tgit add --chmod=+x . &&\n \ttest $(git ls-files --stage | grep ^100644 | wc -l) -eq 0 &&\n \tgit add --chmod=-x . &&\n-- \n2.21.0\n\n"},{"id":"373567","messageId":"xmqqv9zm1piq.fsf@gitster-ct.c.googlers.com","threadId":"50907","inReplyTo":"20190409230737.26809-1-kyle@kyleam.com","subject":"Re: [PATCH v3 0/3] dir: treat a repository without commits as a repository","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2019-04-10T03:57:01Z","receivedAt":"2019-04-10T03:57:06Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Kyle Meyer <kyle@kyleam.com> writes:\n\n> The series improves the handling of sub-repositories that don't have a\n> commit checked out.  In particular, it addresses the following issues:\n> ...\n>   * Commit message tweaks.  These include replacing wording like \"no\n>     commits\" with something like \"no commit checked out\" because,\n>     technically, this series also concerns repositories that have\n>     commit objects but are on an unborn branch.\n\nChanges from \"not have any commits\" to \"not have a commit checked\nout\" can also be seen in the code (the next bullet point), which is\na very welcome change.  It shows that the patchset was done with\nnice attention to the detail.\n\n>   * Change the \"git submodule add\" error message to match the wording\n>     of the new error message added in add_to_index().\n>\n>   * Consistently use \"expect\" rather than \"expected\" as the output\n>     file name for expected test output.\n\nThanks; will replace.  Hopefully this round is ready for 'next'.\n\n"}]}