Showing the changes to git-diff/src (2 of 3 files). Show all
Unified · Split
| @@ -1,6 +1,6 @@ | ||
| 1 | 1 | use crate::{ |
| 2 | 2 | tree, |
| 3 | − tree::{visit::Change, TreeInfo, TreeInfoPair}, | |
| 3 | + tree::{visit::Change, TreeInfoPair}, | |
| 4 | 4 | }; |
| 5 | 5 | use git_hash::{oid, ObjectId}; |
| 6 | 6 | use git_object::immutable; |
| @@ -77,24 +77,16 @@ impl<'a> tree::Changes<'a> { · 70 unmodified lines | ||
| 77 | 77 | match state.trees.pop_front() { |
| 78 | 78 | Some((None, Some(rhs))) => { |
| 79 | 79 | delegate.pop_front_tracked_path_and_set_current(); |
| 80 | − rhs_entries = peekable( | |
| 81 | − locate(&rhs.tree_id, &mut state.buf2).ok_or(Error::NotFound { oid: rhs.tree_id })?, | |
| 82 | − ); | |
| 80 | + rhs_entries = peekable(locate(&rhs, &mut state.buf2).ok_or(Error::NotFound { oid: rhs })?); | |
| 83 | 81 | } |
| 84 | 82 | Some((Some(lhs), Some(rhs))) => { |
| 85 | 83 | delegate.pop_front_tracked_path_and_set_current(); |
| 86 | − lhs_entries = peekable( | |
| 87 | − locate(&lhs.tree_id, &mut state.buf1).ok_or(Error::NotFound { oid: lhs.tree_id })?, | |
| 88 | − ); | |
| 89 | − rhs_entries = peekable( | |
| 90 | − locate(&rhs.tree_id, &mut state.buf2).ok_or(Error::NotFound { oid: rhs.tree_id })?, | |
| 91 | − ); | |
| 84 | + lhs_entries = peekable(locate(&lhs, &mut state.buf1).ok_or(Error::NotFound { oid: lhs })?); | |
| 85 | + rhs_entries = peekable(locate(&rhs, &mut state.buf2).ok_or(Error::NotFound { oid: rhs })?); | |
| 92 | 86 | } |
| 93 | 87 | Some((Some(lhs), None)) => { |
| 94 | 88 | delegate.pop_front_tracked_path_and_set_current(); |
| 95 | − lhs_entries = peekable( | |
| 96 | − locate(&lhs.tree_id, &mut state.buf1).ok_or(Error::NotFound { oid: lhs.tree_id })?, | |
| 97 | − ); | |
| 89 | + lhs_entries = peekable(locate(&lhs, &mut state.buf1).ok_or(Error::NotFound { oid: lhs })?); | |
| 98 | 90 | } |
| 99 | 91 | Some((None, None)) => unreachable!("BUG: it makes no sense to fill the stack with empties"), |
| 100 | 92 | None => return Ok(()), |
| @@ -140,14 +132,8 @@ fn delete_entry_schedule_recursion<R: tree::Visit>( · 39 unmodified lines | ||
| 140 | 132 | } |
| 141 | 133 | if entry.mode.is_tree() { |
| 142 | 134 | delegate.pop_path_component(); |
| 143 | − let path_id = delegate.push_back_tracked_path_component(entry.filename); | |
| 144 | − queue.push_back(( | |
| 145 | − Some(TreeInfo { | |
| 146 | − tree_id: entry.oid.to_owned(), | |
| 147 | − parent_path_id: Some(path_id), | |
| 148 | − }), | |
| 149 | − None, | |
| 150 | − )); | |
| 135 | + delegate.push_back_tracked_path_component(entry.filename); | |
| 136 | + queue.push_back((Some(entry.oid.to_owned()), None)); | |
| 151 | 137 | } |
| 152 | 138 | Ok(()) |
| 153 | 139 | } |
| @@ -169,14 +155,8 @@ fn add_entry_schedule_recursion<R: tree::Visit>( · 15 unmodified lines | ||
| 169 | 155 | } |
| 170 | 156 | if entry.mode.is_tree() { |
| 171 | 157 | delegate.pop_path_component(); |
| 172 | − let path_id = delegate.push_back_tracked_path_component(entry.filename); | |
| 173 | − queue.push_back(( | |
| 174 | − None, | |
| 175 | − Some(TreeInfo { | |
| 176 | − tree_id: entry.oid.to_owned(), | |
| 177 | − parent_path_id: Some(path_id), | |
| 178 | − }), | |
| 179 | − )) | |
| 158 | + delegate.push_back_tracked_path_component(entry.filename); | |
| 159 | + queue.push_back((None, Some(entry.oid.to_owned()))) | |
| 180 | 160 | } |
| 181 | 161 | Ok(()) |
| 182 | 162 | } |
| @@ -269,7 +249,7 @@ fn handle_lhs_and_rhs_with_equal_filenames<R: tree::Visit>( · 86 unmodified lines | ||
| 269 | 249 | use git_object::tree::EntryMode::*; |
| 270 | 250 | match (lhs.mode, rhs.mode) { |
| 271 | 251 | (Tree, Tree) => { |
| 272 | − let path_id = delegate.push_back_tracked_path_component(lhs.filename); | |
| 252 | + delegate.push_back_tracked_path_component(lhs.filename); | |
| 273 | 253 | if lhs.oid != rhs.oid |
| 274 | 254 | && delegate |
| 275 | 255 | .visit(Change::Modification { |
| @@ -282,19 +262,10 @@ fn handle_lhs_and_rhs_with_equal_filenames<R: tree::Visit>( · 6 unmodified lines | ||
| 282 | 262 | { |
| 283 | 263 | return Err(Error::Cancelled); |
| 284 | 264 | } |
| 285 | − queue.push_back(( | |
| 286 | − Some(TreeInfo { | |
| 287 | − tree_id: lhs.oid.to_owned(), | |
| 288 | − parent_path_id: Some(path_id), | |
| 289 | − }), | |
| 290 | − Some(TreeInfo { | |
| 291 | − tree_id: rhs.oid.to_owned(), | |
| 292 | − parent_path_id: None, | |
| 293 | − }), | |
| 294 | − )); | |
| 265 | + queue.push_back((Some(lhs.oid.to_owned()), Some(rhs.oid.to_owned()))); | |
| 295 | 266 | } |
| 296 | 267 | (lhs_mode, Tree) if lhs_mode.is_no_tree() => { |
| 297 | − let path_id = delegate.push_back_tracked_path_component(lhs.filename); | |
| 268 | + delegate.push_back_tracked_path_component(lhs.filename); | |
| 298 | 269 | if delegate |
| 299 | 270 | .visit(Change::Deletion { |
| 300 | 271 | entry_mode: lhs.mode, |
| @@ -313,16 +284,10 @@ fn handle_lhs_and_rhs_with_equal_filenames<R: tree::Visit>( · 12 unmodified lines | ||
| 313 | 284 | { |
| 314 | 285 | return Err(Error::Cancelled); |
| 315 | 286 | }; |
| 316 | − queue.push_back(( | |
| 317 | − None, | |
| 318 | − Some(TreeInfo { | |
| 319 | − tree_id: rhs.oid.to_owned(), | |
| 320 | − parent_path_id: Some(path_id), | |
| 321 | − }), | |
| 322 | − )); | |
| 287 | + queue.push_back((None, Some(rhs.oid.to_owned()))); | |
| 323 | 288 | } |
| 324 | 289 | (Tree, rhs_mode) if rhs_mode.is_no_tree() => { |
| 325 | − let path_id = delegate.push_back_tracked_path_component(lhs.filename); | |
| 290 | + delegate.push_back_tracked_path_component(lhs.filename); | |
| 326 | 291 | if delegate |
| 327 | 292 | .visit(Change::Deletion { |
| 328 | 293 | entry_mode: lhs.mode, |
| @@ -341,13 +306,7 @@ fn handle_lhs_and_rhs_with_equal_filenames<R: tree::Visit>( · 12 unmodified lines | ||
| 341 | 306 | { |
| 342 | 307 | return Err(Error::Cancelled); |
| 343 | 308 | }; |
| 344 | − queue.push_back(( | |
| 345 | − Some(TreeInfo { | |
| 346 | − tree_id: lhs.oid.to_owned(), | |
| 347 | − parent_path_id: Some(path_id), | |
| 348 | − }), | |
| 349 | − None, | |
| 350 | − )); | |
| 309 | + queue.push_back((Some(lhs.oid.to_owned()), None)); | |
| 351 | 310 | } |
| 352 | 311 | (lhs_non_tree, rhs_non_tree) => { |
| 353 | 312 | delegate.push_path_component(lhs.filename); |
| @@ -10,13 +10,7 @@ pub struct State { · 9 unmodified lines | ||
| 10 | 10 | trees: VecDeque<TreeInfoPair>, |
| 11 | 11 | } |
| 12 | 12 | |
| 13 | −type TreeInfoPair = (Option<TreeInfo>, Option<TreeInfo>); | |
| 14 | − | |
| 15 | −#[derive(Clone)] | |
| 16 | −pub(crate) struct TreeInfo { | |
| 17 | − pub tree_id: ObjectId, | |
| 18 | − pub parent_path_id: Option<()>, | |
| 19 | −} | |
| 13 | +type TreeInfoPair = (Option<ObjectId>, Option<ObjectId>); | |
| 20 | 14 | |
| 21 | 15 | impl State { |
| 22 | 16 | fn clear(&mut self) { |