| Summary: | Double star pattern in gitignore is not handled correctly | ||||||
|---|---|---|---|---|---|---|---|
| Product: | [Technology] JGit | Reporter: | Andrey Loskutov <loskutov> | ||||
| Component: | JGit | Assignee: | Project Inbox <egit.core-inbox> | ||||
| Status: | RESOLVED FIXED | QA Contact: | |||||
| Severity: | major | ||||||
| Priority: | P3 | CC: | a.krey, david.humeniuk, florianskarten, hendy, matthias.sohn, olim, ovrabec, robin, sanders.philip | ||||
| Version: | 3.1 | Keywords: | helpwanted | ||||
| Target Milestone: | 3.6 | ||||||
| Hardware: | All | ||||||
| OS: | All | ||||||
| See Also: | https://bugs.eclipse.org/bugs/show_bug.cgi?id=440732 | ||||||
| Whiteboard: | |||||||
| Bug Depends on: | |||||||
| Bug Blocks: | 439447 | ||||||
| Attachments: |
|
||||||
|
Description
Andrey Loskutov
Small correction: I've used command line git 1.8.2 and not 1.8.4 (looks like ** pattern was supported even before 1.8.4, but I found only the referenced page with mention of ** pattern). To make that more concise: jgit interprets a ** in a .gitignore pattern just like single * (so **/gen/**/ignore is treated the same as */gen/*/ignore). But C git does do this differently since 1.8.2, and it would be expected that jgit follows C git's behaviour. ** there means zero or more directories, and is valid only with a / following and either at the start of a pattern of with a preceeding slash, so '**ab/cd' or similar isn't valid and currently does the same as '*ab/cd'. A fix, well, actually following C git, would be much appreciated. Created attachment 236755 [details]
Trial mod to handle **
I've done a trial to get the /**/ pattern recognized, but what (little) I did so far has some unexpected effects. I can't yet claim to understand that code, and I'd like some pointers how to implement this.
What happens now is that with **/gen/**/ignore in .gitignore of all the files
# a/b/c/gen/e/f/g/ignore
# a/b/c/gen/e/f/ignore
# a/b/c/gen/e/ignore
# a/b/c/gen/ignore
# a/b/gen/e/f/g/ignore
# a/b/gen/e/f/ignore
# a/b/gen/e/ignore
# a/b/gen/ignore
# a/gen/e/f/g/ignore
# a/gen/e/f/ignore
# a/gen/e/ignore
# a/gen/ignore
# ab/c/gen/e/f/g/ignore
# ab/c/gen/e/f/ignore
# ab/c/gen/e/ignore
# ab/c/gen/ignore
# abc/gen/e/f/g/ignore
# abc/gen/e/f/ignore
# abc/gen/e/ignore
# abc/gen/ignore
# gen/e/f/g/ignore
# gen/e/f/ignore
# gen/e/ignore
# gen/ignore
only the last one (gen/ignore) does not get ignored, which is the only one where both ** match an empty list of path components, and I don't understand yet how I manage to cause that action at a distance. (I would expect it to miss any case where either **/ matches an empty string, not just the case where both are empty.)
(In reply to Andreas Krey from comment #3) ... > yet how I manage to cause that action at a distance. (I would expect it to > miss any case where either **/ matches an empty string, not just the case > where both are empty.) Self-update: Actually, the 'gen/' part is ignored completely, the **/gen/**/ignore matches everything that ends in '/ignore'. Hey Andreas, nice that you're looking into this. I would recommend adding your list of test cases to FileNameMatcherTest (including tests that should not match) and then working out the solution. Isolate the cases that don't yet work and debug them to find out why. (Not sure if you're already doing this.) If you shared the test code, others could to take a look at it, but it might spoil the fun of puzzling it out ;). I also put the original author of this (Florian Köberle) on CC, but I'm not sure if he's still active. Andreas: Any updates on this? *** Bug 427713 has been marked as a duplicate of this bug. *** Gerrit review (proposal, not! final version): https://git.eclipse.org/r/31366 *** Bug 439447 has been marked as a duplicate of this bug. *** (In reply to Andrey Loskutov from comment #8) > Gerrit review (proposal, not! final version): https://git.eclipse.org/r/31366 merged as 2f5a08798eb29e8141c452c0dc2622bc8fe90dd0 *** Bug 456852 has been marked as a duplicate of this bug. *** |