History

rename 'Locate' to 'Find' - shorter and just as good

Sebastian Thiel committed 5 years ago

Commit 60f72f51 parent 5c791af24 files · +84 −81Browse files

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

Unified · Split

git-diff/tests/visit/mod.rs+10−10
@@ -4,7 +4,7 @@ mod changes { · 3 unmodified lines
4 use git_diff::visit::{recorder, recorder::Change::*};4 use git_diff::visit::{recorder, recorder::Change::*};
5 use git_hash::{oid, ObjectId};5 use git_hash::{oid, ObjectId};
6 use git_object::{bstr::ByteSlice, immutable, tree::EntryMode};6 use git_object::{bstr::ByteSlice, immutable, tree::EntryMode};
7 use git_odb::{linked, pack, Locate};7 use git_odb::{linked, pack, Find};
8 8
9 fn db(args: impl IntoIterator<Item = &'static str>) -> crate::Result<linked::Db> {9 fn db(args: impl IntoIterator<Item = &'static str>) -> crate::Result<linked::Db> {
10 linked::Db::at(10 linked::Db::at(
@@ -21,7 +21,7 @@ mod changes { · 10 unmodified lines
21 buf: &'a mut Vec<u8>,21 buf: &'a mut Vec<u8>,
22 ) -> crate::Result<immutable::TreeIter<'a>> {22 ) -> crate::Result<immutable::TreeIter<'a>> {
23 let tree_id = db23 let tree_id = db
24 .locate(commit, buf, &mut pack::cache::Never)?24 .find(commit, buf, &mut pack::cache::Never)?
25 .ok_or_else(|| String::from(format!("start commit {:?} to be present", commit)))?25 .ok_or_else(|| String::from(format!("start commit {:?} to be present", commit)))?
26 .decode()?26 .decode()?
27 .into_commit()27 .into_commit()
@@ -29,7 +29,7 @@ mod changes { · 1 unmodified line
29 .tree();29 .tree();
30 30
31 Ok(db31 Ok(db
32 .locate(tree_id, buf, &mut pack::cache::Never)?32 .find(tree_id, buf, &mut pack::cache::Never)?
33 .expect("main tree present")33 .expect("main tree present")
34 .into_tree_iter()34 .into_tree_iter()
35 .expect("id to be a tree"))35 .expect("id to be a tree"))
@@ -51,7 +51,7 @@ mod changes { · 15 unmodified lines
51 rhs_tree,51 rhs_tree,
52 git_diff::visit::State::default(),52 git_diff::visit::State::default(),
53 |oid, buf| {53 |oid, buf| {
54 db.locate(oid, buf, &mut pack::cache::Never)54 db.find(oid, buf, &mut pack::cache::Never)
55 .ok()55 .ok()
56 .flatten()56 .flatten()
57 .and_then(|obj| obj.into_tree_iter())57 .and_then(|obj| obj.into_tree_iter())
@@ -65,7 +65,7 @@ mod changes { · 7 unmodified lines
65 let mut buf = Vec::new();65 let mut buf = Vec::new();
66 let (main_tree_id, parent_commit_id) = {66 let (main_tree_id, parent_commit_id) = {
67 let commit = db67 let commit = db
68 .locate(commit_id, &mut buf, &mut pack::cache::Never)?68 .find(commit_id, &mut buf, &mut pack::cache::Never)?
69 .ok_or_else(|| String::from(format!("start commit {:?} to be present", commit_id)))?69 .ok_or_else(|| String::from(format!("start commit {:?} to be present", commit_id)))?
70 .decode()?70 .decode()?
71 .into_commit()71 .into_commit()
@@ -77,18 +77,18 @@ mod changes { · 5 unmodified lines
77 })77 })
78 };78 };
79 let current_tree = db79 let current_tree = db
80 .locate(main_tree_id, &mut buf, &mut pack::cache::Never)?80 .find(main_tree_id, &mut buf, &mut pack::cache::Never)?
81 .expect("main tree present")81 .expect("main tree present")
82 .into_tree_iter()82 .into_tree_iter()
83 .expect("id to be a tree");83 .expect("id to be a tree");
84 let mut buf2 = Vec::new();84 let mut buf2 = Vec::new();
85 let previous_tree: Option<_> = {85 let previous_tree: Option<_> = {
86 parent_commit_id86 parent_commit_id
87 .and_then(|id| db.locate(id, &mut buf2, &mut pack::cache::Never).ok().flatten())87 .and_then(|id| db.find(id, &mut buf2, &mut pack::cache::Never).ok().flatten())
88 .and_then(|c| c.decode().ok())88 .and_then(|c| c.decode().ok())
89 .and_then(|c| c.into_commit())89 .and_then(|c| c.into_commit())
90 .map(|c| c.tree())90 .map(|c| c.tree())
91 .and_then(|tree| db.locate(tree, &mut buf2, &mut pack::cache::Never).ok().flatten())91 .and_then(|tree| db.find(tree, &mut buf2, &mut pack::cache::Never).ok().flatten())
92 .and_then(|tree| tree.into_tree_iter())92 .and_then(|tree| tree.into_tree_iter())
93 };93 };
94 94
@@ -97,7 +97,7 @@ mod changes { · 2 unmodified lines
97 current_tree,97 current_tree,
98 &mut git_diff::visit::State::default(),98 &mut git_diff::visit::State::default(),
99 |oid, buf| {99 |oid, buf| {
100 db.locate(oid, buf, &mut pack::cache::Never)100 db.find(oid, buf, &mut pack::cache::Never)
101 .ok()101 .ok()
102 .flatten()102 .flatten()
103 .and_then(|obj| obj.into_tree_iter())103 .and_then(|obj| obj.into_tree_iter())
@@ -131,7 +131,7 @@ mod changes { · 27 unmodified lines
131 131
132 let head = head_of(db);132 let head = head_of(db);
133 iter::Ancestors::new(Some(head), iter::ancestors::State::default(), |oid, buf| {133 iter::Ancestors::new(Some(head), iter::ancestors::State::default(), |oid, buf| {
134 db.locate(oid, buf, &mut pack::cache::Never)134 db.find(oid, buf, &mut pack::cache::Never)
135 .ok()135 .ok()
136 .flatten()136 .flatten()
137 .and_then(|o| o.into_commit_iter())137 .and_then(|o| o.into_commit_iter())