History

working_copy: don't pass `FileState` through `get_updated_file_state()`

Since the caller now has the `FileState`, there's no need to pass it in by value only to get it back in the return value.

Martin von Zweigbergk committed 3 years ago

Commit cb8ff841 parent 01feb401 file · +13 −12Browse files

Unified · Split

lib/src/working_copy.rs+13−12
@@ -409,8 +409,8 @@ pub enum TreeStateError { · 408 unmodified lines
409}409}
410 410
411enum UpdatedFileState {411enum UpdatedFileState {
412 Unchanged(FileState),412 Unchanged,
413 Changed(TreeValue, FileState),413 Changed(TreeValue),
414}414}
415 415
416impl TreeState {416impl TreeState {
@@ -726,14 +726,15 @@ impl TreeState { · 309 unmodified lines
726 entry.path(),726 entry.path(),
727 maybe_current_file_state,727 maybe_current_file_state,
728 &current_tree,728 &current_tree,
729 new_file_state,729 &new_file_state,
730 )?;730 )?;
731 match update {731 match update {
732 UpdatedFileState::Unchanged(file_state) => {732 UpdatedFileState::Unchanged => {
733 self.file_states.insert(sub_path, file_state);733 self.file_states.insert(sub_path, new_file_state);
734 }734 }
735 UpdatedFileState::Changed(tree_value, file_state) => {735 UpdatedFileState::Changed(tree_value) => {
736 self.file_states.insert(sub_path.clone(), file_state);736 self.file_states
737 .insert(sub_path.clone(), new_file_state);
737 tree_builder.set(sub_path, tree_value);738 tree_builder.set(sub_path, tree_value);
738 }739 }
739 }740 }
@@ -818,7 +819,7 @@ impl TreeState { · 78 unmodified lines
818 disk_path: PathBuf,819 disk_path: PathBuf,
819 maybe_current_file_state: Option<&FileState>,820 maybe_current_file_state: Option<&FileState>,
820 current_tree: &Tree,821 current_tree: &Tree,
821 new_file_state: FileState,822 new_file_state: &FileState,
822 ) -> Result<UpdatedFileState, SnapshotError> {823 ) -> Result<UpdatedFileState, SnapshotError> {
823 let current_file_state = match maybe_current_file_state {824 let current_file_state = match maybe_current_file_state {
824 None => {825 None => {
@@ -826,23 +827,23 @@ impl TreeState { · 1 unmodified line
826 let file_type = new_file_state.file_type.clone();827 let file_type = new_file_state.file_type.clone();
827 let file_value =828 let file_value =
828 self.write_path_to_store(repo_path, &disk_path, None, file_type)?;829 self.write_path_to_store(repo_path, &disk_path, None, file_type)?;
829 return Ok(UpdatedFileState::Changed(file_value, new_file_state));830 return Ok(UpdatedFileState::Changed(file_value));
830 }831 }
831 Some(current_file_state) => current_file_state,832 Some(current_file_state) => current_file_state,
832 };833 };
833 834
834 // If the file's mtime was set at the same time as this state file's own mtime,835 // If the file's mtime was set at the same time as this state file's own mtime,
835 // then we don't know if the file was modified before or after this state file.836 // then we don't know if the file was modified before or after this state file.
836 if current_file_state != &new_file_state || current_file_state.mtime >= self.own_mtime {837 if current_file_state != new_file_state || current_file_state.mtime >= self.own_mtime {
837 let new_file_type = new_file_state.file_type.clone();838 let new_file_type = new_file_state.file_type.clone();
838 let current_tree_value = current_tree.path_value(repo_path);839 let current_tree_value = current_tree.path_value(repo_path);
839 // If the file contained a conflict before and is now a normal file on disk, we840 // If the file contained a conflict before and is now a normal file on disk, we
840 // try to parse any conflict markers in the file into a conflict.841 // try to parse any conflict markers in the file into a conflict.
841 let new_tree_value =842 let new_tree_value =
842 self.write_path_to_store(repo_path, &disk_path, current_tree_value, new_file_type)?;843 self.write_path_to_store(repo_path, &disk_path, current_tree_value, new_file_type)?;
843 return Ok(UpdatedFileState::Changed(new_tree_value, new_file_state));844 return Ok(UpdatedFileState::Changed(new_tree_value));
844 }845 }
845 Ok(UpdatedFileState::Unchanged(new_file_state))846 Ok(UpdatedFileState::Unchanged)
846 }847 }
847 848
848 fn write_conflict_to_store(849 fn write_conflict_to_store(

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t