Skip to content

internal: git-hook tries to add a file that does not exist #14670

Closed
@ada4a

Description

@ada4a

Summary

I was trying to set-up a development environment to add a lint. I set up the git hook, and defined the lint. When I tried to commit the intermediate results, the git hook failed.

Reproducer

I tried this code:

cargo dev new_lint --name=needless_path_new --pass=late
cargo dev setup git-hook
git add .
git commit -m "cargo dev new_lint" 

I expected to see this happen:
successful commit

Instead, this happened:

fatal: pathspec 'clippy_lints/src/lib.*.rs' did not match any files

This is what the output of git diff looked like after I ran git add .:

Changes to be committed:
        modified:   CHANGELOG.md
        modified:   clippy_lints/src/declared_lints.rs
        modified:   clippy_lints/src/lib.rs
        new file:   clippy_lints/src/needless_path_new.rs
        new file:   tests/ui/needless_path_new.rs

so it seems like the pathspec was trying to match the third path, but failed because of the extra . either before or after the *

Version

rustc 1.88.0-nightly (d6c1e454a 2025-04-21)
binary: rustc
commit-hash: d6c1e454aa8af5e7e59fbf5c4e7d3128d2f99582
commit-date: 2025-04-21
host: x86_64-unknown-linux-gnu
release: 1.88.0-nightly
LLVM version: 20.1.2

Additional Labels

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: Clippy is not doing the correct thing

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions