mirror of
https://github.com/martinvonz/jj.git
synced 2025-01-28 23:32:41 +00:00
working_copy: drop optimization for exec-bit-only change
When updating the working copy from one tree to another, if only the executable bit has changed between the two trees, we set the executable bit on the file without touching its contents. The optimization probably gets used quite rarely. Maybe it's even so rarely that it's a pessimization overall. Perhaps its value lies more in that we avoid updating the file's mtime unnecessarily. Either way, I'm about to change this code to use `Merge<Option<TreeValue>>` and that will make this block more complex. I don't think it's worth the complexity even it provides some small benefit sometimes.
This commit is contained in:
parent
89b7b0bfe8
commit
2151fd8930
1 changed files with 0 additions and 24 deletions
|
@ -114,13 +114,6 @@ impl FileState {
|
|||
size: 0,
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(unix)]
|
||||
fn mark_executable(&mut self, executable: bool) {
|
||||
if let FileType::Normal { .. } = &self.file_type {
|
||||
self.file_type = FileType::Normal { executable }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub struct TreeState {
|
||||
|
@ -1251,23 +1244,6 @@ impl TreeState {
|
|||
self.file_states.remove(&path);
|
||||
stats.removed_files += 1;
|
||||
}
|
||||
(
|
||||
Some(TreeValue::File {
|
||||
id: old_id,
|
||||
executable: old_executable,
|
||||
}),
|
||||
Some(TreeValue::File { id, executable }),
|
||||
) if id == old_id => {
|
||||
// Optimization for when only the executable bit changed
|
||||
assert_ne!(executable, old_executable);
|
||||
#[cfg(unix)]
|
||||
{
|
||||
self.set_executable(&disk_path, executable)?;
|
||||
let file_state = self.file_states.get_mut(&path).unwrap();
|
||||
file_state.mark_executable(executable);
|
||||
}
|
||||
stats.updated_files += 1;
|
||||
}
|
||||
(before, Some(after)) => {
|
||||
if before.is_some() {
|
||||
fs::remove_file(&disk_path).ok();
|
||||
|
|
Loading…
Reference in a new issue