Skip to content
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

IgnoreNode should not always use path match as true #105

Open
Jenson3210 opened this issue Oct 25, 2024 · 1 comment
Open

IgnoreNode should not always use path match as true #105

Jenson3210 opened this issue Oct 25, 2024 · 1 comment

Comments

@Jenson3210
Copy link

Jenson3210 commented Oct 25, 2024

Version

latest

Operating System

Linux/Unix, MacOS

Bug description

a .gitignore file containing a single ignore rule for a directory fails to match correctly.

/directory/nested/

should be ignoring /directory/nested/again directory

Actual behavior

the result given back is CHECK_PARENT

Expected behavior

the result given back is IGNORED

Relevant log output

No response

Other information

I have a test showcasing this behaviour in my fork (will link commit). Here more insights/debugging can be found.

Caused by the fact that IgnoreNode is always passing true as pathMatch to the rule.isMatch

    @Test
    public void fastIgnoreRuleForNestedDirectory() {
        //This PASSES as isMatch returns true
        FastIgnoreRule ignoreRule1 = new FastIgnoreRule("/directory/nested/");
        assertTrue(ignoreRule1.isMatch("/directory/nested/again", true, false));

        //This FAILS as isMatch returns false
        FastIgnoreRule ignoreRule2 = new FastIgnoreRule("/directory/nested/");
        assertTrue(ignoreRule2.isMatch("/directory/nested/again", true, true));
    }
Jenson3210 pushed a commit to Jenson3210/jgit-eclipse that referenced this issue Oct 25, 2024
Jenson3210 pushed a commit to Jenson3210/jgit-eclipse that referenced this issue Oct 25, 2024
@Jenson3210
Copy link
Author

If this is expected behaviour, feel free to close.
In a local test, I validated that the correct behaviour is present when using TreeWalk.

Only weird that IgnoreNode would always result in Check_Parent if clearly ignored by the current node.

I do not really need a fix as I made a workaround which just uses the internally used getRules response and call correct true/false based on the current input.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant