diff mbox series

[v2,3/4] t3009: test that ls-files -o traverses bogus repo

Message ID 20190402183505.31512-4-kyle@kyleam.com (mailing list archive)
State New, archived
Headers show
Series dir: Treat a repository without commits as a repository | expand

Commit Message

Kyle Meyer April 2, 2019, 6:35 p.m. UTC
When a2d5156c2b (resolve_gitlink_ref: ignore non-repository paths,
2016-01-22) added this test, the purpose was to check the 'ls-files
-o' didn't die() when processing the bogus repository.  The expected
output didn't even need to be adjusted for the addition because the
bogus repository is treated as an empty directory.

Let's add another scenario to test that 'ls-files -o' lists an
untracked file within this directory.  Doing so isn't useful for the
original purpose of the test, but it will be helpful for highlighting
that this traversal does _not_ happen in the non-bogus scenarios that
will be added next.  Rename the original subdirectory to highlight the
difference with the new one.

Signed-off-by: Kyle Meyer <kyle@kyleam.com>
---
 t/t3009-ls-files-others-nonsubmodule.sh | 21 ++++++++++++++++++---
 1 file changed, 18 insertions(+), 3 deletions(-)
diff mbox series

Patch

diff --git a/t/t3009-ls-files-others-nonsubmodule.sh b/t/t3009-ls-files-others-nonsubmodule.sh
index cc66a4a14d..9ed75928aa 100755
--- a/t/t3009-ls-files-others-nonsubmodule.sh
+++ b/t/t3009-ls-files-others-nonsubmodule.sh
@@ -1,6 +1,14 @@ 
 #!/bin/sh
 
-test_description='test git ls-files --others with non-submodule repositories'
+test_description='test git ls-files --others with non-submodule repositories
+
+This test runs git ls-files --others with the following working tree:
+
+    repo-bogus-no-files/
+      directory with no files aside from a bogus .git file
+    repo-bogus-untracked-file/
+      directory with a bogus .git file and another untracked file
+'
 
 . ./test-lib.sh
 
@@ -8,12 +16,19 @@  test_expect_success 'setup: expected output' '
 	cat >expected <<-EOF
 	expected
 	output
+	repo-bogus-untracked-file/untracked
 	EOF
 '
 
+test_expect_success 'setup: directories' '
+	mkdir repo-bogus-no-files &&
+	echo foo >repo-bogus-no-files/.git &&
+	mkdir repo-bogus-untracked-file &&
+	echo foo >repo-bogus-untracked-file/.git &&
+	: >repo-bogus-untracked-file/untracked
+'
+
 test_expect_success 'ls-files --others handles non-submodule .git' '
-	mkdir not-a-submodule &&
-	echo foo >not-a-submodule/.git &&
 	git ls-files -o >output &&
 	test_cmp expected output
 '