5bd8e2d894
The notion of "ignored tracked" directories introduced in 721ac4ed
"dir.c:
Make git-status --ignored more consistent" has a few unwanted side effects:
- git-clean -d -X: deletes ignored tracked directories. git-clean should
never delete tracked content.
- git-ls-files --ignored --other --directory: lists ignored tracked
directories instead of "other" directories.
- git-status --ignored: lists ignored tracked directories while contained
files may be listed as modified. Paths listed by git-status should be
disjoint (except in long format where a path may be listed in both the
staged and unstaged section).
Additionally, the current behaviour violates documentation in gitignore(5)
("Specifies intentionally *untracked* files to ignore") and Documentation/
technical/api-directory-listing.txt ("DIR_SHOW_OTHER_DIRECTORIES: Include
a directory that is *not tracked*.").
In dir.c::treat_directory, remove the special handling of ignored tracked
directories, so that the DIR_SHOW_OTHER_DIRECTORIES flag only affects
"other" (i.e. untracked) directories. In dir.c::dir_add_name, check that
added paths are untracked even if DIR_SHOW_IGNORED is set.
Signed-off-by: Karsten Blees <blees@dcon.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
266 lines
5.5 KiB
Bash
Executable File
266 lines
5.5 KiB
Bash
Executable File
#!/bin/sh
|
|
|
|
test_description='git-status ignored files'
|
|
|
|
. ./test-lib.sh
|
|
|
|
cat >expected <<\EOF
|
|
?? .gitignore
|
|
?? actual
|
|
?? expected
|
|
?? untracked/
|
|
EOF
|
|
|
|
test_expect_success 'status untracked directory with --ignored' '
|
|
echo "ignored" >.gitignore &&
|
|
mkdir untracked &&
|
|
: >untracked/ignored &&
|
|
: >untracked/uncommitted &&
|
|
git status --porcelain --ignored >actual &&
|
|
test_cmp expected actual
|
|
'
|
|
|
|
cat >expected <<\EOF
|
|
?? .gitignore
|
|
?? actual
|
|
?? expected
|
|
?? untracked/uncommitted
|
|
!! untracked/ignored
|
|
EOF
|
|
|
|
test_expect_success 'status untracked directory with --ignored -u' '
|
|
git status --porcelain --ignored -u >actual &&
|
|
test_cmp expected actual
|
|
'
|
|
cat >expected <<\EOF
|
|
?? untracked/uncommitted
|
|
!! untracked/ignored
|
|
EOF
|
|
|
|
test_expect_success 'status prefixed untracked directory with --ignored' '
|
|
git status --porcelain --ignored untracked/ >actual &&
|
|
test_cmp expected actual
|
|
'
|
|
|
|
cat >expected <<\EOF
|
|
?? untracked/uncommitted
|
|
!! untracked/ignored
|
|
EOF
|
|
|
|
test_expect_success 'status prefixed untracked sub-directory with --ignored -u' '
|
|
git status --porcelain --ignored -u untracked/ >actual &&
|
|
test_cmp expected actual
|
|
'
|
|
|
|
cat >expected <<\EOF
|
|
?? .gitignore
|
|
?? actual
|
|
?? expected
|
|
!! ignored/
|
|
EOF
|
|
|
|
test_expect_success 'status ignored directory with --ignore' '
|
|
rm -rf untracked &&
|
|
mkdir ignored &&
|
|
: >ignored/uncommitted &&
|
|
git status --porcelain --ignored >actual &&
|
|
test_cmp expected actual
|
|
'
|
|
|
|
cat >expected <<\EOF
|
|
?? .gitignore
|
|
?? actual
|
|
?? expected
|
|
!! ignored/uncommitted
|
|
EOF
|
|
|
|
test_expect_success 'status ignored directory with --ignore -u' '
|
|
git status --porcelain --ignored -u >actual &&
|
|
test_cmp expected actual
|
|
'
|
|
|
|
cat >expected <<\EOF
|
|
?? .gitignore
|
|
?? actual
|
|
?? expected
|
|
EOF
|
|
|
|
test_expect_success 'status empty untracked directory with --ignore' '
|
|
rm -rf ignored &&
|
|
mkdir untracked-ignored &&
|
|
mkdir untracked-ignored/test &&
|
|
git status --porcelain --ignored >actual &&
|
|
test_cmp expected actual
|
|
'
|
|
|
|
cat >expected <<\EOF
|
|
?? .gitignore
|
|
?? actual
|
|
?? expected
|
|
EOF
|
|
|
|
test_expect_success 'status empty untracked directory with --ignore -u' '
|
|
git status --porcelain --ignored -u >actual &&
|
|
test_cmp expected actual
|
|
'
|
|
|
|
cat >expected <<\EOF
|
|
?? .gitignore
|
|
?? actual
|
|
?? expected
|
|
!! untracked-ignored/
|
|
EOF
|
|
|
|
test_expect_success 'status untracked directory with ignored files with --ignore' '
|
|
: >untracked-ignored/ignored &&
|
|
: >untracked-ignored/test/ignored &&
|
|
git status --porcelain --ignored >actual &&
|
|
test_cmp expected actual
|
|
'
|
|
|
|
cat >expected <<\EOF
|
|
?? .gitignore
|
|
?? actual
|
|
?? expected
|
|
!! untracked-ignored/ignored
|
|
!! untracked-ignored/test/ignored
|
|
EOF
|
|
|
|
test_expect_success 'status untracked directory with ignored files with --ignore -u' '
|
|
git status --porcelain --ignored -u >actual &&
|
|
test_cmp expected actual
|
|
'
|
|
|
|
cat >expected <<\EOF
|
|
?? .gitignore
|
|
?? actual
|
|
?? expected
|
|
EOF
|
|
|
|
test_expect_success 'status ignored tracked directory with --ignore' '
|
|
rm -rf untracked-ignored &&
|
|
mkdir tracked &&
|
|
: >tracked/committed &&
|
|
git add tracked/committed &&
|
|
git commit -m. &&
|
|
echo "tracked" >.gitignore &&
|
|
git status --porcelain --ignored >actual &&
|
|
test_cmp expected actual
|
|
'
|
|
|
|
cat >expected <<\EOF
|
|
?? .gitignore
|
|
?? actual
|
|
?? expected
|
|
EOF
|
|
|
|
test_expect_success 'status ignored tracked directory with --ignore -u' '
|
|
git status --porcelain --ignored -u >actual &&
|
|
test_cmp expected actual
|
|
'
|
|
|
|
cat >expected <<\EOF
|
|
?? .gitignore
|
|
?? actual
|
|
?? expected
|
|
EOF
|
|
|
|
test_expect_success 'status ignored tracked directory and ignored file with --ignore' '
|
|
echo "committed" >>.gitignore &&
|
|
git status --porcelain --ignored >actual &&
|
|
test_cmp expected actual
|
|
'
|
|
|
|
cat >expected <<\EOF
|
|
?? .gitignore
|
|
?? actual
|
|
?? expected
|
|
EOF
|
|
|
|
test_expect_success 'status ignored tracked directory and ignored file with --ignore -u' '
|
|
git status --porcelain --ignored -u >actual &&
|
|
test_cmp expected actual
|
|
'
|
|
|
|
cat >expected <<\EOF
|
|
?? .gitignore
|
|
?? actual
|
|
?? expected
|
|
!! tracked/uncommitted
|
|
EOF
|
|
|
|
test_expect_success 'status ignored tracked directory and uncommitted file with --ignore' '
|
|
echo "tracked" >.gitignore &&
|
|
: >tracked/uncommitted &&
|
|
git status --porcelain --ignored >actual &&
|
|
test_cmp expected actual
|
|
'
|
|
|
|
cat >expected <<\EOF
|
|
?? .gitignore
|
|
?? actual
|
|
?? expected
|
|
!! tracked/uncommitted
|
|
EOF
|
|
|
|
test_expect_success 'status ignored tracked directory and uncommitted file with --ignore -u' '
|
|
git status --porcelain --ignored -u >actual &&
|
|
test_cmp expected actual
|
|
'
|
|
|
|
cat >expected <<\EOF
|
|
?? .gitignore
|
|
?? actual
|
|
?? expected
|
|
!! tracked/ignored/
|
|
EOF
|
|
|
|
test_expect_success 'status ignored tracked directory with uncommitted file in untracked subdir with --ignore' '
|
|
rm -rf tracked/uncommitted &&
|
|
mkdir tracked/ignored &&
|
|
: >tracked/ignored/uncommitted &&
|
|
git status --porcelain --ignored >actual &&
|
|
test_cmp expected actual
|
|
'
|
|
|
|
cat >expected <<\EOF
|
|
?? .gitignore
|
|
?? actual
|
|
?? expected
|
|
!! tracked/ignored/uncommitted
|
|
EOF
|
|
|
|
test_expect_success 'status ignored tracked directory with uncommitted file in untracked subdir with --ignore -u' '
|
|
git status --porcelain --ignored -u >actual &&
|
|
test_cmp expected actual
|
|
'
|
|
|
|
cat >expected <<\EOF
|
|
?? .gitignore
|
|
?? actual
|
|
?? expected
|
|
!! tracked/ignored/uncommitted
|
|
EOF
|
|
|
|
test_expect_success 'status ignored tracked directory with uncommitted file in tracked subdir with --ignore' '
|
|
: >tracked/ignored/committed &&
|
|
git add -f tracked/ignored/committed &&
|
|
git commit -m. &&
|
|
git status --porcelain --ignored >actual &&
|
|
test_cmp expected actual
|
|
'
|
|
|
|
cat >expected <<\EOF
|
|
?? .gitignore
|
|
?? actual
|
|
?? expected
|
|
!! tracked/ignored/uncommitted
|
|
EOF
|
|
|
|
test_expect_success 'status ignored tracked directory with uncommitted file in tracked subdir with --ignore -u' '
|
|
git status --porcelain --ignored -u >actual &&
|
|
test_cmp expected actual
|
|
'
|
|
|
|
test_done
|