karajan1001: ```
(0.00 durations hidden.  Use -vv to show these durations.)
=========================== short test summary info ===========================
FAILED tests/func/test_ignore.py::test_multi_ignore_file - AssertionError: as...
===== 1 failed, 1323 passed, 89 skipped, 8 warnings in 713.38s (0:11:53) ======
The command "bash ./scripts/ci/script.sh" exited with 1.
cache.2
store build cache
```

Might there be more details in the log from Travis CI 
pared: @karajan1001 
The log from Travis indicates that `test_ignore_multi` failed.

```
   def test_multi_ignore_file(tmp_dir, dvc, monkeypatch):
        tmp_dir.gen({"dir": {"subdir": {"should_ignore": "1", "not_ignore": "1"}}})
        tmp_dir.gen(DvcIgnore.DVCIGNORE_FILE, "dir/subdir/*_ignore")
        tmp_dir.gen({"dir": {DvcIgnore.DVCIGNORE_FILE: "!subdir/not_ignore"}})
    
>       assert _files_set("dir", dvc.tree) == {
            "dir/subdir/not_ignore",
            "dir/{}".format(DvcIgnore.DVCIGNORE_FILE),
        }
E       AssertionError: assert {'dir/.dvcignore'} == {'dir/.dvcign...r/not_ignore'}
E         Extra items in the right set:
E         'dir/subdir/not_ignore'
E         Full diff:
E         - {'dir/.dvcignore', 'dir/subdir/not_ignore'}
E         + {'dir/.dvcignore'}
```
karajan1001: > @karajan1001
> The log from Travis indicates that `test_ignore_multi` failed.
> 
> ```
>    def test_multi_ignore_file(tmp_dir, dvc, monkeypatch):
>         tmp_dir.gen({"dir": {"subdir": {"should_ignore": "1", "not_ignore": "1"}}})
>         tmp_dir.gen(DvcIgnore.DVCIGNORE_FILE, "dir/subdir/*_ignore")
>         tmp_dir.gen({"dir": {DvcIgnore.DVCIGNORE_FILE: "!subdir/not_ignore"}})
>     
> >       assert _files_set("dir", dvc.tree) == {
>             "dir/subdir/not_ignore",
>             "dir/{}".format(DvcIgnore.DVCIGNORE_FILE),
>         }
> E       AssertionError: assert {'dir/.dvcignore'} == {'dir/.dvcign...r/not_ignore'}
> E         Extra items in the right set:
> E         'dir/subdir/not_ignore'
> E         Full diff:
> E         - {'dir/.dvcignore', 'dir/subdir/not_ignore'}
> E         + {'dir/.dvcignore'}
> ```

Thank you, but the question is where to get this. 


