Skip to content

Commit

Permalink
working_copy: in mtime race case, don't mutate current state
Browse files Browse the repository at this point in the history
There's a comment saying that mutating the file's current state
simplifies later logic, but I don't think that's true. It might have
been true in the past, when we had `FileType::Conflict`.
  • Loading branch information
martinvonz committed Jul 24, 2023
1 parent 8d1cb1e commit 7cc916e
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions lib/src/working_copy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -825,11 +825,9 @@ impl TreeState {
}
// If the file's mtime was set at the same time as this state file's own mtime,
// then we don't know if the file was modified before or after this state file.
// We set the file's mtime to 0 to simplify later code.
if current_file_state.mtime >= self.own_mtime {
current_file_state.mtime = MillisSinceEpoch(0);
}
if current_file_state != &new_file_state {
if current_file_state != &new_file_state
|| current_file_state.mtime >= self.own_mtime
{
let new_file_type = new_file_state.file_type.clone();
*current_file_state = new_file_state;
let current_tree_value = current_tree.path_value(&repo_path);
Expand Down

0 comments on commit 7cc916e

Please sign in to comment.