Skip to content

Commit

Permalink
[commitgraph] refactor file::init
Browse files Browse the repository at this point in the history
  • Loading branch information
Byron committed Oct 1, 2020
1 parent c4b14c1 commit 8b003a0
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
9 changes: 5 additions & 4 deletions git-commitgraph/src/file/init.rs
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ impl TryFrom<&Path> for File {
let mut base_graphs_list_offset: Option<usize> = None;
let mut commit_data_offset: Option<usize> = None;
let mut commit_data_count = 0u32;
let mut extended_edges_list_range: Option<Range<usize>> = None;
let mut extra_edges_list_range: Option<Range<usize>> = None;
let mut fan_offset: Option<usize> = None;
let mut oid_lookup_offset: Option<usize> = None;
let mut oid_lookup_count = 0u32;
Expand Down Expand Up @@ -208,11 +208,11 @@ impl TryFrom<&Path> for File {
commit_data_count = (chunk_size / COMMIT_DATA_ENTRY_SIZE) as u32;
}
EXTENDED_EDGES_LIST_CHUNK_ID => {
if extended_edges_list_range.is_some() {
if extra_edges_list_range.is_some() {
return Err(Error::DuplicateChunk(chunk_id));
}

extended_edges_list_range = Some(Range {
extra_edges_list_range = Some(Range {
start: chunk_offset,
end: next_chunk_offset,
})
Expand Down Expand Up @@ -245,6 +245,7 @@ impl TryFrom<&Path> for File {
}
oid_lookup_offset = Some(chunk_offset);
oid_lookup_count = (chunk_size / OID_LOOKUP_ENTRY_SIZE) as u32;
// TODO(ST): Figure out how to handle this. Don't know what to do with the commented code.
// git allows extra garbage in the extra edges list chunk?
// if oid_lookup_count > 0 {
// let last_edge = &data[next_chunk_offset - 4..next_chunk_offset];
Expand Down Expand Up @@ -296,7 +297,7 @@ impl TryFrom<&Path> for File {
base_graphs_list_offset,
commit_data_offset,
data,
extra_edges_list_range: extended_edges_list_range,
extra_edges_list_range,
fan,
oid_lookup_offset,
path: path.to_owned(),
Expand Down
2 changes: 2 additions & 0 deletions tasks.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
* **Questions**
* ~~How can `Commit` return Graph positions? It doesn't seem to learn about an offset.~~
* Parent IDs are indeed specified as graph positions, not file positions, as they may be in previous commit graph files.
* What to do with the ['extra-garbage'](/~https://github.com/Byron/gitoxide/blob/6f90beeb418480f9cd8bb7ae3b5db678b24103cb/git-commitgraph/src/file/init.rs#L248),
some code is commented out.
* **Future Work**
* A plumbing command to extract some value from the current implementation, maybe statistics, or verification
* Application of the command above in a stress test
Expand Down

0 comments on commit 8b003a0

Please sign in to comment.