pared: @karajan1001, you don't see the 'Details' link near check?
![travis](https://user-images.githubusercontent.com/10195618/85918303-c6827b80-b861-11ea-802d-c350a17dc43e.png)

If you follow it, there should be build summary, and you should see Jobs and Stages section, where you can see particular builds.
codecov[bot]: # [Codecov](https://codecov.io/gh/iterative/dvc/pull/4120?src=pr&el=h1) Report
> Merging [#4120](https://codecov.io/gh/iterative/dvc/pull/4120?src=pr&el=desc) into [master](https://codecov.io/gh/iterative/dvc/commit/efcf4e331258ea0893b98275cf5ca28c8bb87b8d&el=desc) will **increase** coverage by `0.31%`.
> The diff coverage is `96.29%`.

[![Impacted file tree graph](https://codecov.io/gh/iterative/dvc/pull/4120/graphs/tree.svg?width=650&height=150&src=pr&token=VOfa1EJWC4)](https://codecov.io/gh/iterative/dvc/pull/4120?src=pr&el=tree)

```diff
@@            Coverage Diff             @@
##           master    #4120      +/-   ##
==========================================
+ Coverage   92.45%   92.76%   +0.31%     
==========================================
  Files         162      162              
  Lines       11274    11278       +4     
==========================================
+ Hits        10423    10462      +39     
+ Misses        851      816      -35     
```


| [Impacted Files](https://codecov.io/gh/iterative/dvc/pull/4120?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [dvc/command/destroy.py](https://codecov.io/gh/iterative/dvc/pull/4120/diff?src=pr&el=tree#diff-ZHZjL2NvbW1hbmQvZGVzdHJveS5weQ==) | `59.09% <0.00%> (ø)` | |
| [dvc/command/install.py](https://codecov.io/gh/iterative/dvc/pull/4120/diff?src=pr&el=tree#diff-ZHZjL2NvbW1hbmQvaW5zdGFsbC5weQ==) | `64.70% <0.00%> (ø)` | |
| [dvc/logger.py](https://codecov.io/gh/iterative/dvc/pull/4120/diff?src=pr&el=tree#diff-ZHZjL2xvZ2dlci5weQ==) | `87.50% <0.00%> (ø)` | |
| [dvc/remote/base.py](https://codecov.io/gh/iterative/dvc/pull/4120/diff?src=pr&el=tree#diff-ZHZjL3JlbW90ZS9iYXNlLnB5) | `95.54% <ø> (+0.13%)` | :arrow_up: |
| [dvc/repo/plots/\_\_init\_\_.py](https://codecov.io/gh/iterative/dvc/pull/4120/diff?src=pr&el=tree#diff-ZHZjL3JlcG8vcGxvdHMvX19pbml0X18ucHk=) | `92.42% <ø> (ø)` | |
| [dvc/stage/\_\_init\_\_.py](https://codecov.io/gh/iterative/dvc/pull/4120/diff?src=pr&el=tree#diff-ZHZjL3N0YWdlL19faW5pdF9fLnB5) | `99.12% <ø> (ø)` | |
| [dvc/utils/fs.py](https://codecov.io/gh/iterative/dvc/pull/4120/diff?src=pr&el=tree#diff-ZHZjL3V0aWxzL2ZzLnB5) | `92.85% <ø> (-0.06%)` | :arrow_down: |
| [dvc/api.py](https://codecov.io/gh/iterative/dvc/pull/4120/diff?src=pr&el=tree#diff-ZHZjL2FwaS5weQ==) | `97.67% <100.00%> (ø)` | |
| [dvc/command/base.py](https://codecov.io/gh/iterative/dvc/pull/4120/diff?src=pr&el=tree#diff-ZHZjL2NvbW1hbmQvYmFzZS5weQ==) | `96.87% <100.00%> (+0.20%)` | :arrow_up: |
| [dvc/command/diff.py](https://codecov.io/gh/iterative/dvc/pull/4120/diff?src=pr&el=tree#diff-ZHZjL2NvbW1hbmQvZGlmZi5weQ==) | `94.20% <100.00%> (ø)` | |
| ... and [32 more](https://codecov.io/gh/iterative/dvc/pull/4120/diff?src=pr&el=tree-more) | |

------

[Continue to review full report at Codecov](https://codecov.io/gh/iterative/dvc/pull/4120?src=pr&el=continue).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/iterative/dvc/pull/4120?src=pr&el=footer). Last update [efcf4e3...25bfcd3](https://codecov.io/gh/iterative/dvc/pull/4120?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).

karajan1001: Needs more tests. And Some Improvements
karajan1001: > If you follow it, there should be build summary, and you should see Jobs and Stages section, where you can see particular builds.
@pared 

For example in
https://travis-ci.com/github/iterative/dvc/jobs/354665083

I can only get this.
![image](https://user-images.githubusercontent.com/6745454/85938779-c312f100-b942-11ea-8151-df662cc4c177.png)

No more detail.


efiop: Hi @karajan1001 ! Full logs are starting here https://travis-ci.com/github/iterative/dvc/jobs/354665083#L3357 
karajan1001: > Hi @karajan1001 ! Full logs are starting here https://travis-ci.com/github/iterative/dvc/jobs/354665083#L3357

@efiop  Thank you, it seems that only members of the DVC have the permission. 
![image](https://user-images.githubusercontent.com/6745454/85968700-565a2e00-b9f8-11ea-98d3-495f58dbe4af.png)

karajan1001: More tests are needed.
skshetry: @karajan1001, from your https://github.com/iterative/dvc/pull/4120#issuecomment-650699341, it looks like you are able to access it. You have to search manually in that huge log for specific test failure. Or, download the raw log and grep locally.

If you are not able to, you can download the log of a specific job with following url: 

`https://api.travis-ci.com/v3/job/{job-id}/log.txt` (subsitute job id)

Eg: https://api.travis-ci.com/v3/job/354665083/log.txt
karajan1001: > @karajan1001, from your [#4120 (comment)](https://github.com/iterative/dvc/pull/4120#issuecomment-650699341), it looks like you are able to access it. You have to search manually in that huge log for specific test failure. Or, download the raw log and grep locally.
> 
> If you are not able to, you can download the log of a specific job with following url:
> 
> `https://api.travis-ci.com/v3/job/{job-id}/log.txt` (subsitute job id)
> 
> Eg: https://api.travis-ci.com/v3/job/354665083/log.txt

@skshetry Thank you, but, I had tried this on this PR 2 days ago. The result is the same as what is in the `https://api.travis-ci.com/v3/job/354665083/log.txt`

![image](https://user-images.githubusercontent.com/6745454/85993815-7c4bf680-ba29-11ea-99ee-8bf6d93a6899.png)

karajan1001: > 1 thing that I found.
> 
> > More tests are needed, especially the merging of two ignore files and the influence of the changing of the dirname .
> 
> Besides that LGTM. @karajan1001 Do you intend to introduce those tests in this PR?

Of course. I would like to add every test I could think of according to the [gitignore document](https://git-scm.com/docs/gitignore).
It would be a systematic test. It may make DVC users in trouble if this algorithm changed frequently.
Like what `PathSpec`'s author says in [cpburnz/python-path-specification#19](https://github.com/cpburnz/python-path-specification/issues/19)

> I suspect the discrepancy is that a .gitignore does additional filtering beyond that of Git's wildmatch algorithm. If I fixed this in my implementation of wildmatch, it could unexpectedly change the results of anyone already using this for a purpose other than emulating .gitingore.



karajan1001: ![Screenshot from 2020-07-05 16-06-01](https://user-images.githubusercontent.com/6745454/86528324-806c8e00-bed9-11ea-800c-e7fdd0e86ee2.png)

Current benchmark result
karajan1001: > No output has been received in the last 10m0s, this potentially indicates a stalled build or something wrong with the build itself.
Check the details on how to adjust your build configuration on: https://docs.travis-ci.com/user/common-build-problems/#build-times-out-because-no-output-was-received
The build has been terminated

What is this error?
pared: @karajan1001 That does not seem like like an issue with your PR, I got the same error in other repository handled by Travis. Maybe it's their issue. For now, I am restarting the build, lets see how does it go this time.
karajan1001: > @karajan1001 That does not seem like like an issue with your PR, I got the same error in other repository handled by Travis. Maybe it's their issue. For now, I am restarting the build, lets see how does it go this time.

@pared Thank you very much.
karajan1001: > It looks like you are reimplementing or completing implementing `GitWildMatchPattern`:
> 
> 1. Is this unavodable?
> 2. If it is then can this be made in `GitWildMatchPattern`?
> 3. If it can't then can it be separated from `dvc/ignore`, i.e. any logic not specific to dvc moved separately?

@Suor Thank you.
I learned a lot from your following advice. 
But, I didn't reimplement `GitWildMatchPattern`. What I'm doing is only changing the relative path of the `.dvcignore` file. And this is required if we merged two `.dvcignore` rules in different paths.
For example, if we had 
```
a
b
```
in  `/home/.dvcignore`
and 
```
!aa
!bb
```
in `/home/dir/.dvcignore`

And if we want to replace these two files in one.  We must translate one of them to another's directory.

We can choose:
1. change `/home/.dvcignore` into `/home/dir` but it is harder  
> But quicker I think because we can drop those rules which only influence other directories.  I was not as familiar with `gitignore` as now when I made this decision and overestimated the difficulty. I'd like to redo it this way this week.

2. change `/home/dir/.dvcignore` into `/home/` and then it would be
```
!/dir/**/aa
!/dir/**/bb
```
Suor: @karajan1001 Yes, this what I meant. You are implementing some math on top of `GitWildMatchPattern`. It looks like `pathspec` is a proper place to place this math or at least make it separate from `dvc/ignore`, i.e. make some `pathspec_math.py` with all those ops, which might be used from `dvc/ignore`:

```python
pattern = pathspec_add(
    (prefix1, pattern1),
    (prefix2, pattern2),
    ...
)
```

Then this `pathspec_math` might be separated or even contributed back to `pathspec`.
karajan1001: > @karajan1001 Yes, this what I meant. You are implementing some math on top of `GitWildMatchPattern`. It looks like `pathspec` is a proper place to place this math or at least make it separate from `dvc/ignore`, i.e. make some `pathspec_math.py` with all those ops, which might be used from `dvc/ignore`:
> 
> ```python
> pattern = join_patterns(
>     (prefix1, pattern1),
>     (prefix2, pattern2),
>     ...
> )
> ```
> 
> Then this `pathspec_math` might be separated or even contributed back to `pathspec`.

@Suor . Thank you. 
Sorry that I overlooked point 3.

I'm busy at work and can't pay much attention here.  

Suor: @karajan1001 NP. This is really nice performance tuning work.
efiop: Thank you @karajan1001 ! 
diff --git a/dvc/ignore.py b/dvc/ignore.py
index 946e5077e..2ab78ea00 100644
--- a/dvc/ignore.py
+++ b/dvc/ignore.py
@@ -6,8 +6,10 @@ from itertools import groupby
 from funcy import cached_property
 from pathspec.patterns import GitWildMatchPattern
 from pathspec.util import normalize_file
+from pygtrie import StringTrie
 
 from dvc.path_info import PathInfo
+from dvc.pathspec_math import merge_patterns
 from dvc.scm.tree import BaseTree
 from dvc.system import System
 from dvc.utils import relpath
@@ -23,25 +25,33 @@ class DvcIgnore:
 
 
 class DvcIgnorePatterns(DvcIgnore):
-    def __init__(self, ignore_file_path, tree):
-        assert os.path.isabs(ignore_file_path)
+    def __init__(self, pattern_list, dirname):
+
+        self.pattern_list = pattern_list
+        self.dirname = dirname
+        self.prefix = self.dirname + os.sep
 
-        self.ignore_file_path = ignore_file_path
-        self.dirname = os.path.normpath(os.path.dirname(ignore_file_path))
+        regex_pattern_list = map(
+            GitWildMatchPattern.pattern_to_regex, pattern_list
+        )
 
+        self.ignore_spec = [
+            (ignore, re.compile("|".join(item[0] for item in group)))
+            for ignore, group in groupby(regex_pattern_list, lambda x: x[1])
+            if ignore is not None
+        ]
+
+    @classmethod
+    def from_files(cls, ignore_file_path, tree):
+        assert os.path.isabs(ignore_file_path)
+        dirname = os.path.normpath(os.path.dirname(ignore_file_path))
         with tree.open(ignore_file_path, encoding="utf-8") as fobj:
-            path_spec_lines = fobj.readlines()
-            regex_pattern_list = map(
-                GitWildMatchPattern.pattern_to_regex, path_spec_lines
-            )
-            self.ignore_spec = [
-                (ignore, re.compile("|".join(item[0] for item in group)))
-                for ignore, group in groupby(
-                    regex_pattern_list, lambda x: x[1]
-                )
-                if ignore is not None
+            path_spec_lines = [
+                line for line in map(str.strip, fobj.readlines()) if line
             ]
 
+        return cls(path_spec_lines, dirname)
+
     def __call__(self, root, dirs, files):
         files = [f for f in files if not self.matches(root, f)]
         dirs = [d for d in dirs if not self.matches(root, d, True)]
@@ -51,11 +61,10 @@ class DvcIgnorePatterns(DvcIgnore):
     def matches(self, dirname, basename, is_dir=False):
         # NOTE: `relpath` is too slow, so we have to assume that both
         # `dirname` and `self.dirname` are relative or absolute together.
-        prefix = self.dirname + os.sep
         if dirname == self.dirname:
             path = basename
-        elif dirname.startswith(prefix):
-            rel = dirname[len(prefix) :]
+        elif dirname.startswith(self.prefix):
+            rel = dirname[len(self.prefix) :]
             # NOTE: `os.path.join` is ~x5.5 slower
             path = f"{rel}{os.sep}{basename}"
         else:
@@ -79,13 +88,47 @@ class DvcIgnorePatterns(DvcIgnore):
         return result
 
     def __hash__(self):
-        return hash(self.ignore_file_path)
+        return hash(self.dirname + ":" + "\n".join(self.pattern_list))
 
     def __eq__(self, other):
         if not isinstance(other, DvcIgnorePatterns):
             return NotImplemented
+        return (self.dirname == other.dirname) & (
+            self.pattern_list == other.pattern_list
+        )
+
+    def __bool__(self):
+        return bool(self.pattern_list)
 
-        return self.ignore_file_path == other.ignore_file_path
+
+class DvcIgnorePatternsTrie(DvcIgnore):
+    trie = None
+
+    def __init__(self):
+        if self.trie is None:
+            self.trie = StringTrie(separator=os.sep)
+
+    def __call__(self, root, dirs, files):
+        ignore_pattern = self[root]
+        if ignore_pattern:
+            return ignore_pattern(root, dirs, files)
+        return dirs, files
+
+    def __setitem__(self, root, ignore_pattern):
+        base_pattern = self[root]
+        common_dirname, merged_pattern = merge_patterns(
+            base_pattern.dirname,
+            base_pattern.pattern_list,
+            ignore_pattern.dirname,
+            ignore_pattern.pattern_list,
+        )
+        self.trie[root] = DvcIgnorePatterns(merged_pattern, common_dirname)
+
+    def __getitem__(self, root):
+        ignore_pattern = self.trie.longest_prefix(root)
+        if ignore_pattern:
+            return ignore_pattern.value
+        return DvcIgnorePatterns([], root)
 
 
 class DvcIgnoreDirs(DvcIgnore):
@@ -127,14 +170,19 @@ class DvcIgnoreFilter:
             DvcIgnoreDirs([".git", ".hg", ".dvc"]),
             DvcIgnoreRepo(),
         }
-        for root, dirs, files in self.tree.walk(self.root_dir):
-            self._update(root)
-            dirs[:], files[:] = self(root, dirs, files)
-
-    def _update(self, dirname):
+        ignore_pattern_trie = DvcIgnorePatternsTrie()
+        for root, dirs, _ in self.tree.walk(self.root_dir):
+            ignore_pattern = self._get_ignore_pattern(root)
+            if ignore_pattern:
+                ignore_pattern_trie[root] = ignore_pattern
+                self.ignores.add(ignore_pattern_trie)
+            dirs[:], _ = self(root, dirs, [])
+
+    def _get_ignore_pattern(self, dirname):
         ignore_file_path = os.path.join(dirname, DvcIgnore.DVCIGNORE_FILE)
         if self.tree.exists(ignore_file_path):
-            self.ignores.add(DvcIgnorePatterns(ignore_file_path, self.tree))
+            return DvcIgnorePatterns.from_files(ignore_file_path, self.tree)
+        return None
 
     def __call__(self, root, dirs, files):
         for ignore in self.ignores:
diff --git a/dvc/pathspec_math.py b/dvc/pathspec_math.py
new file mode 100644
index 000000000..7377fe4bc
--- /dev/null
+++ b/dvc/pathspec_math.py
@@ -0,0 +1,85 @@
+# Path Specification Pattern Math
+# Including changing base dir of path specification patterns and merging
+# of two path specification patterns with different base
+# All the operations follow the documents of `gitignore`
+import os
+
+from pathspec.util import normalize_file
+
+
+def _not_ignore(rule):
+    return (True, rule[1:]) if rule.startswith("!") else (False, rule)
+
+
+def _is_comment(rule):
+    return rule.startswith("#")
+
+
+def _remove_slash(rule):
+    if rule.startswith("\\"):
+        return rule[1:]
+    return rule
+
+
+def _match_all_level(rule):
+    if rule[:-1].find("/") >= 0 and not rule.startswith("**/"):
+        if rule.startswith("/"):
+            rule = rule[1:]
+        return False, rule
+    if rule.startswith("**/"):
+        rule = rule[3:]
+    return True, rule
+
+
+def change_rule(rule, rel):
+    rule = rule.strip()
+    if _is_comment(rule):
+        return rule
+    not_ignore, rule = _not_ignore(rule)
+    match_all, rule = _match_all_level(rule)
+    rule = _remove_slash(rule)
+    if not match_all:
+        rule = f"/{rule}"
+    else:
+        rule = f"/**/{rule}"
+    if not_ignore:
+        rule = f"!/{rel}{rule}"
+    else:
+        rule = f"/{rel}{rule}"
+    rule = normalize_file(rule)
+    return rule
+
+
+def _change_dirname(dirname, pattern_list, new_dirname):
+    if new_dirname == dirname:
+        return pattern_list
+    rel = os.path.relpath(dirname, new_dirname)
+    if rel.startswith(".."):
+        raise ValueError("change dirname can only change to parent path")
+
+    return [change_rule(rule, rel) for rule in pattern_list]
+
+
+def merge_patterns(prefix_a, pattern_a, prefix_b, pattern_b):
+    """
+    Merge two path specification patterns.
+
+    This implementation merge two path specification patterns on different
+    bases. It returns the longest common parent directory, and the patterns
+    based on this new base directory.
+    """
+    if not pattern_a:
+        return prefix_b, pattern_b
+    elif not pattern_b:
+        return prefix_a, pattern_a
+
+    longest_common_dir = os.path.commonpath([prefix_a, prefix_b])
+    new_pattern_a = _change_dirname(prefix_a, pattern_a, longest_common_dir)
+    new_pattern_b = _change_dirname(prefix_b, pattern_b, longest_common_dir)
+
+    if len(prefix_a) < len(prefix_b):
+        merged_pattern = new_pattern_a + new_pattern_b
+    else:
+        merged_pattern = new_pattern_b + new_pattern_a
+
+    return longest_common_dir, merged_pattern
diff --git a/setup.cfg b/setup.cfg
index f9dc5b216..826c5f64f 100644
--- a/setup.cfg
+++ b/setup.cfg
@@ -17,7 +17,7 @@ count=true
 [isort]
 include_trailing_comma=true
 known_first_party=dvc,tests
-known_third_party=PyInstaller,RangeHTTPServer,boto3,colorama,configobj,distro,dpath,flaky,flufl,funcy,git,grandalf,mock,moto,nanotime,networkx,packaging,pathspec,pylint,pytest,requests,ruamel,setuptools,shortuuid,shtab,tqdm,voluptuous,yaml,zc
+known_third_party=PyInstaller,RangeHTTPServer,boto3,colorama,configobj,distro,dpath,flaky,flufl,funcy,git,grandalf,mock,moto,nanotime,networkx,packaging,pathspec,pygtrie,pylint,pytest,requests,ruamel,setuptools,shortuuid,shtab,tqdm,voluptuous,yaml,zc
 line_length=79
 force_grid_wrap=0
 use_parentheses=True

optimize dvcignore
From https://github.com/iterative/dvc/pull/3867 it is apparent that we need to bench dvcignore and research if anything else there requires optimization. A user (@courentin ) reported that something simple like
```
data/something
bash_projects
mlruns
notebooks
externals
examples
.circleci
.vscode
.pytest_cache
wandb
```
takes a significant time.

- [ ] add benchmark for this to dvc-bench project
diff --git a/tests/func/test_ignore.py b/tests/func/test_ignore.py
index ee9abd943..c9b9feea1 100644
--- a/tests/func/test_ignore.py
+++ b/tests/func/test_ignore.py
@@ -8,6 +8,7 @@ from dvc.ignore import (
     DvcIgnore,
     DvcIgnoreDirs,
     DvcIgnorePatterns,
+    DvcIgnorePatternsTrie,
     DvcIgnoreRepo,
 )
 from dvc.repo import Repo
@@ -98,12 +99,19 @@ def test_ignore_collecting_dvcignores(tmp_dir, dvc, dname):
 
     assert len(dvc.tree.dvcignore.ignores) == 3
     assert DvcIgnoreDirs([".git", ".hg", ".dvc"]) in dvc.tree.dvcignore.ignores
+    ignore_pattern_trie = None
+    for ignore in dvc.tree.dvcignore.ignores:
+        if isinstance(ignore, DvcIgnorePatternsTrie):
+            ignore_pattern_trie = ignore
+
+    assert ignore_pattern_trie is not None
     assert (
-        DvcIgnorePatterns(
+        DvcIgnorePatterns.from_files(
             os.fspath(top_ignore_file), WorkingTree(dvc.root_dir)
         )
-        in dvc.tree.dvcignore.ignores
+        == ignore_pattern_trie[os.fspath(ignore_file)]
     )
+
     assert any(
         i for i in dvc.tree.dvcignore.ignores if isinstance(i, DvcIgnoreRepo)
     )
@@ -236,3 +244,102 @@ def test_ignore_directory(tmp_dir, dvc):
     assert _files_set("dir", dvc.tree) == {
         "dir/{}".format(DvcIgnore.DVCIGNORE_FILE),
     }
+
+
+def test_multi_ignore_file(tmp_dir, dvc, monkeypatch):
+    tmp_dir.gen({"dir": {"subdir": {"should_ignore": "1", "not_ignore": "1"}}})
+    tmp_dir.gen(DvcIgnore.DVCIGNORE_FILE, "dir/subdir/*_ignore")
+    tmp_dir.gen({"dir": {DvcIgnore.DVCIGNORE_FILE: "!subdir/not_ignore"}})
+
+    assert _files_set("dir", dvc.tree) == {
+        "dir/subdir/not_ignore",
+        "dir/{}".format(DvcIgnore.DVCIGNORE_FILE),
+    }
+
+
+def test_pattern_trie_tree(tmp_dir, dvc):
+    tmp_dir.gen(
+        {
+            "top": {
+                "first": {
+                    DvcIgnore.DVCIGNORE_FILE: "a\nb\nc",
+                    "middle": {
+                        "second": {
+                            DvcIgnore.DVCIGNORE_FILE: "d\ne\nf",
+                            "bottom": {},
+                        }
+                    },
+                },
+            },
+            "other": {DvcIgnore.DVCIGNORE_FILE: "1\n2\n3"},
+        }
+    )
+    ignore_pattern_trie = None
+    for ignore in dvc.tree.dvcignore.ignores:
+        if isinstance(ignore, DvcIgnorePatternsTrie):
+            ignore_pattern_trie = ignore
+            break
+
+    assert ignore_pattern_trie is not None
+    ignore_pattern_top = ignore_pattern_trie[os.fspath(tmp_dir / "top")]
+    ignore_pattern_other = ignore_pattern_trie[os.fspath(tmp_dir / "other")]
+    ignore_pattern_first = ignore_pattern_trie[
+        os.fspath(tmp_dir / "top" / "first")
+    ]
+    ignore_pattern_middle = ignore_pattern_trie[
+        os.fspath(tmp_dir / "top" / "first" / "middle")
+    ]
+    ignore_pattern_second = ignore_pattern_trie[
+        os.fspath(tmp_dir / "top" / "first" / "middle" / "second")
+    ]
+    ignore_pattern_bottom = ignore_pattern_trie[
+        os.fspath(tmp_dir / "top" / "first" / "middle" / "second" / "bottom")
+    ]
+    assert not ignore_pattern_top
+    assert (
+        DvcIgnorePatterns([], os.fspath(tmp_dir / "top")) == ignore_pattern_top
+    )
+    assert (
+        DvcIgnorePatterns(["1", "2", "3"], os.fspath(tmp_dir / "other"))
+        == ignore_pattern_other
+    )
+    assert (
+        DvcIgnorePatterns(
+            ["a", "b", "c"], os.fspath(tmp_dir / "top" / "first")
+        )
+        == ignore_pattern_first
+    )
+    assert (
+        DvcIgnorePatterns(
+            ["a", "b", "c"], os.fspath(tmp_dir / "top" / "first")
+        )
+        == ignore_pattern_middle
+    )
+    assert (
+        DvcIgnorePatterns(
+            [
+                "a",
+                "b",
+                "c",
+                "/middle/second/**/d",
+                "/middle/second/**/e",
+                "/middle/second/**/f",
+            ],
+            os.fspath(tmp_dir / "top" / "first"),
+        )
+        == ignore_pattern_second
+    )
+    assert (
+        DvcIgnorePatterns(
+            [
+                "a",
+                "b",
+                "c",
+                "/middle/second/**/d",
+                "/middle/second/**/e",
+                "/middle/second/**/f",
+            ],
+            os.fspath(tmp_dir / "top" / "first"),
+        )
+        == ignore_pattern_bottom
+    )
diff --git a/tests/unit/test_ignore.py b/tests/unit/test_ignore.py
index 85c46edee..0dcde9c91 100644
--- a/tests/unit/test_ignore.py
+++ b/tests/unit/test_ignore.py
@@ -9,7 +9,7 @@ from dvc.ignore import DvcIgnoreDirs, DvcIgnorePatterns
 def mock_dvcignore(dvcignore_path, patterns):
     tree = MagicMock()
     with patch.object(tree, "open", mock_open(read_data="\n".join(patterns))):
-        ignore_patterns = DvcIgnorePatterns(dvcignore_path, tree)
+        ignore_patterns = DvcIgnorePatterns.from_files(dvcignore_path, tree)
 
     return ignore_patterns
 
diff --git a/tests/unit/test_pathspec_math.py b/tests/unit/test_pathspec_math.py
new file mode 100644
index 000000000..1cc683715
--- /dev/null
+++ b/tests/unit/test_pathspec_math.py
@@ -0,0 +1,72 @@
+import pytest
+
+from dvc.pathspec_math import _change_dirname
+
+
+@pytest.mark.parametrize(
+    "patterns, dirname, changed",
+    [
+        # A line starting with # serves as a comment.
+        ("#comment", "/dir", "#comment"),
+        # Put a backslash ("\") in front of the first hash for patterns that
+        # begin with a hash.
+        ("\\#hash", "/dir", "/dir/**/#hash"),
+        ("\\#hash", "/#dir", "/#dir/**/#hash"),
+        # Trailing spaces are ignored unless they are quoted with
+        # backslash ("\").
+        (" space", "/dir", "/dir/**/space"),
+        ("\\ space", "/dir", "/dir/**/ space"),
+        # An optional prefix "!" which negates the pattern;
+        ("!include", "/dir", "!/dir/**/include"),
+        # Put a backslash ("\") in front of the first "!" for patterns that
+        # begin with a literal "!", for example, "\!important!.txt".
+        ("\\!important!.txt", "/dir", "/dir/**/!important!.txt"),
+        # If there is a separator at the beginning or middle (or both) of the
+        # pattern, then the pattern is relative to the directory level of the
+        # particular .gitignore file itself.
+        ("/separator.txt", "/dir", "/dir/separator.txt"),
+        ("subdir/separator.txt", "/dir", "/dir/subdir/separator.txt"),
+        # Otherwise the pattern may also match at any level below
+        # the .gitignore level.
+        ("no_sep", "/dir", "/dir/**/no_sep"),
+        # If there is a separator at the end of the pattern then the pattern
+        # will only match directories, otherwise the pattern can match both
+        # files and directories.
+        ("doc/fortz/", "/dir", "/dir/doc/fortz/"),
+        ("fortz/", "/dir", "/dir/**/fortz/"),
+        # An asterisk "*" matches anything except a slash.
+        ("*aste*risk*", "/dir", "/dir/**/*aste*risk*"),
+        # The character "?" matches any one character except "/".
+        ("?fi?le?", "/dir", "/dir/**/?fi?le?"),
+        # The range notation, e.g. [a-zA-Z], can be used to match one of the
+        # characters in a range. See fnmatch(3) and the FNM_PATHNAME flag
+        # for a more detailed description.
+        ("[a-zA-Z]file[a-zA-Z]", "/dir", "/dir/**/[a-zA-Z]file[a-zA-Z]"),
+        # Two consecutive asterisks ("**") in patterns matched against full
+        # pathname may have special meaning:
+        # A leading "**" followed by a slash means match in all directories.
+        # For example, "**/foo" matches file or directory "foo" anywhere,
+        # the same as pattern "foo".
+        ("**/foo", "/dir", "/dir/**/foo"),
+        # "**/foo/bar" matches file or directory "bar" anywhere that is
+        # directly under directory "foo".
+        ("**/foo/bar", "/dir", "/dir/**/foo/bar"),
+        # A trailing "/**" matches everything inside.
+        # For example, "abc/**" matches all files inside directory "abc",
+        # relative to the location of the .gitignore file, with infinite depth.
+        ("abc/**", "/dir", "/dir/abc/**"),
+        # A slash followed by two consecutive asterisks then a slash matches
+        # zero or more directories. For example, "a/**/b"
+        # matches "a/b", "a/x/b", "a/x/y/b" and so on.
+        ("a/**/b", "/dir", "/dir/a/**/b"),
+        # Other consecutive asterisks are considered regular asterisks and
+        # will match according to the previous rules.
+        ("/***.txt", "/dir", "/dir/***.txt"),
+        ("data/***", "/dir", "/dir/data/***"),
+        ("***/file.txt", "/dir", "/dir/***/file.txt"),
+        ("***file", "/dir", "/dir/**/***file"),
+        ("a/***/b", "/dir", "/dir/a/***/b"),
+    ],
+)
+def test_dvcignore_pattern_change_dir(tmp_dir, patterns, dirname, changed):
+    assert _change_dirname(dirname, [patterns], "/") == [changed]

pip install -e .[all]
parse_log_pytest
pytest
pytest pytest-cov pytest-xdist pytest-mock pytest-lazy-fixture flaky mock xmltodict awscli google-compute-engine Pygments collective.checkdocs flake8 psutil flake8-docstrings pydocstyle jaraco.windows mock-ssh-server moto rangehttpserver beautifulsoup4 flake8-bugbear flake8-comprehensions flake8-string-format pylint pylint-pytest pylint-plugin-utils wget filelock
apt-get update apt-get install -y gcc
3.7
pytest --no-header -rA --tb=line --color=no -p no:cacheprovider -W ignore::DeprecationWarning
aliyun-python-sdk-core==2.16.0
aliyun-python-sdk-core-v3==2.13.33
aliyun-python-sdk-kms==2.16.5
appdirs==1.4.4
argcomplete==3.1.2
astroid==2.15.8
atpublic==3.1.2
attrs @ file:///croot/attrs_1668696182826/work
autocommand==2.2.2
awscli==1.31.13
azure-common==1.1.28
azure-storage-blob==2.1.0
azure-storage-common==2.1.0
bcrypt==4.2.1
beautifulsoup4==4.13.3
boto==2.49.0
boto3==1.33.13
botocore==1.33.13
cachetools==4.2.4
certifi @ file:///croot/certifi_1671487769961/work/certifi
cffi==1.15.1
charset-normalizer==3.4.1
collective.checkdocs==0.2
colorama==0.4.4
configobj==5.0.9
coverage==7.2.7
crcmod==1.7
cryptography==44.0.2
decorator==5.1.1
dill==0.3.7
distro==1.9.0
docutils==0.16
dpath==2.2.0
-e git+https://github.com/iterative/dvc.git@66def035bfd7c483ce99b963c8c5f1c0cfae48b4#egg=dvc
execnet==2.0.2
filelock==3.12.2
flake8==5.0.4
flake8-bugbear==23.3.12
flake8-comprehensions==3.13.0
flake8-docstrings==1.7.0
flake8-string-format==0.3.0
flaky==3.8.1
flatten-json==0.1.14
flit_core @ file:///opt/conda/conda-bld/flit-core_1644941570762/work/source/flit_core
flufl.lock==3.2
funcy==2.0
future==1.0.0
gitdb==4.0.12
GitPython==3.1.44
google-api-core==2.10.2
google-api-python-client==2.166.0
google-auth==1.35.0
google-auth-httplib2==0.2.0
google-cloud-core==1.7.3
google-cloud-storage==1.19.0
google-compute-engine==2.8.13
google-crc32c==1.5.0
google-resumable-media==2.7.2
googleapis-common-protos==1.69.2
grandalf==0.6
httplib2==0.22.0
idna==3.10
importlib-metadata==4.2.0
importlib-resources==5.12.0
inflect==6.0.5
iniconfig @ file:///home/linux1/recipes/ci/iniconfig_1610983019677/work
isort==5.11.5
jaraco.classes==3.2.3
jaraco.collections==4.2.0
jaraco.context==4.3.0
jaraco.functools==3.7.0
jaraco.structures==2.1.0
jaraco.text==3.11.1
jaraco.ui==2.3.0
jaraco.windows==5.7.0
Jinja2==3.1.6
jmespath==0.10.0
jsonpath-ng==1.7.0
knack==0.12.0
lazy-object-proxy==1.9.0
MarkupSafe==2.1.5
mccabe==0.7.0
mock==5.2.0
mock-ssh-server==0.9.1
more-itertools==9.1.0
moto==4.2.14
nanotime==0.5.2
networkx==2.3
numpy==1.21.6
oauth2client==4.1.3
oss2==2.6.1
packaging @ file:///croot/packaging_1671697413597/work
paramiko==3.5.1
path==16.6.0
pathspec==0.11.2
platformdirs==4.0.0
pluggy @ file:///tmp/build/80754af9/pluggy_1648042572264/work
ply==3.11
protobuf==4.24.4
psutil==7.0.0
py @ file:///opt/conda/conda-bld/py_1644396412707/work
pyarrow==12.0.1
pyasn1==0.5.1
pyasn1-modules==0.3.0
pycodestyle==2.9.1
pycparser==2.21
pycryptodome==3.22.0
pydantic==1.10.21
pydocstyle==6.3.0
pydot==2.0.0
PyDrive2==1.15.4
pyflakes==2.5.0
Pygments==2.17.2
pygtrie==2.3.2
pylint==2.17.7
pylint-plugin-utils==0.8.2
pylint-pytest==1.1.8
PyNaCl==1.5.0
pyOpenSSL==25.0.0
pyparsing==3.1.4
pytest==7.1.2
pytest-cov==4.1.0
pytest-lazy-fixture==0.6.3
pytest-mock==3.11.1
pytest-xdist==3.5.0
python-dateutil==2.9.0.post0
PyYAML==5.3.1
rangehttpserver==1.4.0
requests==2.31.0
responses==0.23.3
rsa==4.7.2
ruamel.yaml==0.18.10
ruamel.yaml.clib==0.2.8
s3transfer==0.8.2
shortuuid==1.0.13
shtab==1.7.1
six==1.17.0
smmap==5.0.2
snowballstemmer==2.2.0
soupsieve==2.4.1
tabulate==0.9.0
tomli @ file:///opt/conda/conda-bld/tomli_1657175507142/work
tomlkit==0.12.5
tqdm==4.67.1
typed-ast==1.5.5
types-PyYAML==6.0.12.12
typing_extensions==4.7.1
uritemplate==4.1.1
urllib3==1.26.20
voluptuous==0.14.1
Werkzeug==2.2.3
wget==3.2
wrapt==1.16.0
xmltodict==0.14.2
zc.lockfile==3.0.post1
zipp @ file:///croot/zipp_1672387121353/work

name: dvc
channels:
  - defaults
  - https://repo.anaconda.com/pkgs/main
  - https://repo.anaconda.com/pkgs/r
  - conda-forge
dependencies:
  - _libgcc_mutex=0.1=main
  - _openmp_mutex=5.1=1_gnu
  - attrs=22.1.0=py37h06a4308_0
  - ca-certificates=2025.2.25=h06a4308_0
  - certifi=2022.12.7=py37h06a4308_0
  - flit-core=3.6.0=pyhd3eb1b0_0
  - importlib_metadata=4.11.3=hd3eb1b0_0
  - iniconfig=1.1.1=pyhd3eb1b0_0
  - ld_impl_linux-64=2.40=h12ee557_0
  - libffi=3.4.4=h6a678d5_1
  - libgcc-ng=11.2.0=h1234567_1
  - libgomp=11.2.0=h1234567_1
  - libstdcxx-ng=11.2.0=h1234567_1
  - ncurses=6.4=h6a678d5_0
  - openssl=1.1.1w=h7f8727e_0
  - packaging=22.0=py37h06a4308_0
  - pip=22.3.1=py37h06a4308_0
  - pluggy=1.0.0=py37h06a4308_1
  - py=1.11.0=pyhd3eb1b0_0
  - pytest=7.1.2=py37h06a4308_0
  - python=3.7.16=h7a1cb2a_0
  - readline=8.2=h5eee18b_0
  - setuptools=65.6.3=py37h06a4308_0
  - sqlite=3.45.3=h5eee18b_0
  - tk=8.6.14=h39e8969_0
  - tomli=2.0.1=py37h06a4308_0
  - wheel=0.38.4=py37h06a4308_0
  - xz=5.6.4=h5eee18b_1
  - zipp=3.11.0=py37h06a4308_0
  - zlib=1.2.13=h5eee18b_1
  - pip:
      - aliyun-python-sdk-core==2.16.0
      - aliyun-python-sdk-core-v3==2.13.33
      - aliyun-python-sdk-kms==2.16.5
      - appdirs==1.4.4
      - argcomplete==3.1.2
      - astroid==2.15.8
      - atpublic==3.1.2
      - autocommand==2.2.2
      - awscli==1.31.13
      - azure-common==1.1.28
      - azure-storage-blob==2.1.0
      - azure-storage-common==2.1.0
      - bcrypt==4.2.1
      - beautifulsoup4==4.13.3
      - boto==2.49.0
      - boto3==1.33.13
      - botocore==1.33.13
      - cachetools==4.2.4
      - cffi==1.15.1
      - charset-normalizer==3.4.1
      - collective-checkdocs==0.2
      - colorama==0.4.4
      - configobj==5.0.9
      - coverage==7.2.7
      - crcmod==1.7
      - cryptography==44.0.2
      - decorator==5.1.1
      - dill==0.3.7
      - distro==1.9.0
      - docutils==0.16
      - dpath==2.2.0
      - dvc==1.1.10+66def0
      - execnet==2.0.2
      - filelock==3.12.2
      - flake8==5.0.4
      - flake8-bugbear==23.3.12
      - flake8-comprehensions==3.13.0
      - flake8-docstrings==1.7.0
      - flake8-string-format==0.3.0
      - flaky==3.8.1
      - flatten-json==0.1.14
      - flufl-lock==3.2
      - funcy==2.0
      - future==1.0.0
      - gitdb==4.0.12
      - gitpython==3.1.44
      - google-api-core==2.10.2
      - google-api-python-client==2.166.0
      - google-auth==1.35.0
      - google-auth-httplib2==0.2.0
      - google-cloud-core==1.7.3
      - google-cloud-storage==1.19.0
      - google-compute-engine==2.8.13
      - google-crc32c==1.5.0
      - google-resumable-media==2.7.2
      - googleapis-common-protos==1.69.2
      - grandalf==0.6
      - httplib2==0.22.0
      - idna==3.10
      - importlib-metadata==4.2.0
      - importlib-resources==5.12.0
      - inflect==6.0.5
      - isort==5.11.5
      - jaraco-classes==3.2.3
      - jaraco-collections==4.2.0
      - jaraco-context==4.3.0
      - jaraco-functools==3.7.0
      - jaraco-structures==2.1.0
      - jaraco-text==3.11.1
      - jaraco-ui==2.3.0
      - jaraco-windows==5.7.0
      - jinja2==3.1.6
      - jmespath==0.10.0
      - jsonpath-ng==1.7.0
      - knack==0.12.0
      - lazy-object-proxy==1.9.0
      - markupsafe==2.1.5
      - mccabe==0.7.0
      - mock==5.2.0
      - mock-ssh-server==0.9.1
      - more-itertools==9.1.0
      - moto==4.2.14
      - nanotime==0.5.2
      - networkx==2.3
      - numpy==1.21.6
      - oauth2client==4.1.3
      - oss2==2.6.1
      - paramiko==3.5.1
      - path==16.6.0
      - pathspec==0.11.2
      - platformdirs==4.0.0
      - ply==3.11
      - protobuf==4.24.4
      - psutil==7.0.0
      - pyarrow==12.0.1
      - pyasn1==0.5.1
      - pyasn1-modules==0.3.0
      - pycodestyle==2.9.1
      - pycparser==2.21
      - pycryptodome==3.22.0
      - pydantic==1.10.21
      - pydocstyle==6.3.0
      - pydot==2.0.0
      - pydrive2==1.15.4
      - pyflakes==2.5.0
      - pygments==2.17.2
      - pygtrie==2.3.2
      - pylint==2.17.7
      - pylint-plugin-utils==0.8.2
      - pylint-pytest==1.1.8
      - pynacl==1.5.0
      - pyopenssl==25.0.0
      - pyparsing==3.1.4
      - pytest-cov==4.1.0
      - pytest-lazy-fixture==0.6.3
      - pytest-mock==3.11.1
      - pytest-xdist==3.5.0
      - python-dateutil==2.9.0.post0
      - pyyaml==5.3.1
      - rangehttpserver==1.4.0
      - requests==2.31.0
      - responses==0.23.3
      - rsa==4.7.2
      - ruamel-yaml==0.18.10
      - ruamel-yaml-clib==0.2.8
      - s3transfer==0.8.2
      - shortuuid==1.0.13
      - shtab==1.7.1
      - six==1.17.0
      - smmap==5.0.2
      - snowballstemmer==2.2.0
      - soupsieve==2.4.1
      - tabulate==0.9.0
      - tomlkit==0.12.5
      - tqdm==4.67.1
      - typed-ast==1.5.5
      - types-pyyaml==6.0.12.12
      - typing-extensions==4.7.1
      - uritemplate==4.1.1
      - urllib3==1.26.20
      - voluptuous==0.14.1
      - werkzeug==2.2.3
      - wget==3.2
      - wrapt==1.16.0
      - xmltodict==0.14.2
      - zc-lockfile==3.0.post1
prefix: /opt/conda/envs/dvc

tests/func/test_ignore.py::test_ignore tests/func/test_ignore.py::test_ignore_unicode tests/func/test_ignore.py::test_rename_ignored_file tests/func/test_ignore.py::test_rename_file tests/func/test_ignore.py::test_remove_ignored_file tests/func/test_ignore.py::test_remove_file tests/func/test_ignore.py::test_dvcignore_in_out_dir tests/func/test_ignore.py::test_ignore_collecting_dvcignores[dir] tests/func/test_ignore.py::test_ignore_collecting_dvcignores[dir/subdir] tests/func/test_ignore.py::test_ignore_on_branch tests/func/test_ignore.py::test_ignore_subrepo tests/func/test_ignore.py::test_ignore_file_in_parent_path[data_struct0-pattern_list0-result_set0] tests/func/test_ignore.py::test_ignore_file_in_parent_path[data_struct1-pattern_list1-result_set1] tests/func/test_ignore.py::test_ignore_file_in_parent_path[data_struct2-pattern_list2-result_set2] tests/func/test_ignore.py::test_ignore_sub_directory tests/func/test_ignore.py::test_ignore_directory tests/func/test_ignore.py::test_multi_ignore_file tests/unit/test_ignore.py::test_match_ignore_from_file[to_ignore-patterns0-True] tests/unit/test_ignore.py::test_match_ignore_from_file[dont_ignore.txt-patterns1-False] tests/unit/test_ignore.py::test_match_ignore_from_file[to_ignore-patterns2-True] tests/unit/test_ignore.py::test_match_ignore_from_file[#to_ignore-patterns3-True] tests/unit/test_ignore.py::test_match_ignore_from_file[#to_ignore-patterns4-False] tests/unit/test_ignore.py::test_match_ignore_from_file[ tests/unit/test_ignore.py::test_match_ignore_from_file[to_ignore.txt-patterns7-True] tests/unit/test_ignore.py::test_match_ignore_from_file[to_ignore.txt-patterns8-False] tests/unit/test_ignore.py::test_match_ignore_from_file[to_ignore.txt-patterns9-True] tests/unit/test_ignore.py::test_match_ignore_from_file[!to_ignore.txt-patterns10-True] tests/unit/test_ignore.py::test_match_ignore_from_file[file-patterns11-True] tests/unit/test_ignore.py::test_match_ignore_from_file[data/file-patterns12-False] tests/unit/test_ignore.py::test_match_ignore_from_file[data/file-patterns13-True] tests/unit/test_ignore.py::test_match_ignore_from_file[other/data/file-patterns14-False] tests/unit/test_ignore.py::test_match_ignore_from_file[/full/path/to/ignore/file/to_ignore-patterns15-True] tests/unit/test_ignore.py::test_match_ignore_from_file[to_ignore.txt-patterns16-True] tests/unit/test_ignore.py::test_match_ignore_from_file[path/to_ignore.txt-patterns17-False] tests/unit/test_ignore.py::test_match_ignore_from_file[data/file.txt-patterns18-True] tests/unit/test_ignore.py::test_match_ignore_from_file[rel/path/path2/to_ignore-patterns19-False] tests/unit/test_ignore.py::test_match_ignore_from_file[file.txt-patterns20-True] tests/unit/test_ignore.py::test_match_ignore_from_file[file.txt-patterns21-True] tests/unit/test_ignore.py::test_match_ignore_from_file[fi/e.txt-patterns22-False] tests/unit/test_ignore.py::test_match_ignore_from_file[file.txt-patterns23-True] tests/unit/test_ignore.py::test_match_ignore_from_file[2ile.txt-patterns24-False] tests/unit/test_ignore.py::test_match_ignore_from_file[rel/p/p2/to_ignore-patterns25-True] tests/unit/test_ignore.py::test_match_ignore_from_file[rel/p/p2/to_ignore-patterns26-True] tests/unit/test_ignore.py::test_match_ignore_from_file[rel/path/path2/dont_ignore-patterns27-False] tests/unit/test_ignore.py::test_match_ignore_from_file[rel/p/p2/to_ignore-patterns28-True] tests/unit/test_ignore.py::test_match_ignore_from_file[rel/p/p2/to_ignore-patterns29-False] tests/unit/test_ignore.py::test_match_ignore_from_file[rel/path/path2/dont_ignore-patterns30-True] tests/unit/test_ignore.py::test_match_ignore_from_file[rel/p/to_ignore-patterns31-True] tests/unit/test_ignore.py::test_match_ignore_from_file[rel/p/p2/to_ignore-patterns32-True] tests/unit/test_ignore.py::test_match_ignore_from_file[rel/path/path2/dont_ignore-patterns33-False] tests/unit/test_ignore.py::test_match_ignore_from_file[rel/path/path2/dont_ignore-patterns34-False] tests/unit/test_ignore.py::test_match_ignore_from_file[to_ignore.txt-patterns35-True] tests/unit/test_ignore.py::test_match_ignore_from_file[path/to_ignore.txt-patterns36-False] tests/unit/test_ignore.py::test_match_ignore_from_file[path/to_ignore.txt-patterns37-True] tests/unit/test_ignore.py::test_match_ignore_from_file[data/file.txt-patterns38-True] tests/unit/test_ignore.py::test_match_ignore_from_file[data/p/file.txt-patterns39-False] tests/unit/test_ignore.py::test_match_ignore_from_file[rel/path/path2/to_ignore-patterns40-False] tests/unit/test_ignore.py::test_should_ignore_dir[.git] tests/unit/test_ignore.py::test_should_ignore_dir[.hg] tests/unit/test_ignore.py::test_should_ignore_dir[.dvc] tests/unit/test_pathspec_math.py::test_dvcignore_pattern_change_dir[#comment-/dir-#comment] tests/unit/test_pathspec_math.py::test_dvcignore_pattern_change_dir[!include-/dir-!/dir/**/include]
tests/func/test_ignore.py::test_match_nested tests/func/test_ignore.py::test_ignore_external tests/func/test_ignore.py::test_ignore_blank_line tests/func/test_ignore.py::test_pattern_trie_tree tests/unit/test_pathspec_math.py::test_dvcignore_pattern_change_dir[\\#hash-/dir-/dir/**/#hash] tests/unit/test_pathspec_math.py::test_dvcignore_pattern_change_dir[\\#hash-/#dir-/#dir/**/#hash] tests/unit/test_pathspec_math.py::test_dvcignore_pattern_change_dir[ tests/unit/test_pathspec_math.py::test_dvcignore_pattern_change_dir[\\ tests/unit/test_pathspec_math.py::test_dvcignore_pattern_change_dir[\\!important!.txt-/dir-/dir/**/!important!.txt] tests/unit/test_pathspec_math.py::test_dvcignore_pattern_change_dir[/separator.txt-/dir-/dir/separator.txt] tests/unit/test_pathspec_math.py::test_dvcignore_pattern_change_dir[subdir/separator.txt-/dir-/dir/subdir/separator.txt] tests/unit/test_pathspec_math.py::test_dvcignore_pattern_change_dir[no_sep-/dir-/dir/**/no_sep] tests/unit/test_pathspec_math.py::test_dvcignore_pattern_change_dir[doc/fortz/-/dir-/dir/doc/fortz/] tests/unit/test_pathspec_math.py::test_dvcignore_pattern_change_dir[fortz/-/dir-/dir/**/fortz/] tests/unit/test_pathspec_math.py::test_dvcignore_pattern_change_dir[*aste*risk*-/dir-/dir/**/*aste*risk*] tests/unit/test_pathspec_math.py::test_dvcignore_pattern_change_dir[?fi?le?-/dir-/dir/**/?fi?le?] tests/unit/test_pathspec_math.py::test_dvcignore_pattern_change_dir[[a-zA-Z]file[a-zA-Z]-/dir-/dir/**/[a-zA-Z]file[a-zA-Z]] tests/unit/test_pathspec_math.py::test_dvcignore_pattern_change_dir[**/foo-/dir-/dir/**/foo] tests/unit/test_pathspec_math.py::test_dvcignore_pattern_change_dir[**/foo/bar-/dir-/dir/**/foo/bar] tests/unit/test_pathspec_math.py::test_dvcignore_pattern_change_dir[abc/**-/dir-/dir/abc/**] tests/unit/test_pathspec_math.py::test_dvcignore_pattern_change_dir[a/**/b-/dir-/dir/a/**/b] tests/unit/test_pathspec_math.py::test_dvcignore_pattern_change_dir[/***.txt-/dir-/dir/***.txt] tests/unit/test_pathspec_math.py::test_dvcignore_pattern_change_dir[data/***-/dir-/dir/data/***] tests/unit/test_pathspec_math.py::test_dvcignore_pattern_change_dir[***/file.txt-/dir-/dir/***/file.txt] tests/unit/test_pathspec_math.py::test_dvcignore_pattern_change_dir[***file-/dir-/dir/**/***file] tests/unit/test_pathspec_math.py::test_dvcignore_pattern_change_dir[a/***/b-/dir-/dir/a/***/b]
dvc/ignore.py dvc/pathspec_math.py setup.cfg
dvc/ignore.py dvc/pathspec_math.py setup.cfg