-
Notifications
You must be signed in to change notification settings - Fork 346
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
jj
ignoring trailing slash in .gitignore
#4718
Comments
JJ internally use ignore ripgrep/ignore crate. ❯ cat .gitignore
/*/ # this should only ignore subdirectories and files in them
❯ rg ba
foo/bar.txt
1:foo/bar.txt
baz.txt
1:baz.txt |
FWIW, the |
That would be amazing. We just ran into an issue with trying to ignore all files except one in a given directory. |
Are you working on it? if not i can try. |
I've started working on porting to As an example, let mut ignore = gix_ignore::Search::default();
ignore.add_patterns_buffer(b"/dir1/dir2/dir3\n", PathBuf::default(), None);
// passes
assert!(ignore.pattern_matching_relative_path(b"dir1/dir2/dir3".into(), Some(true), pattern::Case::Sensitive).is_some());
// fails
assert!(ignore.pattern_matching_relative_path(b"dir1/dir2/dir3/foo".into(), Some(false), pattern::Case::Sensitive).is_some()); But in our tests: #[test]
fn test_gitignore_deep_dir() {
let file = GitIgnoreFile::empty()
.chain("", b"/dir1/dir2/dir3\n")
.unwrap();
assert!(!file.matches("foo"));
assert!(!file.matches("dir1/foo"));
assert!(!file.matches("dir1/dir2/foo"));
assert!(file.matches("dir1/dir2/dir3/foo"));
assert!(file.matches("dir1/dir2/dir3/dir4/foo"));
} I'm diving in now to see if consumers of this API are dependent upon this detail. |
If I ignore the test failures in the I'll dig a little further but it does look like a port to |
There's an API like that in If you wanted to make this change, it might make sense to first switch our code to using that API, then cut over to gitoxide. Alternatively, you could try to wrap the logic to explicitly check all parent paths as well, like this code. Make sure to profile the working copy snapshot time before and after your change. Switching to |
Thanks for the heads up. That's probably a better path forward. It might even be good to expose a second function that explicitly matches without parents, then gradually convert over to that. I'll make sure to profile/benchmark. |
Description
jj
does not seem to correctly handle.gitignore
lines that end with a slash.Instead of only ignoring directories that match the part preceding the trailing slash, it ignores all files that match.
Steps to Reproduce the Problem
Expected Behavior
Both
jj status
andgit status
should show the same list of files, namely.gitignore
,baz.txt
, andwoot.txt
. The subdirectories and the files in them should be ignored.Actual Behavior
Only
git status
shows the expected behaviour.jj status
instead ignores all of the files (including.gitignore
itself).Correct output of
git status
:Incorrect output of
jj status
:Specifications
jj 0.22.0
(Possibly) Related issues/pull requests:
The text was updated successfully, but these errors were encountered: