From 7cc916e4f1728f15442a99467520e3ba5ce08126 Mon Sep 17 00:00:00 2001 From: Martin von Zweigbergk Date: Mon, 24 Jul 2023 16:17:04 -0700 Subject: [PATCH] working_copy: in mtime race case, don't mutate current state 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`. --- lib/src/working_copy.rs | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/lib/src/working_copy.rs b/lib/src/working_copy.rs index 4766cf470..f1dd94a4a 100644 --- a/lib/src/working_copy.rs +++ b/lib/src/working_copy.rs @@ -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);