This will break a lot, but has to happen to prepare these traits for the next generation of object databases.
Showing the changes to git-diff (1 of 49 files). Show all
Unified · Split
| @@ -3,7 +3,7 @@ mod changes { · 2 unmodified lines | |||
| 3 | use git_diff::tree::{recorder, recorder::Change::*}; | 3 | use git_diff::tree::{recorder, recorder::Change::*}; |
| 4 | use git_hash::{oid, ObjectId}; | 4 | use git_hash::{oid, ObjectId}; |
| 5 | use git_object::{bstr::ByteSlice, tree::EntryMode, TreeRefIter}; | 5 | use git_object::{bstr::ByteSlice, tree::EntryMode, TreeRefIter}; |
| 6 | use git_odb::{linked, pack, Find}; | 6 | use git_odb::{linked, pack, pack::Find}; |
| 7 | 7 | ||
| 8 | use crate::hex_to_id; | 8 | use crate::hex_to_id; |
| 9 | 9 | ||
| @@ -26,6 +26,7 @@ mod changes { · 16 unmodified lines | |||
| 26 | let tree_id = db | 26 | let tree_id = db |
| 27 | .try_find(commit, buf, &mut pack::cache::Never)? | 27 | .try_find(commit, buf, &mut pack::cache::Never)? |
| 28 | .ok_or_else(|| format!("start commit {:?} to be present", commit))? | 28 | .ok_or_else(|| format!("start commit {:?} to be present", commit))? |
| 29 | .0 | ||
| 29 | .decode()? | 30 | .decode()? |
| 30 | .into_commit() | 31 | .into_commit() |
| 31 | .expect("id is actually a commit") | 32 | .expect("id is actually a commit") |
| @@ -34,6 +35,7 @@ mod changes { · 2 unmodified lines | |||
| 34 | Ok(db | 35 | Ok(db |
| 35 | .try_find(tree_id, buf, &mut pack::cache::Never)? | 36 | .try_find(tree_id, buf, &mut pack::cache::Never)? |
| 36 | .expect("main tree present") | 37 | .expect("main tree present") |
| 38 | .0 | ||
| 37 | .try_into_tree_iter() | 39 | .try_into_tree_iter() |
| 38 | .expect("id to be a tree")) | 40 | .expect("id to be a tree")) |
| 39 | } | 41 | } |
| @@ -53,7 +55,7 @@ mod changes { · 13 unmodified lines | |||
| 53 | db.try_find(oid, buf, &mut pack::cache::Never) | 55 | db.try_find(oid, buf, &mut pack::cache::Never) |
| 54 | .ok() | 56 | .ok() |
| 55 | .flatten() | 57 | .flatten() |
| 56 | .and_then(|obj| obj.try_into_tree_iter()) | 58 | .and_then(|obj| obj.0.try_into_tree_iter()) |
| 57 | }, | 59 | }, |
| 58 | &mut recorder, | 60 | &mut recorder, |
| 59 | )?; | 61 | )?; |
| @@ -66,6 +68,7 @@ mod changes { · 6 unmodified lines | |||
| 66 | let commit = db | 68 | let commit = db |
| 67 | .try_find(commit_id, &mut buf, &mut pack::cache::Never)? | 69 | .try_find(commit_id, &mut buf, &mut pack::cache::Never)? |
| 68 | .ok_or_else(|| format!("start commit {:?} to be present", commit_id))? | 70 | .ok_or_else(|| format!("start commit {:?} to be present", commit_id))? |
| 71 | .0 | ||
| 69 | .decode()? | 72 | .decode()? |
| 70 | .into_commit() | 73 | .into_commit() |
| 71 | .expect("id is actually a commit"); | 74 | .expect("id is actually a commit"); |
| @@ -78,17 +81,18 @@ mod changes { · 6 unmodified lines | |||
| 78 | let current_tree = db | 81 | let current_tree = db |
| 79 | .try_find(main_tree_id, &mut buf, &mut pack::cache::Never)? | 82 | .try_find(main_tree_id, &mut buf, &mut pack::cache::Never)? |
| 80 | .expect("main tree present") | 83 | .expect("main tree present") |
| 84 | .0 | ||
| 81 | .try_into_tree_iter() | 85 | .try_into_tree_iter() |
| 82 | .expect("id to be a tree"); | 86 | .expect("id to be a tree"); |
| 83 | let mut buf2 = Vec::new(); | 87 | let mut buf2 = Vec::new(); |
| 84 | let previous_tree: Option<_> = { | 88 | let previous_tree: Option<_> = { |
| 85 | parent_commit_id | 89 | parent_commit_id |
| 86 | .and_then(|id| db.try_find(id, &mut buf2, &mut pack::cache::Never).ok().flatten()) | 90 | .and_then(|id| db.try_find(id, &mut buf2, &mut pack::cache::Never).ok().flatten()) |
| 87 | .and_then(|c| c.decode().ok()) | 91 | .and_then(|(c, _l)| c.decode().ok()) |
| 88 | .and_then(|c| c.into_commit()) | 92 | .and_then(|c| c.into_commit()) |
| 89 | .map(|c| c.tree()) | 93 | .map(|c| c.tree()) |
| 90 | .and_then(|tree| db.try_find(tree, &mut buf2, &mut pack::cache::Never).ok().flatten()) | 94 | .and_then(|tree| db.try_find(tree, &mut buf2, &mut pack::cache::Never).ok().flatten()) |
| 91 | .and_then(|tree| tree.try_into_tree_iter()) | 95 | .and_then(|(tree, _)| tree.try_into_tree_iter()) |
| 92 | }; | 96 | }; |
| 93 | 97 | ||
| 94 | let mut recorder = git_diff::tree::Recorder::default(); | 98 | let mut recorder = git_diff::tree::Recorder::default(); |
| @@ -99,7 +103,7 @@ mod changes { · 4 unmodified lines | |||
| 99 | db.try_find(oid, buf, &mut pack::cache::Never) | 103 | db.try_find(oid, buf, &mut pack::cache::Never) |
| 100 | .ok() | 104 | .ok() |
| 101 | .flatten() | 105 | .flatten() |
| 102 | .and_then(|obj| obj.try_into_tree_iter()) | 106 | .and_then(|(obj, _)| obj.try_into_tree_iter()) |
| 103 | }, | 107 | }, |
| 104 | &mut recorder, | 108 | &mut recorder, |
| 105 | )?; | 109 | )?; |
| @@ -133,7 +137,7 @@ mod changes { · 27 unmodified lines | |||
| 133 | db.try_find(oid, buf, &mut pack::cache::Never) | 137 | db.try_find(oid, buf, &mut pack::cache::Never) |
| 134 | .ok() | 138 | .ok() |
| 135 | .flatten() | 139 | .flatten() |
| 136 | .and_then(|o| o.try_into_commit_iter()) | 140 | .and_then(|t| t.0.try_into_commit_iter()) |
| 137 | }) | 141 | }) |
| 138 | .collect::<Vec<_>>() | 142 | .collect::<Vec<_>>() |
| 139 | .into_iter() | 143 | .into_iter() |