Skip to content

Commit 8de7821

Browse files
avargitster
authored andcommitted
ls-files tests: add meaningful --with-tree tests
Add tests for "ls-files --with-tree". There was effectively no coverage for any normal usage of this command, only the tests added in 54e1abc (Add test case for ls-files --with-tree, 2007-10-03) for an obscure bug. Signed-off-by: Ævar Arnfjörð Bjarmason <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent dcc0a86 commit 8de7821

File tree

1 file changed

+41
-0
lines changed

1 file changed

+41
-0
lines changed

t/t3060-ls-files-with-tree.sh

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,12 @@ test_expect_success setup '
4747
git add .
4848
'
4949

50+
test_expect_success 'usage' '
51+
test_expect_code 128 git ls-files --with-tree=HEAD -u &&
52+
test_expect_code 128 git ls-files --with-tree=HEAD -s &&
53+
test_expect_code 128 git ls-files --recurse-submodules --with-tree=HEAD
54+
'
55+
5056
test_expect_success 'git ls-files --with-tree should succeed from subdir' '
5157
# We have to run from a sub-directory to trigger prune_path
5258
# Then we finally get to run our --with-tree test
@@ -60,4 +66,39 @@ test_expect_success \
6066
'git ls-files --with-tree should add entries from named tree.' \
6167
'test_cmp expected output'
6268

69+
test_expect_success 'no duplicates in --with-tree output' '
70+
git ls-files --with-tree=HEAD >actual &&
71+
sort -u actual >expected &&
72+
test_cmp expected actual
73+
'
74+
75+
test_expect_success 'setup: output in a conflict' '
76+
test_create_repo conflict &&
77+
test_commit -C conflict BASE file &&
78+
test_commit -C conflict A file foo &&
79+
git -C conflict reset --hard BASE &&
80+
test_commit -C conflict B file bar
81+
'
82+
83+
test_expect_success 'output in a conflict' '
84+
test_must_fail git -C conflict merge A B &&
85+
cat >expected <<-\EOF &&
86+
file
87+
file
88+
file
89+
file
90+
EOF
91+
git -C conflict ls-files --with-tree=HEAD >actual &&
92+
test_cmp expected actual
93+
'
94+
95+
test_expect_success 'output with removed .git/index' '
96+
cat >expected <<-\EOF &&
97+
file
98+
EOF
99+
rm conflict/.git/index &&
100+
git -C conflict ls-files --with-tree=HEAD >actual &&
101+
test_cmp expected actual
102+
'
103+
63104
test_done

0 commit comments

Comments
 (0)