2005-10-02 15:33:38 +00:00
|
|
|
#!/bin/sh
|
|
|
|
#
|
|
|
|
# Copyright (c) 2005 Junio C Hamano
|
|
|
|
#
|
|
|
|
|
2007-07-03 05:52:14 +00:00
|
|
|
test_description='git ls-files test (-- to terminate the path list).
|
2005-10-02 15:33:38 +00:00
|
|
|
|
2007-07-03 05:52:14 +00:00
|
|
|
This test runs git ls-files --others with the following on the
|
2005-10-02 15:33:38 +00:00
|
|
|
filesystem.
|
|
|
|
|
|
|
|
path0 - a file
|
|
|
|
-foo - a file with a funny name.
|
|
|
|
-- - another file with a funny name.
|
|
|
|
'
|
2021-10-12 13:56:42 +00:00
|
|
|
|
|
|
|
TEST_PASSES_SANITIZE_LEAK=true
|
2005-10-02 15:33:38 +00:00
|
|
|
. ./test-lib.sh
|
|
|
|
|
2022-07-03 15:49:09 +00:00
|
|
|
test_expect_success 'setup' '
|
|
|
|
echo frotz >path0 &&
|
2005-10-02 15:33:38 +00:00
|
|
|
echo frotz >./-foo &&
|
2022-07-03 15:49:09 +00:00
|
|
|
echo frotz >./--
|
|
|
|
'
|
2005-10-02 15:33:38 +00:00
|
|
|
|
2022-07-03 15:49:09 +00:00
|
|
|
test_expect_success 'git ls-files without path restriction.' '
|
|
|
|
test_when_finished "rm -f expect" &&
|
|
|
|
git ls-files --others >output &&
|
|
|
|
cat >expect <<-\EOF &&
|
|
|
|
--
|
|
|
|
-foo
|
|
|
|
output
|
|
|
|
path0
|
|
|
|
EOF
|
|
|
|
test_cmp output expect
|
2005-10-02 15:33:38 +00:00
|
|
|
'
|
|
|
|
|
2022-07-03 15:49:09 +00:00
|
|
|
test_expect_success 'git ls-files with path restriction.' '
|
|
|
|
test_when_finished "rm -f expect" &&
|
|
|
|
git ls-files --others path0 >output &&
|
|
|
|
cat >expect <<-\EOF &&
|
|
|
|
path0
|
|
|
|
EOF
|
|
|
|
test_cmp output expect
|
2005-10-02 15:33:38 +00:00
|
|
|
'
|
|
|
|
|
2022-07-03 15:49:09 +00:00
|
|
|
test_expect_success 'git ls-files with path restriction with --.' '
|
|
|
|
test_when_finished "rm -f expect" &&
|
|
|
|
git ls-files --others -- path0 >output &&
|
|
|
|
cat >expect <<-\EOF &&
|
|
|
|
path0
|
|
|
|
EOF
|
|
|
|
test_cmp output expect
|
2005-10-02 15:33:38 +00:00
|
|
|
'
|
|
|
|
|
2022-07-03 15:49:09 +00:00
|
|
|
test_expect_success 'git ls-files with path restriction with -- --.' '
|
|
|
|
test_when_finished "rm -f expect" &&
|
|
|
|
git ls-files --others -- -- >output &&
|
|
|
|
cat >expect <<-\EOF &&
|
|
|
|
--
|
|
|
|
EOF
|
|
|
|
test_cmp output expect
|
2005-10-02 15:33:38 +00:00
|
|
|
'
|
|
|
|
|
2022-07-03 15:49:09 +00:00
|
|
|
test_expect_success 'git ls-files with no path restriction.' '
|
|
|
|
test_when_finished "rm -f expect" &&
|
|
|
|
git ls-files --others -- >output &&
|
|
|
|
cat >expect <<-\EOF &&
|
|
|
|
--
|
|
|
|
-foo
|
|
|
|
output
|
|
|
|
path0
|
|
|
|
EOF
|
|
|
|
test_cmp output expect
|
|
|
|
|
2005-10-02 15:33:38 +00:00
|
|
|
'
|
|
|
|
|
|
|
|
test_done
|