History

Promote file-format constants to `git_commitgraph::file` module.

This will let future code that writes commit graphs use those constants.

Conor Davis committed 5 years ago

Commit 0afd3541 parent b559dd03 files · +30 −28Browse files

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

Unified · Split

3 files
  1. git-commitgraph/src/file/commit.rs +1 −8
  2. git-commitgraph/src/file/init.rs +5 −12
  3. git-commitgraph/src/file/mod.rs +24 −8
git-commitgraph/src/file/commit.rs+1−8
@@ -9,7 +9,7 @@ use byteorder::{BigEndian, ByteOrder}; · 8 unmodified lines
99 use git_hash::SIZE_OF_SHA1_DIGEST as SHA1_SIZE;
1010
1111 use crate::{
12− file::{self, File},
12+ file::{self, File, EXTENDED_EDGES_MASK, LAST_EXTENDED_EDGE_MASK, NO_PARENT},
1313 graph,
1414 };
1515
@@ -27,11 +27,6 @@ pub enum Error { · 11 unmodified lines
2727 SecondParentWithoutFirstParent(git_hash::ObjectId),
2828 }
2929
30−// Note that git's commit-graph-format.txt as of v2.28.0 gives an incorrect value 0x0700_0000 for
31−// NO_PARENT. Fixed in https://github.com/git/git/commit/4d515253afcef985e94400adbfed7044959f9121 .
32−const NO_PARENT: u32 = 0x7000_0000;
33−const EXTENDED_EDGES_MASK: u32 = 0x8000_0000;
34−
3530 /// A commit as stored in a [`File`].
3631 pub struct Commit<'a> {
3732 file: &'a File,
@@ -240,8 +235,6 @@ impl ParentEdge { · 202 unmodified lines
240235 }
241236 }
242237
243−const LAST_EXTENDED_EDGE_MASK: u32 = 0x8000_0000;
244−
245238 enum ExtraEdge {
246239 Internal(graph::Position),
247240 Last(graph::Position),
git-commitgraph/src/file/init.rs+5−12
@@ -9,9 +9,11 @@ use byteorder::{BigEndian, ByteOrder}; · 8 unmodified lines
99 use filebuffer::FileBuffer;
1010 use git_hash::SIZE_OF_SHA1_DIGEST as SHA1_SIZE;
1111
12−use crate::file::{File, COMMIT_DATA_ENTRY_SIZE, FAN_LEN, SIGNATURE};
13−
14−type ChunkId = [u8; 4];
12+use crate::file::{
13+ ChunkId, File, BASE_GRAPHS_LIST_CHUNK_ID, CHUNK_LOOKUP_SIZE, COMMIT_DATA_CHUNK_ID, COMMIT_DATA_ENTRY_SIZE,
14+ EXTENDED_EDGES_LIST_CHUNK_ID, FAN_LEN, HEADER_LEN, OID_FAN_CHUNK_ID, OID_LOOKUP_CHUNK_ID, OID_LOOKUP_ENTRY_SIZE,
15+ SENTINEL_CHUNK_ID, SIGNATURE,
16+};
1517
1618 /// The error used in [`File::at()`].
1719 #[derive(thiserror::Error, Debug)]
@@ -51,20 +53,11 @@ pub enum Error { · 33 unmodified lines
5153 UnsupportedVersion(u8),
5254 }
5355
54−const CHUNK_LOOKUP_SIZE: usize = 12;
55−const HEADER_LEN: usize = 8;
5656 const TRAILER_LEN: usize = SHA1_SIZE;
5757 const MIN_FILE_SIZE: usize = HEADER_LEN + ((MIN_CHUNKS + 1) * CHUNK_LOOKUP_SIZE) + TRAILER_LEN;
58−const OID_LOOKUP_ENTRY_SIZE: usize = SHA1_SIZE;
5958
6059 // Required chunks: OIDF, OIDL, CDAT
6160 const MIN_CHUNKS: usize = 3;
62−const BASE_GRAPHS_LIST_CHUNK_ID: ChunkId = *b"BASE";
63−const COMMIT_DATA_CHUNK_ID: ChunkId = *b"CDAT";
64−const EXTENDED_EDGES_LIST_CHUNK_ID: ChunkId = *b"EDGE";
65−const OID_FAN_CHUNK_ID: ChunkId = *b"OIDF";
66−const OID_LOOKUP_CHUNK_ID: ChunkId = *b"OIDL";
67−const SENTINEL_CHUNK_ID: ChunkId = [0u8; 4];
6861
6962 impl File {
7063 /// Try to parse the commit graph file at `path`.
git-commitgraph/src/file/mod.rs+24−8
@@ -1,12 +1,6 @@
11 //! Operations on a single commit-graph file.
22
3−mod access;
4−
5−pub mod commit;
6−pub use commit::Commit;
7−
8−mod init;
9−pub mod verify;
3+pub use self::{commit::Commit, init::Error};
104
115 use std::{
126 fmt::{Display, Formatter},
@@ -16,12 +10,34 @@ use std::{ · 3 unmodified lines
1610
1711 use filebuffer::FileBuffer;
1812 use git_hash::SIZE_OF_SHA1_DIGEST as SHA1_SIZE;
19−pub use init::Error;
2013
14+mod access;
15+pub mod commit;
16+mod init;
17+pub mod verify;
18+
19+const CHUNK_LOOKUP_SIZE: usize = 12;
2120 const COMMIT_DATA_ENTRY_SIZE: usize = SHA1_SIZE + 16;
2221 const FAN_LEN: usize = 256;
22+const HEADER_LEN: usize = 8;
23+const OID_LOOKUP_ENTRY_SIZE: usize = SHA1_SIZE;
24+
2325 const SIGNATURE: &[u8] = b"CGPH";
2426
27+type ChunkId = [u8; 4];
28+const BASE_GRAPHS_LIST_CHUNK_ID: ChunkId = *b"BASE";
29+const COMMIT_DATA_CHUNK_ID: ChunkId = *b"CDAT";
30+const EXTENDED_EDGES_LIST_CHUNK_ID: ChunkId = *b"EDGE";
31+const OID_FAN_CHUNK_ID: ChunkId = *b"OIDF";
32+const OID_LOOKUP_CHUNK_ID: ChunkId = *b"OIDL";
33+const SENTINEL_CHUNK_ID: ChunkId = [0u8; 4];
34+
35+// Note that git's commit-graph-format.txt as of v2.28.0 gives an incorrect value 0x0700_0000 for
36+// NO_PARENT. Fixed in https://github.com/git/git/commit/4d515253afcef985e94400adbfed7044959f9121 .
37+const NO_PARENT: u32 = 0x7000_0000;
38+const EXTENDED_EDGES_MASK: u32 = 0x8000_0000;
39+const LAST_EXTENDED_EDGE_MASK: u32 = 0x8000_0000;
40+
2541 /// A single commit-graph file.
2642 ///
2743 /// All operations on a `File` are local to that graph file. Since a commit graph can span multiple

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