History

refactor!: move git_pack::data::Object to git_object::Data, massively alter git_odb::Find trait (#266)

This will break a lot, but has to happen to prepare these traits for the next generation of object databases.

Sebastian Thiel committed 4 years ago

Commit 2290d001 parent e25f4ea49 files · +377 −302Browse files

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

Unified · Split

git-diff/tests/visit/mod.rs+10−6
@@ -3,7 +3,7 @@ mod changes { · 2 unmodified lines
33 use git_diff::tree::{recorder, recorder::Change::*};
44 use git_hash::{oid, ObjectId};
55 use git_object::{bstr::ByteSlice, tree::EntryMode, TreeRefIter};
6− use git_odb::{linked, pack, Find};
6+ use git_odb::{linked, pack, pack::Find};
77
88 use crate::hex_to_id;
99
@@ -26,6 +26,7 @@ mod changes { · 16 unmodified lines
2626 let tree_id = db
2727 .try_find(commit, buf, &mut pack::cache::Never)?
2828 .ok_or_else(|| format!("start commit {:?} to be present", commit))?
29+ .0
2930 .decode()?
3031 .into_commit()
3132 .expect("id is actually a commit")
@@ -34,6 +35,7 @@ mod changes { · 2 unmodified lines
3435 Ok(db
3536 .try_find(tree_id, buf, &mut pack::cache::Never)?
3637 .expect("main tree present")
38+ .0
3739 .try_into_tree_iter()
3840 .expect("id to be a tree"))
3941 }
@@ -53,7 +55,7 @@ mod changes { · 13 unmodified lines
5355 db.try_find(oid, buf, &mut pack::cache::Never)
5456 .ok()
5557 .flatten()
56− .and_then(|obj| obj.try_into_tree_iter())
58+ .and_then(|obj| obj.0.try_into_tree_iter())
5759 },
5860 &mut recorder,
5961 )?;
@@ -66,6 +68,7 @@ mod changes { · 6 unmodified lines
6668 let commit = db
6769 .try_find(commit_id, &mut buf, &mut pack::cache::Never)?
6870 .ok_or_else(|| format!("start commit {:?} to be present", commit_id))?
71+ .0
6972 .decode()?
7073 .into_commit()
7174 .expect("id is actually a commit");
@@ -78,17 +81,18 @@ mod changes { · 6 unmodified lines
7881 let current_tree = db
7982 .try_find(main_tree_id, &mut buf, &mut pack::cache::Never)?
8083 .expect("main tree present")
84+ .0
8185 .try_into_tree_iter()
8286 .expect("id to be a tree");
8387 let mut buf2 = Vec::new();
8488 let previous_tree: Option<_> = {
8589 parent_commit_id
8690 .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())
8892 .and_then(|c| c.into_commit())
8993 .map(|c| c.tree())
9094 .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())
9296 };
9397
9498 let mut recorder = git_diff::tree::Recorder::default();
@@ -99,7 +103,7 @@ mod changes { · 4 unmodified lines
99103 db.try_find(oid, buf, &mut pack::cache::Never)
100104 .ok()
101105 .flatten()
102− .and_then(|obj| obj.try_into_tree_iter())
106+ .and_then(|(obj, _)| obj.try_into_tree_iter())
103107 },
104108 &mut recorder,
105109 )?;
@@ -133,7 +137,7 @@ mod changes { · 27 unmodified lines
133137 db.try_find(oid, buf, &mut pack::cache::Never)
134138 .ok()
135139 .flatten()
136− .and_then(|o| o.try_into_commit_iter())
140+ .and_then(|t| t.0.try_into_commit_iter())
137141 })
138142 .collect::<Vec<_>>()
139143 .into_iter()