History

all docs for git-commitgraph::file

Sebastian Thiel committed 5 years ago

Commit 8b262011 parent 23bba1c6 files · +54 −20Browse files

Showing the changes to git-commitgraph/src/file/access.rs (1 of 6 files). Show all

Unified · Split

git-commitgraph/src/file/access.rs+9−0
@@ -9,6 +9,7 @@ use std::{ · 8 unmodified lines
9 9
10/// Access10/// Access
11impl File {11impl File {
12 /// The amount of base graphs that this file depends on.
12 pub fn base_graph_count(&self) -> u8 {13 pub fn base_graph_count(&self) -> u8 {
13 self.base_graph_count14 self.base_graph_count
14 }15 }
@@ -24,6 +25,9 @@ impl File { · 9 unmodified lines
24 Commit::new(self, pos)25 Commit::new(self, pos)
25 }26 }
26 27
28 /// The kind of hash used in this File.
29 ///
30 /// Note that it is always conforming to the hash used in the owning repository.
27 pub fn hash_kind(&self) -> HashKind {31 pub fn hash_kind(&self) -> HashKind {
28 HashKind::Sha132 HashKind::Sha1
29 }33 }
@@ -46,6 +50,7 @@ impl File { · 16 unmodified lines
46 borrowed::Id::try_from(&self.data[start..start + SHA1_SIZE]).expect("20 bytes SHA1 to be alright")50 borrowed::Id::try_from(&self.data[start..start + SHA1_SIZE]).expect("20 bytes SHA1 to be alright")
47 }51 }
48 52
53 /// Return an iterator over all object hashes stored in the base graph.
49 pub fn iter_base_graph_ids(&self) -> impl Iterator<Item = borrowed::Id<'_>> {54 pub fn iter_base_graph_ids(&self) -> impl Iterator<Item = borrowed::Id<'_>> {
50 let start = self.base_graphs_list_offset.unwrap_or(0);55 let start = self.base_graphs_list_offset.unwrap_or(0);
51 let base_graphs_list = &self.data[start..start + (SHA1_SIZE * usize::from(self.base_graph_count))];56 let base_graphs_list = &self.data[start..start + (SHA1_SIZE * usize::from(self.base_graph_count))];
@@ -54,14 +59,17 @@ impl File { · 2 unmodified lines
54 .map(|bytes| borrowed::Id::try_from(bytes).expect("20 bytes SHA1 to be alright"))59 .map(|bytes| borrowed::Id::try_from(bytes).expect("20 bytes SHA1 to be alright"))
55 }60 }
56 61
62 /// return an iterator over all commits in this file.
57 pub fn iter_commits(&self) -> impl Iterator<Item = Commit<'_>> {63 pub fn iter_commits(&self) -> impl Iterator<Item = Commit<'_>> {
58 (0..self.num_commits()).map(move |i| self.commit_at(file::Position(i)))64 (0..self.num_commits()).map(move |i| self.commit_at(file::Position(i)))
59 }65 }
60 66
67 /// Return an iterator over all object hashes stored in this file.
61 pub fn iter_ids(&self) -> impl Iterator<Item = borrowed::Id<'_>> {68 pub fn iter_ids(&self) -> impl Iterator<Item = borrowed::Id<'_>> {
62 (0..self.num_commits()).map(move |i| self.id_at(file::Position(i)))69 (0..self.num_commits()).map(move |i| self.id_at(file::Position(i)))
63 }70 }
64 71
72 /// Translate the given object hash to its position within this file, if present.
65 // copied from git-odb/src/pack/index/access.rs73 // copied from git-odb/src/pack/index/access.rs
66 pub fn lookup(&self, id: borrowed::Id<'_>) -> Option<file::Position> {74 pub fn lookup(&self, id: borrowed::Id<'_>) -> Option<file::Position> {
67 let first_byte = usize::from(id.first_byte());75 let first_byte = usize::from(id.first_byte());
@@ -94,6 +102,7 @@ impl File { · 26 unmodified lines
94 self.fan[255]102 self.fan[255]
95 }103 }
96 104
105 /// Returns the path to this file.
97 pub fn path(&self) -> &Path {106 pub fn path(&self) -> &Path {
98 &self.path107 &self.path
99 }108 }

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