cargo: cargo-package: list of dirty files contains ignored files
Problem When running “cargo package” it complains about some files containing uncommited change, even though they’re ignored by my .gitignore rules.
This seems to only happen when the file is in a directory that contains a mix of ignored and non-ignored files, but no tracked files at all.
$ git status
On branch master
nothing to commit, working tree clean
$ mkdir new_dir
$ touch new_dir/file
$ touch new_dir/.file.swp
$ git status
On branch master
Untracked files:
(use "git add <file>..." to include in what will be committed)
new_dir/
nothing added to commit but untracked files present (use "git add" to track)
$ git status new_dir/
On branch master
Untracked files:
(use "git add <file>..." to include in what will be committed)
new_dir/file
nothing added to commit but untracked files present (use "git add" to track)
$ cargo package
error: 2 files in the working directory contain changes that were not yet committed into git:
new_dir/.file.swp
new_dir/file
I expect to only see the entry for new_dir/file there, not new_dir/.file.swp.
Notes
Output of cargo version:
$ cargo --version
cargo 1.44.1 (88ba85757 2020-06-11)
About this issue
- Original URL
- State: open
- Created 6 years ago
- Comments: 16 (11 by maintainers)
Commits related to this issue
- Fall back to `--no-verify` while publishing. This is particularly undesirable, but I don't know of any other programmatic way to work around https://github.com/rust-lang/cargo/issues/8407 — committed to cubing/twsearch by lgarron 2 years ago
- Add `--no-verify` to `cargo-publish` to work around https://github.com/rust-lang/cargo/issues/8407 — committed to lgarron/folderify by lgarron a year ago
I was about to say that maybe it’s related to the way the
.gitignorerule is specified, for instance by (more) global git configuration)……but re-reading this means that it can’t be the case.
However, I believe that once the next stage of #11813 (
gitoxidesupport) is rolled out, the issue should disappear and I will be sure to try to verify it truly is fixed then. The reproducer mentioned in the comment right above does not reproduce for me by the way.I am really sorry to hear that and per my previous comment still puzzled how that happens. My hope would be that the
ignorecrate can be replaced withgitoxidewhich I’d expect fixes any issues regarding.gitignorerules, if there are any in the first place.Similar case here, I believe. On macOS, packaging fails for one of my packages because of verification
I have another package on my system which I could package and publish without such issues. Both contain a
.DS_Storefile in the root dir. None has it in.gitignore.As an attempt I added
.DS_Storeto .gitignore in the problematic package but it makes no difference.This reproduces the issue on my system:
git clone git@github.com:holochain/holochain-client-rust.git cargo-testcd cargo-testcargo packageI am experiencing a possible variant of this, but even if it’s not it’s probably worth piggybacking on this issue to keep it simple.
First of all, I believe this will do my best to assure this gets fixed in the
gitoxideimplementation.Now for the problem I am seeing:
src/tbd/is untracked and won’t show up ingit statusas its content,.DS_Storeis ignored.src/.DS_Storehas more files but all.DS_Storefiles are ignored.We can validate this with
gix:Even though it didn’t reproduce this time, I also ran into problems with files that couldn’t be packed into the
cratedue to (intentionally broken) symlinks, even though these are in folders that git-ignored as well.CC @weihanglo