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/src (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
4 bstr::{BStr, BString, ByteSlice, ByteVec},4 bstr::{BStr, BString, ByteSlice, ByteVec},
5 tree,5 tree,
6};6};
7use std::{collections::BTreeMap, ops::Deref, path::PathBuf};7use std::collections::BTreeMap;
8 8
9/// A Change as observed by a call to [`visit(…)`][visit::Visit::visit()], enhanced with the path affected by the change.9/// A Change as observed by a call to [`visit(…)`][visit::Visit::visit()], enhanced with the path affected by the change.
10/// Its similar to [visit::Change] but includes the path that changed.10/// Its similar to [visit::Change] but includes the path that changed.
@@ -14,12 +14,12 @@ pub enum Change { · 3 unmodified lines
14 Addition {14 Addition {
15 entry_mode: tree::EntryMode,15 entry_mode: tree::EntryMode,
16 oid: ObjectId,16 oid: ObjectId,
17 path: PathBuf,17 path: BString,
18 },18 },
19 Deletion {19 Deletion {
20 entry_mode: tree::EntryMode,20 entry_mode: tree::EntryMode,
21 oid: ObjectId,21 oid: ObjectId,
22 path: PathBuf,22 path: BString,
23 },23 },
24 Modification {24 Modification {
25 previous_entry_mode: tree::EntryMode,25 previous_entry_mode: tree::EntryMode,
@@ -28,7 +28,7 @@ pub enum Change { · 2 unmodified lines
28 entry_mode: tree::EntryMode,28 entry_mode: tree::EntryMode,
29 oid: ObjectId,29 oid: ObjectId,
30 30
31 path: PathBuf,31 path: BString,
32 },32 },
33}33}
34 34
@@ -61,10 +61,6 @@ impl Recorder { · 26 unmodified lines
61 fn path_clone(&self) -> BString {61 fn path_clone(&self) -> BString {
62 self.path.clone()62 self.path.clone()
63 }63 }
64
65 fn path_buf(&self) -> PathBuf {
66 self.path.deref().to_owned().into_path_buf_lossy()
67 }
68}64}
69 65
70impl visit::Visit for Recorder {66impl visit::Visit for Recorder {
@@ -96,12 +92,12 @@ impl visit::Visit for Recorder { · 25 unmodified lines
96 Deletion { entry_mode, oid } => Change::Deletion {92 Deletion { entry_mode, oid } => Change::Deletion {
97 entry_mode,93 entry_mode,
98 oid,94 oid,
99 path: self.path_buf(),95 path: self.path_clone(),
100 },96 },
101 Addition { entry_mode, oid } => Change::Addition {97 Addition { entry_mode, oid } => Change::Addition {
102 entry_mode,98 entry_mode,
103 oid,99 oid,
104 path: self.path_buf(),100 path: self.path_clone(),
105 },101 },
106 Modification {102 Modification {
107 previous_entry_mode,103 previous_entry_mode,
@@ -113,7 +109,7 @@ impl visit::Visit for Recorder { · 5 unmodified lines
113 previous_oid,109 previous_oid,
114 entry_mode,110 entry_mode,
115 oid,111 oid,
116 path: self.path_buf(),112 path: self.path_clone(),
117 },113 },
118 });114 });
119 visit::Action::Continue115 visit::Action::Continue