Skip to content

Missing support for [[:space:]] match group in the ignore crate #2962

Open
@weiznich

Description

@weiznich

Please tick this box to confirm you have reviewed the above.

  • I have a different issue.

What version of ripgrep are you using?

ignore = "0.4.23"

How did you install ripgrep?

Cargo

What operating system are you using ripgrep on?

Fedora

NAME="Fedora Linux"
VERSION="41 (Workstation Edition)"
RELEASE_TYPE=stable
ID=fedora
VERSION_ID=41
VERSION_CODENAME=""
PLATFORM_ID="platform:f41"
PRETTY_NAME="Fedora Linux 41 (Workstation Edition)"
ANSI_COLOR="0;38;2;60;110;180"
LOGO=fedora-logo-icon
CPE_NAME="cpe:/o:fedoraproject:fedora:41"
DEFAULT_HOSTNAME="fedora"
HOME_URL="https://fedoraproject.org/"
DOCUMENTATION_URL="https://docs.fedoraproject.org/en-US/fedora/f41/system-administrators-guide/"
SUPPORT_URL="https://ask.fedoraproject.org/"
BUG_REPORT_URL="https://bugzilla.redhat.com/"
REDHAT_BUGZILLA_PRODUCT="Fedora"
REDHAT_BUGZILLA_PRODUCT_VERSION=41
REDHAT_SUPPORT_PRODUCT="Fedora"
REDHAT_SUPPORT_PRODUCT_VERSION=41
SUPPORT_END=2025-12-15
VARIANT="Workstation Edition"
VARIANT_ID=workstation

Describe your bug.

The ignore crate fails to handle certain character classes as part of it's matcher implementation. I noticed this for [[:space:]] which happens to be contained in some local .gitattributes file I try to parse and use via the ignore crate to teach [jj'](https://github.com/jj-vcs/jj/) to just ignore git-lfs files. Git itself [documents the pattern syntax](https://git-scm.com/docs/gitattributes) to be the same (beside minor restrictions) than that one from .gitignore` files, therefore I've tried to use the ignore crate for this.

What are the steps to reproduce the behavior?

Run the following code and see the assertion fail:

    let mut ignore_builder = ignore::gitignore::GitignoreBuilder::new("");

    ignore_builder.add_line(None, "giga_las/samples/MOAT[[:space:]]HOUSE[[:space:]]FARM[[:space:]]BH_Raw1[[:space:]](Disks).las").unwrap();
    ignore_builder
        .add_line(None, "giga_las/samples/MOAT_HOUSE_FARM_BH_Raw1_(Disks).las")
        .unwrap();

    let ignore = ignore_builder.build().unwrap();

    assert!(matches!(
        ignore.matched(
            "giga_las/samples/MOAT_HOUSE_FARM_BH_Raw1_(Disks).las",
            false
        ),
        ignore::Match::Ignore(_)
    ));

    assert!(
        matches!(
            ignore.matched(
                "giga_las/samples/MOAT HOUSE FARM BH Raw1 (Disks).las",
                false
            ),
            ignore::Match::Ignore(_)
        ),
        "Did not match, did not satisfy the [[:space:]] matchers"
    );

What is the actual behavior?

The assertion fails

What is the expected behavior?

The assertion passes. See the character class tests from the git repository itself here: https://github.com/git/git/blob/8d8387116ae8c3e73f6184471f0c46edbd2c7601/t/t3070-wildmatch.sh#L144 for future examples

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementAn enhancement to the functionality of the software.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions