Skip to content

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

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

Closed
ada4a opened this issue Apr 22, 2025 · 3 comments · Fixed by #14671
Closed

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

ada4a opened this issue Apr 22, 2025 · 3 comments · Fixed by #14671
Labels
C-bug Category: Clippy is not doing the correct thing

Comments

@ada4a
Copy link
Contributor

ada4a commented Apr 22, 2025

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

@ada4a ada4a added the C-bug Category: Clippy is not doing the correct thing label Apr 22, 2025
@ada4a
Copy link
Contributor Author

ada4a commented Apr 22, 2025

Ah, no, it tries to add the non-existing path in the following line:

git add clippy_lints/src/lib.*.rs

Maybe the shell script wasn't updated after the removal of whatever was at this path?

@ada4a
Copy link
Contributor Author

ada4a commented Apr 22, 2025

Yup, removed that line and everything works now

@ada4a
Copy link
Contributor Author

ada4a commented Apr 22, 2025

The line was added in 6035e05, and at that time there were indeed some files matching the pathspec, e.g. https://github.com/rust-lang/rust-clippy/blob/6035e050e83cc991f94797eef4d720c0b61d8955/clippy_lints/src/lib.deprecated.rs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: Clippy is not doing the correct thing
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant