Merge branch 'en/check-ignore' into maint
"git check-ignore" did not work when the given path is explicitly marked as not ignored with a negative entry in the .gitignore file. * en/check-ignore: check-ignore: fix documentation and implementation to match
This commit is contained in:
@ -30,9 +30,15 @@ OPTIONS
|
|||||||
valid with a single pathname.
|
valid with a single pathname.
|
||||||
|
|
||||||
-v, --verbose::
|
-v, --verbose::
|
||||||
Also output details about the matching pattern (if any)
|
Instead of printing the paths that are excluded, for each path
|
||||||
for each given pathname. For precedence rules within and
|
that matches an exclude pattern, print the exclude pattern
|
||||||
between exclude sources, see linkgit:gitignore[5].
|
together with the path. (Matching an exclude pattern usually
|
||||||
|
means the path is excluded, but if the pattern begins with '!'
|
||||||
|
then it is a negated pattern and matching it means the path is
|
||||||
|
NOT excluded.)
|
||||||
|
+
|
||||||
|
For precedence rules within and between exclude sources, see
|
||||||
|
linkgit:gitignore[5].
|
||||||
|
|
||||||
--stdin::
|
--stdin::
|
||||||
Read pathnames from the standard input, one per line,
|
Read pathnames from the standard input, one per line,
|
||||||
|
@ -108,6 +108,9 @@ static int check_ignore(struct dir_struct *dir,
|
|||||||
int dtype = DT_UNKNOWN;
|
int dtype = DT_UNKNOWN;
|
||||||
pattern = last_matching_pattern(dir, &the_index,
|
pattern = last_matching_pattern(dir, &the_index,
|
||||||
full_path, &dtype);
|
full_path, &dtype);
|
||||||
|
if (!verbose && pattern &&
|
||||||
|
pattern->flags & PATTERN_FLAG_NEGATIVE)
|
||||||
|
pattern = NULL;
|
||||||
}
|
}
|
||||||
if (!quiet && (pattern || show_non_matching))
|
if (!quiet && (pattern || show_non_matching))
|
||||||
output_pattern(pathspec.items[i].original, pattern);
|
output_pattern(pathspec.items[i].original, pattern);
|
||||||
|
@ -424,9 +424,24 @@ test_expect_success 'local ignore inside a sub-directory with --verbose' '
|
|||||||
)
|
)
|
||||||
'
|
'
|
||||||
|
|
||||||
test_expect_success_multi 'nested include' \
|
test_expect_success 'nested include of negated pattern' '
|
||||||
'a/b/.gitignore:8:!on* a/b/one' '
|
expect "" &&
|
||||||
test_check_ignore "a/b/one"
|
test_check_ignore "a/b/one" 1
|
||||||
|
'
|
||||||
|
|
||||||
|
test_expect_success 'nested include of negated pattern with -q' '
|
||||||
|
expect "" &&
|
||||||
|
test_check_ignore "-q a/b/one" 1
|
||||||
|
'
|
||||||
|
|
||||||
|
test_expect_success 'nested include of negated pattern with -v' '
|
||||||
|
expect "a/b/.gitignore:8:!on* a/b/one" &&
|
||||||
|
test_check_ignore "-v a/b/one" 0
|
||||||
|
'
|
||||||
|
|
||||||
|
test_expect_success 'nested include of negated pattern with -v -n' '
|
||||||
|
expect "a/b/.gitignore:8:!on* a/b/one" &&
|
||||||
|
test_check_ignore "-v -n a/b/one" 0
|
||||||
'
|
'
|
||||||
|
|
||||||
############################################################################
|
############################################################################
|
||||||
@ -460,7 +475,6 @@ test_expect_success 'cd to ignored sub-directory' '
|
|||||||
expect_from_stdin <<-\EOF &&
|
expect_from_stdin <<-\EOF &&
|
||||||
foo
|
foo
|
||||||
twoooo
|
twoooo
|
||||||
../one
|
|
||||||
seven
|
seven
|
||||||
../../one
|
../../one
|
||||||
EOF
|
EOF
|
||||||
@ -543,7 +557,6 @@ test_expect_success 'global ignore' '
|
|||||||
globalthree
|
globalthree
|
||||||
a/globalthree
|
a/globalthree
|
||||||
a/per-repo
|
a/per-repo
|
||||||
globaltwo
|
|
||||||
EOF
|
EOF
|
||||||
test_check_ignore "globalone per-repo globalthree a/globalthree a/per-repo not-ignored globaltwo"
|
test_check_ignore "globalone per-repo globalthree a/globalthree a/per-repo not-ignored globaltwo"
|
||||||
'
|
'
|
||||||
@ -586,17 +599,7 @@ EOF
|
|||||||
cat <<-\EOF >expected-default
|
cat <<-\EOF >expected-default
|
||||||
one
|
one
|
||||||
a/one
|
a/one
|
||||||
a/b/on
|
|
||||||
a/b/one
|
|
||||||
a/b/one one
|
|
||||||
a/b/one two
|
|
||||||
"a/b/one\"three"
|
|
||||||
a/b/two
|
|
||||||
a/b/twooo
|
a/b/twooo
|
||||||
globaltwo
|
|
||||||
a/globaltwo
|
|
||||||
a/b/globaltwo
|
|
||||||
b/globaltwo
|
|
||||||
EOF
|
EOF
|
||||||
cat <<-EOF >expected-verbose
|
cat <<-EOF >expected-verbose
|
||||||
.gitignore:1:one one
|
.gitignore:1:one one
|
||||||
@ -696,8 +699,12 @@ cat <<-EOF >expected-all
|
|||||||
$global_excludes:2:!globaltwo ../b/globaltwo
|
$global_excludes:2:!globaltwo ../b/globaltwo
|
||||||
:: c/not-ignored
|
:: c/not-ignored
|
||||||
EOF
|
EOF
|
||||||
|
cat <<-EOF >expected-default
|
||||||
|
../one
|
||||||
|
one
|
||||||
|
b/twooo
|
||||||
|
EOF
|
||||||
grep -v '^:: ' expected-all >expected-verbose
|
grep -v '^:: ' expected-all >expected-verbose
|
||||||
sed -e 's/.* //' expected-verbose >expected-default
|
|
||||||
|
|
||||||
broken_c_unquote stdin >stdin0
|
broken_c_unquote stdin >stdin0
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user