History

Remove re-export of git_object::borrowed::Id (#63)

Sebastian Thiel committed 5 years ago

Commit a3f28161 parent fdbe70422 files · +64 −69Browse files

Showing the changes to git-commitgraph/src (4 of 22 files). Show all

Unified · Split

4 files
  1. git-commitgraph/src/file/access.rs +7 −7
  2. git-commitgraph/src/file/commit.rs +5 −5
  3. git-commitgraph/src/file/verify.rs +10 −6
  4. git-commitgraph/src/graph/access.rs +5 −6
git-commitgraph/src/file/access.rs+7−7
@@ -1,6 +1,6 @@
11 use crate::file::{self, commit::Commit, File, COMMIT_DATA_ENTRY_SIZE};
22 use git_hash::SIZE_OF_SHA1_DIGEST as SHA1_SIZE;
3−use git_object::{borrowed, HashKind};
3+use git_object::HashKind;
44 use std::{
55 convert::{TryFrom, TryInto},
66 fmt::{Debug, Formatter},
@@ -35,7 +35,7 @@ impl File { · 28 unmodified lines
3535 /// Returns 20 bytes sha1 at the given index in our list of (sorted) sha1 hashes.
3636 /// The position ranges from 0 to self.num_commits()
3737 // copied from git-odb/src/pack/index/access.rs
38− pub fn id_at(&self, pos: file::Position) -> borrowed::Id<'_> {
38+ pub fn id_at(&self, pos: file::Position) -> git_hash::borrowed::Id<'_> {
3939 assert!(
4040 pos.0 < self.num_commits(),
4141 "expected lexigraphical position less than {}, got {}",
@@ -47,16 +47,16 @@ impl File { · 5 unmodified lines
4747 .try_into()
4848 .expect("an architecture able to hold 32 bits of integer");
4949 let start = self.oid_lookup_offset + (pos * SHA1_SIZE);
50− borrowed::Id::try_from(&self.data[start..start + SHA1_SIZE]).expect("20 bytes SHA1 to be alright")
50+ git_hash::borrowed::Id::try_from(&self.data[start..start + SHA1_SIZE]).expect("20 bytes SHA1 to be alright")
5151 }
5252
5353 /// Return an iterator over all object hashes stored in the base graph.
54− pub fn iter_base_graph_ids(&self) -> impl Iterator<Item = borrowed::Id<'_>> {
54+ pub fn iter_base_graph_ids(&self) -> impl Iterator<Item = git_hash::borrowed::Id<'_>> {
5555 let start = self.base_graphs_list_offset.unwrap_or(0);
5656 let base_graphs_list = &self.data[start..start + (SHA1_SIZE * usize::from(self.base_graph_count))];
5757 base_graphs_list
5858 .chunks(SHA1_SIZE)
59− .map(|bytes| borrowed::Id::try_from(bytes).expect("20 bytes SHA1 to be alright"))
59+ .map(|bytes| git_hash::borrowed::Id::try_from(bytes).expect("20 bytes SHA1 to be alright"))
6060 }
6161
6262 /// return an iterator over all commits in this file.
@@ -65,13 +65,13 @@ impl File { · 2 unmodified lines
6565 }
6666
6767 /// Return an iterator over all object hashes stored in this file.
68− pub fn iter_ids(&self) -> impl Iterator<Item = borrowed::Id<'_>> {
68+ pub fn iter_ids(&self) -> impl Iterator<Item = git_hash::borrowed::Id<'_>> {
6969 (0..self.num_commits()).map(move |i| self.id_at(file::Position(i)))
7070 }
7171
7272 /// Translate the given object hash to its position within this file, if present.
7373 // copied from git-odb/src/pack/index/access.rs
74− pub fn lookup(&self, id: borrowed::Id<'_>) -> Option<file::Position> {
74+ pub fn lookup(&self, id: git_hash::borrowed::Id<'_>) -> Option<file::Position> {
7575 let first_byte = usize::from(id.first_byte());
7676 let mut upper_bound = self.fan[first_byte];
7777 let mut lower_bound = if first_byte != 0 { self.fan[first_byte - 1] } else { 0 };
git-commitgraph/src/file/commit.rs+5−5
@@ -5,7 +5,7 @@ use crate::{ · 4 unmodified lines
55 };
66 use byteorder::{BigEndian, ByteOrder};
77 use git_hash::SIZE_OF_SHA1_DIGEST as SHA1_SIZE;
8−use git_object::{borrowed, owned};
8+use git_object::owned;
99 use std::{
1010 convert::{TryFrom, TryInto},
1111 fmt::{Debug, Formatter},
@@ -40,7 +40,7 @@ pub struct Commit<'a> { · 28 unmodified lines
4040 generation: u32,
4141 parent1: ParentEdge,
4242 parent2: ParentEdge,
43− root_tree_id: borrowed::Id<'a>,
43+ root_tree_id: git_hash::borrowed::Id<'a>,
4444 }
4545
4646 impl<'a> Commit<'a> {
@@ -49,7 +49,7 @@ impl<'a> Commit<'a> { · 2 unmodified lines
4949 Commit {
5050 file,
5151 pos,
52− root_tree_id: borrowed::Id::try_from(&bytes[..SHA1_SIZE]).expect("20 bytes SHA1 to be alright"),
52+ root_tree_id: git_hash::borrowed::Id::try_from(&bytes[..SHA1_SIZE]).expect("20 bytes SHA1 to be alright"),
5353 parent1: ParentEdge::from_raw(BigEndian::read_u32(&bytes[SHA1_SIZE..SHA1_SIZE + 4])),
5454 parent2: ParentEdge::from_raw(BigEndian::read_u32(&bytes[SHA1_SIZE + 4..SHA1_SIZE + 8])),
5555 generation: BigEndian::read_u32(&bytes[SHA1_SIZE + 8..SHA1_SIZE + 12]) >> 2,
@@ -84,7 +84,7 @@ impl<'a> Commit<'a> { · 28 unmodified lines
8484 }
8585
8686 /// Returns the hash of this commit.
87− pub fn id(&self) -> borrowed::Id<'a> {
87+ pub fn id(&self) -> git_hash::borrowed::Id<'a> {
8888 self.file.id_at(self.pos)
8989 }
9090
@@ -99,7 +99,7 @@ impl<'a> Commit<'a> { · 8 unmodified lines
9999 }
100100
101101 /// Return the hash of the tree this commit points to.
102− pub fn root_tree_id(&self) -> borrowed::Id<'a> {
102+ pub fn root_tree_id(&self) -> git_hash::borrowed::Id<'a> {
103103 self.root_tree_id
104104 }
105105 }
git-commitgraph/src/file/verify.rs+10−6
@@ -5,7 +5,7 @@ use crate::{ · 4 unmodified lines
55 };
66 use bstr::ByteSlice;
77 use git_hash::SIZE_OF_SHA1_DIGEST as SHA1_SIZE;
8−use git_object::{borrowed, owned};
8+use git_object::owned;
99 use std::{
1010 cmp::{max, min},
1111 collections::HashMap,
@@ -58,8 +58,9 @@ pub struct Outcome { · 46 unmodified lines
5858 /// Verification
5959 impl File {
6060 /// Returns the trailing checksum over the entire content of this file.
61− pub fn checksum(&self) -> borrowed::Id<'_> {
62− borrowed::Id::try_from(&self.data[self.data.len() - SHA1_SIZE..]).expect("file to be large enough for a hash")
61+ pub fn checksum(&self) -> git_hash::borrowed::Id<'_> {
62+ git_hash::borrowed::Id::try_from(&self.data[self.data.len() - SHA1_SIZE..])
63+ .expect("file to be large enough for a hash")
6364 }
6465
6566 /// Traverse all [commits][file::Commit] stored in this file and call `processor(commit) -> Result<(), Error>` on it.
@@ -74,7 +75,7 @@ impl File { · 8 unmodified lines
7475 .map_err(|(actual, expected)| Error::Mismatch { actual, expected })?;
7576 verify_split_chain_filename_hash(&self.path, self.checksum()).map_err(Error::Filename)?;
7677
77− let null_id = borrowed::Id::null_sha1();
78+ let null_id = git_hash::borrowed::Id::null_sha1();
7879
7980 let mut stats = Outcome {
8081 max_generation: 0,
@@ -85,7 +86,7 @@ impl File { · 4 unmodified lines
8586 };
8687
8788 // TODO: Verify self.fan values as we go.
88− let mut prev_id: borrowed::Id<'a> = null_id;
89+ let mut prev_id: git_hash::borrowed::Id<'a> = null_id;
8990 for commit in self.iter_commits() {
9091 if commit.id() <= prev_id {
9192 if commit.id() == null_id {
@@ -157,7 +158,10 @@ impl File { · 65 unmodified lines
157158
158159 /// If the given path's filename matches "graph-{hash}.graph", check that `hash` matches the
159160 /// expected hash.
160−fn verify_split_chain_filename_hash(path: impl AsRef<Path>, expected: borrowed::Id<'_>) -> Result<(), String> {
161+fn verify_split_chain_filename_hash(
162+ path: impl AsRef<Path>,
163+ expected: git_hash::borrowed::Id<'_>,
164+) -> Result<(), String> {
161165 let path = path.as_ref();
162166 path.file_name()
163167 .and_then(|filename| filename.to_str())
git-commitgraph/src/graph/access.rs+5−6
@@ -2,7 +2,6 @@ use crate::{ · 1 unmodified line
22 file::{self, Commit, File},
33 graph::{self, Graph},
44 };
5−use git_object::borrowed;
65
76 /// Access
87 impl Graph {
@@ -16,7 +15,7 @@ impl Graph { · 7 unmodified lines
1615 }
1716
1817 /// Returns the commit matching the given `id`.
19− pub fn commit_by_id(&self, id: borrowed::Id<'_>) -> Option<Commit<'_>> {
18+ pub fn commit_by_id(&self, id: git_hash::borrowed::Id<'_>) -> Option<Commit<'_>> {
2019 let r = self.lookup_by_id(id)?;
2120 Some(r.file.commit_at(r.file_pos))
2221 }
@@ -25,7 +24,7 @@ impl Graph { · 2 unmodified lines
2524 ///
2625 /// # Panics
2726 /// If `pos` is greater or equal to [`num_commits()`][Graph::num_commits()].
28− pub fn id_at(&self, pos: graph::Position) -> borrowed::Id<'_> {
27+ pub fn id_at(&self, pos: graph::Position) -> git_hash::borrowed::Id<'_> {
2928 let r = self.lookup_by_pos(pos);
3029 r.file.id_at(r.pos)
3130 }
@@ -36,12 +35,12 @@ impl Graph { · 4 unmodified lines
3635 }
3736
3837 /// Iterate over commit IDs in unsorted order.
39− pub fn iter_ids(&self) -> impl Iterator<Item = borrowed::Id<'_>> {
38+ pub fn iter_ids(&self) -> impl Iterator<Item = git_hash::borrowed::Id<'_>> {
4039 self.files.iter().flat_map(|file| file.iter_ids())
4140 }
4241
4342 /// Translate the given `id` to its position in the file.
44− pub fn lookup(&self, id: borrowed::Id<'_>) -> Option<graph::Position> {
43+ pub fn lookup(&self, id: git_hash::borrowed::Id<'_>) -> Option<graph::Position> {
4544 Some(self.lookup_by_id(id)?.graph_pos)
4645 }
4746
@@ -53,7 +52,7 @@ impl Graph { · 5 unmodified lines
5352
5453 /// Access fundamentals
5554 impl Graph {
56− pub(crate) fn lookup_by_id(&self, id: borrowed::Id<'_>) -> Option<LookupByIdResult<'_>> {
55+ pub(crate) fn lookup_by_id(&self, id: git_hash::borrowed::Id<'_>) -> Option<LookupByIdResult<'_>> {
5756 let mut current_file_start = 0;
5857 for file in &self.files {
5958 if let Some(lex_pos) = file.lookup(id) {

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t