test_expect_success 'ls-files --others' '
git ls-files --others >output &&
+ test_filter_gitconfig output &&
test_cmp expected1 output
'
test_expect_success 'ls-files --others --directory' '
git ls-files --others --directory >output &&
+ test_filter_gitconfig output &&
test_cmp expected2 output
'
test_expect_success '--no-empty-directory hides empty directory' '
git ls-files --others --directory --no-empty-directory >output &&
+ test_filter_gitconfig output &&
test_cmp expected3 output
'
mkdir not-a-submodule &&
echo foo >not-a-submodule/.git &&
git ls-files -o >output &&
+ test_filter_gitconfig output &&
test_cmp expected1 output
'
--exclude-per-directory=.gitignore \
--exclude-from=.git/ignore \
>output &&
+ test_filter_gitconfig output &&
test_cmp expect output
'
--exclude-per-directory=.gitignore \
--exclude-from=.git/ignore \
>output &&
+ test_filter_gitconfig output &&
test_cmp expect output
'
--exclude-per-directory=.gitignore \
--exclude-from=.git/ignore \
>output &&
+ test_filter_gitconfig output &&
test_cmp expect output
'
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
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
test_expect_success 'ls-files --others handles untracked git repositories' '
git ls-files -o >output &&
+ test_filter_gitconfig output &&
cat >expect <<-EOF &&
nonrepo-untracked-file/untracked
output
'
test_expect_success 'git ls-files -o shows the right entries' '
- cat <<-EOF >expect &&
+ cat >expect <<-EOF &&
.gitignore
actual
an_ignored_dir/ignored
untracked_repo/
EOF
git ls-files -o >actual &&
+ test_filter_gitconfig actual &&
test_cmp expect actual
'
rm -f hello &&
mkdir -p hello &&
>hello/world &&
- test "$(git ls-files -o)" = hello/world
+ test "$(git ls-files -o --exclude-standard)" = hello/world
'
test_redact_non_printables () {
tr -d "\n\r" | tr "[\001-\040][\177-\377]" "."
}
+
+# Remove .gitconfig entries from a file in place. test-lib.sh may
+# create $HOME/.gitconfig (e.g. to set safe.bareRepository) which
+# can appear in ls-files or status output.
+test_filter_gitconfig () {
+ sed "/\\.gitconfig/d" "$1" >"$1.filtered" &&
+ mv "$1.filtered" "$1"
+}