History

[traverse-tree] one test to pin implementation down a little

Sebastian Thiel committed 5 years ago

Commit f0aeee11 parent c7633f27 files · +235 −15Browse files

Showing the changes to git-diff (1 of 7 files). Show all

Unified · Split

git-diff/src/tree/recorder.rs+7−11
@@ -4,7 +4,7 @@ use git_object::{ · 3 unmodified lines
44 bstr::{BStr, BString, ByteSlice, ByteVec},
55 tree,
66 };
7−use std::{collections::BTreeMap, ops::Deref, path::PathBuf};
7+use std::collections::BTreeMap;
88
99 /// A Change as observed by a call to [`visit(…)`][visit::Visit::visit()], enhanced with the path affected by the change.
1010 /// Its similar to [visit::Change] but includes the path that changed.
@@ -14,12 +14,12 @@ pub enum Change { · 3 unmodified lines
1414 Addition {
1515 entry_mode: tree::EntryMode,
1616 oid: ObjectId,
17− path: PathBuf,
17+ path: BString,
1818 },
1919 Deletion {
2020 entry_mode: tree::EntryMode,
2121 oid: ObjectId,
22− path: PathBuf,
22+ path: BString,
2323 },
2424 Modification {
2525 previous_entry_mode: tree::EntryMode,
@@ -28,7 +28,7 @@ pub enum Change { · 2 unmodified lines
2828 entry_mode: tree::EntryMode,
2929 oid: ObjectId,
3030
31− path: PathBuf,
31+ path: BString,
3232 },
3333 }
3434
@@ -61,10 +61,6 @@ impl Recorder { · 26 unmodified lines
6161 fn path_clone(&self) -> BString {
6262 self.path.clone()
6363 }
64−
65− fn path_buf(&self) -> PathBuf {
66− self.path.deref().to_owned().into_path_buf_lossy()
67− }
6864 }
6965
7066 impl visit::Visit for Recorder {
@@ -96,12 +92,12 @@ impl visit::Visit for Recorder { · 25 unmodified lines
9692 Deletion { entry_mode, oid } => Change::Deletion {
9793 entry_mode,
9894 oid,
99− path: self.path_buf(),
95+ path: self.path_clone(),
10096 },
10197 Addition { entry_mode, oid } => Change::Addition {
10298 entry_mode,
10399 oid,
104− path: self.path_buf(),
100+ path: self.path_clone(),
105101 },
106102 Modification {
107103 previous_entry_mode,
@@ -113,7 +109,7 @@ impl visit::Visit for Recorder { · 5 unmodified lines
113109 previous_oid,
114110 entry_mode,
115111 oid,
116− path: self.path_buf(),
112+ path: self.path_clone(),
117113 },
118114 });
119115 visit::Action::Continue