Skip to content
Closed
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions src/ops/lockfile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -208,9 +208,17 @@ fn serialize_resolve(resolve: &Resolve, orig: Option<&str>) -> String {

#[tracing::instrument(skip_all)]
fn are_equal_lockfiles(orig: &str, current: &str, ws: &Workspace<'_>) -> bool {
// If we want to try and avoid updating the lock file, parse both and
// compare them; since this is somewhat expensive, don't do it in the
// common case where we can update lock files.
if orig == current {

@epage epage Aug 1, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Below this is something similar that handles new line changes.

Is significance to the existing precedence? If not, should we move that check up?

View changes since the review

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The order was changed but my question is still relevant.

return true;
}

// Prefer newline-insensitive equality over TOML parse + into_resolve.
if orig.lines().eq(current.lines()) {
return true;
}

// Under --locked/--frozen, allow semantic equality when serialization
// differs beyond line endings but the resolve is unchanged.
if !ws.gctx().lock_update_allowed() {
let res: CargoResult<bool> = (|| {
let old: TomlLockfile = toml::from_str(orig)?;
Expand All @@ -222,7 +230,7 @@ fn are_equal_lockfiles(orig: &str, current: &str, ws: &Workspace<'_>) -> bool {
}
}

orig.lines().eq(current.lines())
false
}

fn emit_package(dep: &toml::Table, out: &mut String) {
Expand Down