Skip to content

Commit

Permalink
ls-files tests: add meaningful --with-tree tests
Browse files Browse the repository at this point in the history
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 <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
avar authored and gitster committed Mar 20, 2021
1 parent dcc0a86 commit 8de7821
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions t/t3060-ls-files-with-tree.sh
Expand Up @@ -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
Expand All @@ -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

0 comments on commit 8de7821

Please sign in to comment.