check-ignore: fix mix of directories and other file types
In check_ignore(), the first pathspec item determines the dtype for any subsequent ones. That means that a pathspec matching a regular file can prevent following pathspecs from matching directories, which makes no sense. Fix that by determining the dtype for each pathspec separately, by passing the value DT_UNKNOWN to last_exclude_matching() each time. Signed-off-by: Rene Scharfe <l.s.r@web.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
parent
fc849d8d6b
commit
d60771e930
@ -72,7 +72,7 @@ static int check_ignore(struct dir_struct *dir,
|
|||||||
{
|
{
|
||||||
const char *full_path;
|
const char *full_path;
|
||||||
char *seen;
|
char *seen;
|
||||||
int num_ignored = 0, dtype = DT_UNKNOWN, i;
|
int num_ignored = 0, i;
|
||||||
struct exclude *exclude;
|
struct exclude *exclude;
|
||||||
struct pathspec pathspec;
|
struct pathspec pathspec;
|
||||||
|
|
||||||
@ -104,6 +104,7 @@ static int check_ignore(struct dir_struct *dir,
|
|||||||
full_path = pathspec.items[i].match;
|
full_path = pathspec.items[i].match;
|
||||||
exclude = NULL;
|
exclude = NULL;
|
||||||
if (!seen[i]) {
|
if (!seen[i]) {
|
||||||
|
int dtype = DT_UNKNOWN;
|
||||||
exclude = last_exclude_matching(dir, &the_index,
|
exclude = last_exclude_matching(dir, &the_index,
|
||||||
full_path, &dtype);
|
full_path, &dtype);
|
||||||
}
|
}
|
||||||
|
@ -775,6 +775,26 @@ test_expect_success PIPE 'streaming support for --stdin' '
|
|||||||
echo "$response" | grep "^:: two"
|
echo "$response" | grep "^:: two"
|
||||||
'
|
'
|
||||||
|
|
||||||
|
test_expect_success 'existing file and directory' '
|
||||||
|
test_when_finished "rm one" &&
|
||||||
|
test_when_finished "rmdir top-level-dir" &&
|
||||||
|
>one &&
|
||||||
|
mkdir top-level-dir &&
|
||||||
|
git check-ignore one top-level-dir >actual &&
|
||||||
|
grep one actual &&
|
||||||
|
grep top-level-dir actual
|
||||||
|
'
|
||||||
|
|
||||||
|
test_expect_success 'existing directory and file' '
|
||||||
|
test_when_finished "rm one" &&
|
||||||
|
test_when_finished "rmdir top-level-dir" &&
|
||||||
|
>one &&
|
||||||
|
mkdir top-level-dir &&
|
||||||
|
git check-ignore top-level-dir one >actual &&
|
||||||
|
grep one actual &&
|
||||||
|
grep top-level-dir actual
|
||||||
|
'
|
||||||
|
|
||||||
############################################################################
|
############################################################################
|
||||||
#
|
#
|
||||||
# test whitespace handling
|
# test whitespace handling
|
||||||
|
Loading…
Reference in New Issue
Block a user