2012-12-30 15:39:01 +01:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
test_description='git-status ignored files'
|
|
|
|
|
|
|
|
. ./test-lib.sh
|
|
|
|
|
|
|
|
cat >expected <<\EOF
|
|
|
|
?? .gitignore
|
|
|
|
?? actual
|
|
|
|
?? expected
|
|
|
|
?? untracked/
|
2017-05-18 10:21:50 +02:00
|
|
|
!! untracked/ignored
|
2012-12-30 15:39:01 +01:00
|
|
|
EOF
|
|
|
|
|
2017-05-18 10:21:52 +02:00
|
|
|
test_expect_success 'status untracked directory with --ignored' '
|
2012-12-30 15:39:01 +01:00
|
|
|
echo "ignored" >.gitignore &&
|
|
|
|
mkdir untracked &&
|
|
|
|
: >untracked/ignored &&
|
|
|
|
: >untracked/uncommitted &&
|
|
|
|
git status --porcelain --ignored >actual &&
|
|
|
|
test_cmp expected actual
|
|
|
|
'
|
|
|
|
|
2017-05-18 10:21:52 +02:00
|
|
|
test_expect_success 'same with gitignore starting with BOM' '
|
2015-04-16 16:05:12 +02:00
|
|
|
printf "\357\273\277ignored\n" >.gitignore &&
|
|
|
|
mkdir -p untracked &&
|
|
|
|
: >untracked/ignored &&
|
|
|
|
: >untracked/uncommitted &&
|
|
|
|
git status --porcelain --ignored >actual &&
|
|
|
|
test_cmp expected actual
|
|
|
|
'
|
|
|
|
|
2012-12-30 15:39:01 +01:00
|
|
|
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
|
|
|
|
'
|
2013-04-15 21:09:25 +02:00
|
|
|
cat >expected <<\EOF
|
Revert "dir.c: make 'git-status --ignored' work within leading directories"
Commit be8a84c52669 ("dir.c: make 'git-status --ignored' work within
leading directories", 2013-04-15) noted that
git status --ignored <SOMEPATH>
would not list ignored files and directories within <SOMEPATH> if
<SOMEPATH> was untracked, and modified the behavior to make it show
them. However, it did so via a hack that broke consistency; it would
show paths under <SOMEPATH> differently than a simple
git status --ignored | grep <SOMEPATH>
would show them. A correct fix is slightly more involved, and
complicated slightly by this hack, so we revert this commit (but keep
corrected versions of the testcases) and will later fix the original
bug with a subsequent patch.
Some history may be helpful:
A very, very similar case to the commit we are reverting was raised in
commit 48ffef966c76 ("ls-files: fix overeager pathspec optimization",
2010-01-08); but it actually went in somewhat the opposite direction. In
that commit, it mentioned how
git ls-files -o --exclude-standard t/
used to show untracked files under t/ even when t/ was ignored, and then
changed the behavior to stop showing untracked files under an ignored
directory. More importantly, this commit considered keeping this
behavior but noted that it would be inconsistent with the behavior when
multiple pathspecs were specified and thus rejected it.
The reason for this whole inconsistency when one pathspec is specified
versus zero or two is because common prefixes of pathspecs are sent
through a different set of checks (in treat_leading_path()) than normal
file/directory traversal (those go through read_directory_recursive()
and treat_path()). As such, for consistency, one needs to check that
both codepaths produce the same result.
Revert commit be8a84c526691667fc04a8241d93a3de1de298ab, except instead
of removing the testcase it added, modify it to check for correct and
consistent behavior. A subsequent patch in this series will fix the
testcase.
Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2019-12-10 21:00:21 +01:00
|
|
|
?? untracked/
|
2013-04-15 21:09:25 +02:00
|
|
|
!! untracked/ignored
|
|
|
|
EOF
|
|
|
|
|
2019-12-19 22:28:25 +01:00
|
|
|
test_expect_success 'status of untracked directory with --ignored works with or without prefix' '
|
Revert "dir.c: make 'git-status --ignored' work within leading directories"
Commit be8a84c52669 ("dir.c: make 'git-status --ignored' work within
leading directories", 2013-04-15) noted that
git status --ignored <SOMEPATH>
would not list ignored files and directories within <SOMEPATH> if
<SOMEPATH> was untracked, and modified the behavior to make it show
them. However, it did so via a hack that broke consistency; it would
show paths under <SOMEPATH> differently than a simple
git status --ignored | grep <SOMEPATH>
would show them. A correct fix is slightly more involved, and
complicated slightly by this hack, so we revert this commit (but keep
corrected versions of the testcases) and will later fix the original
bug with a subsequent patch.
Some history may be helpful:
A very, very similar case to the commit we are reverting was raised in
commit 48ffef966c76 ("ls-files: fix overeager pathspec optimization",
2010-01-08); but it actually went in somewhat the opposite direction. In
that commit, it mentioned how
git ls-files -o --exclude-standard t/
used to show untracked files under t/ even when t/ was ignored, and then
changed the behavior to stop showing untracked files under an ignored
directory. More importantly, this commit considered keeping this
behavior but noted that it would be inconsistent with the behavior when
multiple pathspecs were specified and thus rejected it.
The reason for this whole inconsistency when one pathspec is specified
versus zero or two is because common prefixes of pathspecs are sent
through a different set of checks (in treat_leading_path()) than normal
file/directory traversal (those go through read_directory_recursive()
and treat_path()). As such, for consistency, one needs to check that
both codepaths produce the same result.
Revert commit be8a84c526691667fc04a8241d93a3de1de298ab, except instead
of removing the testcase it added, modify it to check for correct and
consistent behavior. A subsequent patch in this series will fix the
testcase.
Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2019-12-10 21:00:21 +01:00
|
|
|
git status --porcelain --ignored >tmp &&
|
|
|
|
grep untracked/ tmp >actual &&
|
|
|
|
rm tmp &&
|
|
|
|
test_cmp expected actual &&
|
|
|
|
|
2013-04-15 21:09:25 +02:00
|
|
|
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
|
|
|
|
'
|
2012-12-30 15:39:01 +01:00
|
|
|
|
|
|
|
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
|
|
|
|
|
2013-04-15 21:08:42 +02:00
|
|
|
test_expect_success 'status empty untracked directory with --ignore' '
|
2012-12-30 15:39:01 +01:00
|
|
|
rm -rf ignored &&
|
|
|
|
mkdir untracked-ignored &&
|
|
|
|
mkdir untracked-ignored/test &&
|
2013-04-15 21:08:42 +02:00
|
|
|
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' '
|
2012-12-30 15:39:01 +01:00
|
|
|
: >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
|
|
|
|
'
|
|
|
|
|
2013-04-15 21:07:16 +02:00
|
|
|
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
|
|
|
|
'
|
|
|
|
|
2012-12-30 15:39:01 +01:00
|
|
|
cat >expected <<\EOF
|
|
|
|
?? .gitignore
|
|
|
|
?? actual
|
|
|
|
?? expected
|
2013-04-15 21:10:05 +02:00
|
|
|
!! tracked/uncommitted
|
2012-12-30 15:39:01 +01:00
|
|
|
EOF
|
|
|
|
|
|
|
|
test_expect_success 'status ignored tracked directory and uncommitted file with --ignore' '
|
2013-04-15 21:07:16 +02:00
|
|
|
echo "tracked" >.gitignore &&
|
2012-12-30 15:39:01 +01:00
|
|
|
: >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
|
|
|
|
'
|
|
|
|
|
2013-04-15 21:05:19 +02:00
|
|
|
cat >expected <<\EOF
|
|
|
|
?? .gitignore
|
|
|
|
?? actual
|
|
|
|
?? expected
|
2013-04-15 21:10:05 +02:00
|
|
|
!! tracked/ignored/
|
2013-04-15 21:05:19 +02:00
|
|
|
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
|
|
|
|
'
|
|
|
|
|
2013-04-15 21:06:30 +02:00
|
|
|
cat >expected <<\EOF
|
|
|
|
?? .gitignore
|
|
|
|
?? actual
|
|
|
|
?? expected
|
2013-04-15 21:10:05 +02:00
|
|
|
!! tracked/ignored/uncommitted
|
2013-04-15 21:06:30 +02:00
|
|
|
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
|
|
|
|
'
|
|
|
|
|
2017-10-25 22:40:40 +02:00
|
|
|
cat >expected <<\EOF
|
|
|
|
!! tracked/submodule/
|
|
|
|
EOF
|
|
|
|
|
|
|
|
test_expect_success 'status ignores submodule in excluded directory' '
|
|
|
|
git init tracked/submodule &&
|
|
|
|
test_commit -C tracked/submodule initial &&
|
|
|
|
git status --porcelain --ignored -u tracked/submodule >actual &&
|
|
|
|
test_cmp expected actual
|
|
|
|
'
|
|
|
|
|
2012-12-30 15:39:01 +01:00
|
|
|
test_done
|