Skip to content

Commit d760263

Browse files
committed
fix(package): ignore status check failure
Dirtiness check for symlinks is mostly informational. And changes in submodule would fail git-status as well (see #15384). To avoid adding complicated logic to handle that, for now we ignore the status check failure.
1 parent 7947398 commit d760263

File tree

2 files changed

+18
-4
lines changed

2 files changed

+18
-4
lines changed

src/cargo/ops/cargo_package/vcs.rs

+16-2
Original file line numberDiff line numberDiff line change
@@ -268,8 +268,22 @@ fn dirty_files_outside_pkg_root(
268268
// Handle files outside package root but under git workdir,
269269
.filter_map(|p| paths::strip_prefix_canonical(p, workdir).ok())
270270
{
271-
if repo.status_file(&rel_path)? != git2::Status::CURRENT {
272-
dirty_files.insert(workdir.join(rel_path));
271+
match repo.status_file(&rel_path) {
272+
Ok(git2::Status::CURRENT) => {}
273+
Ok(_) => {
274+
dirty_files.insert(workdir.join(rel_path));
275+
}
276+
Err(e) => {
277+
// Dirtiness check for symlinks is mostly informational.
278+
// And changes in submodule would fail git-status as well (see #15384).
279+
// To avoid adding complicated logic to handle that,
280+
// for now we ignore the status check failure.
281+
debug!(
282+
"failed to get status from file `{}` in git repo at `{}`: {e}",
283+
rel_path.display(),
284+
workdir.display()
285+
);
286+
}
273287
}
274288
}
275289
Ok(dirty_files)

tests/testsuite/package.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1467,9 +1467,9 @@ fn dirty_file_outside_pkg_root_inside_submodule() {
14671467
p.change_file("submodule/file.txt", "changed");
14681468

14691469
p.cargo("package --workspace --no-verify")
1470-
.with_status(101)
14711470
.with_stderr_data(str![[r#"
1472-
[ERROR] attempt to get status of nonexistent file 'submodule/file.txt'; class=Invalid (3); code=NotFound (-3)
1471+
[PACKAGING] isengard v0.0.0 ([ROOT]/foo/isengard)
1472+
[PACKAGED] 6 files, [FILE_SIZE]B ([FILE_SIZE]B compressed)
14731473
14741474
"#]])
14751475
.run();

0 commit comments

Comments
 (0)