diff options
author | Andrew Gallant <jamslam@gmail.com> | 2019-01-23 19:46:15 -0500 |
---|---|---|
committer | Andrew Gallant <jamslam@gmail.com> | 2019-01-23 19:59:39 -0500 |
commit | 9c940b45f4f81b51eee7dcf5836fb3680cf6b62c (patch) | |
tree | 8a8814010eeeb6c69b9b248764bb19ee23001c57 /ignore/src | |
parent | 0a167021c36f6946fc586f4c76e66ab627f4cc04 (diff) |
globset: permit ** to appear anywhere
Previously, `man gitignore` specified that `**` was invalid unless it
was used in one of a few specific circumstances, i.e., `**`, `a/**`,
`**/b` or `a/**/b`. That is, `**` always had to be surrounded by either
a path separator or the beginning/end of the pattern.
It turns out that git itself has treated `**` outside the above contexts
as valid for quite a while, so there was an inconsistency between the
spec `man gitignore` and the implementation, and it wasn't clear which
was actually correct.
@okdana filed a bug against git[1] and got this fixed. The spec was wrong,
which has now been fixed [2] and updated[2].
This commit brings ripgrep in line with git and treats `**` outside of
the above contexts as two consecutive `*` patterns. We deprecate the
`InvalidRecursive` error since it is no longer used.
Fixes #373, Fixes #1098
[1] - https://public-inbox.org/git/C16A9F17-0375-42F9-90A9-A92C9F3D8BBA@dana.is
[2] - https://github.com/git/git/commit/627186d0206dcb219c43f8e6670b4487802a4921
[3] - https://git-scm.com/docs/gitignore
Diffstat (limited to 'ignore/src')
-rw-r--r-- | ignore/src/dir.rs | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/ignore/src/dir.rs b/ignore/src/dir.rs index 30f4cb87..3ba0ede8 100644 --- a/ignore/src/dir.rs +++ b/ignore/src/dir.rs @@ -869,7 +869,7 @@ mod tests { #[test] fn errored() { let td = tmpdir("ignore-test-"); - wfile(td.path().join(".gitignore"), "f**oo"); + wfile(td.path().join(".gitignore"), "{foo"); let (_, err) = IgnoreBuilder::new().build().add_child(td.path()); assert!(err.is_some()); @@ -878,8 +878,8 @@ mod tests { #[test] fn errored_both() { let td = tmpdir("ignore-test-"); - wfile(td.path().join(".gitignore"), "f**oo"); - wfile(td.path().join(".ignore"), "fo**o"); + wfile(td.path().join(".gitignore"), "{foo"); + wfile(td.path().join(".ignore"), "{bar"); let (_, err) = IgnoreBuilder::new().build().add_child(td.path()); assert_eq!(2, partial(err.expect("an error")).len()); @@ -889,7 +889,7 @@ mod tests { fn errored_partial() { let td = tmpdir("ignore-test-"); mkdirp(td.path().join(".git")); - wfile(td.path().join(".gitignore"), "f**oo\nbar"); + wfile(td.path().join(".gitignore"), "{foo\nbar"); let (ig, err) = IgnoreBuilder::new().build().add_child(td.path()); assert!(err.is_some()); @@ -899,7 +899,7 @@ mod tests { #[test] fn errored_partial_and_ignore() { let td = tmpdir("ignore-test-"); - wfile(td.path().join(".gitignore"), "f**oo\nbar"); + wfile(td.path().join(".gitignore"), "{foo\nbar"); wfile(td.path().join(".ignore"), "!bar"); let (ig, err) = IgnoreBuilder::new().build().add_child(td.path()); |