History

[commitgraph] refactor

Sebastian Thiel committed 6 years ago

Commit c4b14c11 parent 6f90bee4 files · +18 −18Browse files

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

Unified · Split

git-commitgraph/src/file/commit.rs+5−5
@@ -45,7 +45,7 @@ const EXTENDED_EDGES_MASK: u32 = 0x8000_0000; · 44 unmodified lines
45 45
46pub struct Commit<'a> {46pub struct Commit<'a> {
47 file: &'a File,47 file: &'a File,
48 lex_pos: file::Position,48 pos: file::Position,
49 // We can parse the below fields lazily if needed.49 // We can parse the below fields lazily if needed.
50 commit_timestamp: u64,50 commit_timestamp: u64,
51 generation: u32,51 generation: u32,
@@ -59,7 +59,7 @@ impl<'a> Commit<'a> { · 7 unmodified lines
59 let bytes = file.commit_data_bytes(pos);59 let bytes = file.commit_data_bytes(pos);
60 Commit {60 Commit {
61 file,61 file,
62 lex_pos: pos,62 pos,
63 root_tree_id: borrowed::Id::try_from(&bytes[..SHA1_SIZE]).expect("20 bytes SHA1 to be alright"),63 root_tree_id: borrowed::Id::try_from(&bytes[..SHA1_SIZE]).expect("20 bytes SHA1 to be alright"),
64 parent1: ParentEdge::from_raw(BigEndian::read_u32(&bytes[SHA1_SIZE..SHA1_SIZE + 4])),64 parent1: ParentEdge::from_raw(BigEndian::read_u32(&bytes[SHA1_SIZE..SHA1_SIZE + 4])),
65 parent2: ParentEdge::from_raw(BigEndian::read_u32(&bytes[SHA1_SIZE + 4..SHA1_SIZE + 8])),65 parent2: ParentEdge::from_raw(BigEndian::read_u32(&bytes[SHA1_SIZE + 4..SHA1_SIZE + 8])),
@@ -94,7 +94,7 @@ impl<'a> Commit<'a> { · 28 unmodified lines
94 }94 }
95 95
96 pub fn id(&self) -> borrowed::Id<'_> {96 pub fn id(&self) -> borrowed::Id<'_> {
97 self.file.id_at(self.lex_pos)97 self.file.id_at(self.pos)
98 }98 }
99 99
100 pub fn parent1(&self) -> Result<Option<graph::Position>, Error> {100 pub fn parent1(&self) -> Result<Option<graph::Position>, Error> {
@@ -112,7 +112,7 @@ impl<'a> Debug for Commit<'a> { · 11 unmodified lines
112 f,112 f,
113 "Commit {{ id: {}, lex_pos: {}, generation: {}, root_tree_id: {}, parent1: {:?}, parent2: {:?} }}",113 "Commit {{ id: {}, lex_pos: {}, generation: {}, root_tree_id: {}, parent1: {:?}, parent2: {:?} }}",
114 self.id(),114 self.id(),
115 self.lex_pos,115 self.pos,
116 self.generation(),116 self.generation(),
117 self.root_tree_id(),117 self.root_tree_id(),
118 self.parent1,118 self.parent1,
@@ -125,7 +125,7 @@ impl<'a> Eq for Commit<'a> {} · 6 unmodified lines
125 125
126impl<'a> PartialEq for Commit<'a> {126impl<'a> PartialEq for Commit<'a> {
127 fn eq(&self, other: &Self) -> bool {127 fn eq(&self, other: &Self) -> bool {
128 self.file as *const File == other.file as *const File && self.lex_pos == other.lex_pos128 self.file as *const File == other.file as *const File && self.pos == other.pos
129 }129 }
130}130}
131 131