]> git.ipfire.org Git - thirdparty/git.git/commitdiff
ls-files tests: add meaningful --with-tree tests
authorÆvar Arnfjörð Bjarmason <avarab@gmail.com>
Sat, 20 Mar 2021 22:37:45 +0000 (23:37 +0100)
committerJunio C Hamano <gitster@pobox.com>
Sat, 20 Mar 2021 23:09:25 +0000 (16:09 -0700)
Add tests for "ls-files --with-tree". There was effectively no
coverage for any normal usage of this command, only the tests added in
54e1abce90e (Add test case for ls-files --with-tree, 2007-10-03) for
an obscure bug.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
t/t3060-ls-files-with-tree.sh

index 52ed665fcd2dd7fbcbfbb77be4272b26f81c4f1f..b257c792a46d865a7a1d9d6261b4436ccccb3b8e 100755 (executable)
@@ -47,6 +47,12 @@ test_expect_success setup '
        git add .
 '
 
+test_expect_success 'usage' '
+       test_expect_code 128 git ls-files --with-tree=HEAD -u &&
+       test_expect_code 128 git ls-files --with-tree=HEAD -s &&
+       test_expect_code 128 git ls-files --recurse-submodules --with-tree=HEAD
+'
+
 test_expect_success 'git ls-files --with-tree should succeed from subdir' '
        # We have to run from a sub-directory to trigger prune_path
        # Then we finally get to run our --with-tree test
@@ -60,4 +66,39 @@ test_expect_success \
     'git ls-files --with-tree should add entries from named tree.' \
     'test_cmp expected output'
 
+test_expect_success 'no duplicates in --with-tree output' '
+       git ls-files --with-tree=HEAD >actual &&
+       sort -u actual >expected &&
+       test_cmp expected actual
+'
+
+test_expect_success 'setup: output in a conflict' '
+       test_create_repo conflict &&
+       test_commit -C conflict BASE file &&
+       test_commit -C conflict A file foo &&
+       git -C conflict reset --hard BASE &&
+       test_commit -C conflict B file bar
+'
+
+test_expect_success 'output in a conflict' '
+       test_must_fail git -C conflict merge A B &&
+       cat >expected <<-\EOF &&
+       file
+       file
+       file
+       file
+       EOF
+       git -C conflict ls-files --with-tree=HEAD >actual &&
+       test_cmp expected actual
+'
+
+test_expect_success 'output with removed .git/index' '
+       cat >expected <<-\EOF &&
+       file
+       EOF
+       rm conflict/.git/index &&
+       git -C conflict ls-files --with-tree=HEAD >actual &&
+       test_cmp expected actual
+'
+
 test_done