mirror of
https://github.com/git/git.git
synced 2026-10-13 04:49:40 +02:00
The global `safe.bareRepository=all` setting in test-lib.sh is written to `$HOME/.gitconfig`, which unfortunately lives inside the test repository's working tree. The `.git/info/exclude` entry added alongside it handles most commands, but `git ls-files --others` without `--exclude-standard` does not consult `info/exclude` at all, so the file appears in the output. Ideally, each test that accesses a bare repository would simply specify `--git-dir` or `GIT_DIR` explicitly, which would require no global config and produce no side effects in the working tree. As that approach was not taken, filter `.gitconfig` from the output before comparing against expected results. In t7104, the test already uses `--exclude-standard`, so it suffices to switch from the bare `git ls-files -o` to `git ls-files -o --exclude-standard` which respects the `info/exclude` entry; the other tests deliberately omit `--exclude-standard` because their purpose is to verify unfiltered `--others` output. Assisted-by: Claude Opus 4.6 Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
79 lines
1.5 KiB
Bash
Executable File
79 lines
1.5 KiB
Bash
Executable File
#!/bin/sh
|
|
#
|
|
# Copyright (c) 2005 Junio C Hamano
|
|
#
|
|
|
|
test_description='git ls-files test (-- to terminate the path list).
|
|
|
|
This test runs git ls-files --others with the following on the
|
|
filesystem.
|
|
|
|
path0 - a file
|
|
-foo - a file with a funny name.
|
|
-- - another file with a funny name.
|
|
'
|
|
|
|
. ./test-lib.sh
|
|
|
|
test_expect_success 'setup' '
|
|
echo frotz >path0 &&
|
|
echo frotz >./-foo &&
|
|
echo frotz >./--
|
|
'
|
|
|
|
test_expect_success 'git ls-files without path restriction.' '
|
|
test_when_finished "rm -f expect" &&
|
|
git ls-files --others >output &&
|
|
test_filter_gitconfig output &&
|
|
cat >expect <<-\EOF &&
|
|
--
|
|
-foo
|
|
output
|
|
path0
|
|
EOF
|
|
test_cmp output expect
|
|
'
|
|
|
|
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
|
|
'
|
|
|
|
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
|
|
'
|
|
|
|
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
|
|
'
|
|
|
|
test_expect_success 'git ls-files with no path restriction.' '
|
|
test_when_finished "rm -f expect" &&
|
|
git ls-files --others -- >output &&
|
|
test_filter_gitconfig output &&
|
|
cat >expect <<-\EOF &&
|
|
--
|
|
-foo
|
|
output
|
|
path0
|
|
EOF
|
|
test_cmp output expect
|
|
|
|
'
|
|
|
|
test_done
|