Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Write V2 Index Files (with TREE and EOIE extensions) #473

Merged
merged 13 commits into from
Aug 12, 2022

Conversation

SidneyDouw
Copy link
Contributor

@SidneyDouw SidneyDouw commented Aug 3, 2022

Write V2 Index Files

Features

Version Support

  • V2

Extensions

  • tree cache
  • end of index entry

Out of Scope

  • V3
  • V4
  • resolve undo
  • split index / link
  • untracked cache
  • fs monitor
  • index entry offset table

@Byron
Copy link
Owner

Byron commented Aug 4, 2022

Session Notes

  • File::write_to() to write with trailing hash
  • outscope everything that you didn't start yet
  • refactor tests roundtrip
  • pass std::io::Write to write_to as first argument, see other write_to() methods for reference
  • write docs about Options::hash_kind - it's kind of intricate
  • could there be baseline tests against all existing fixtures somewhat like this?
  • definitely get rid of the index-table, you could try to wrap std::io::Write like so to track bytes written for example.
diff --git a/git-index/tests/index/file/write.rs b/git-index/tests/index/file/write.rs
index aa4342816..49d2129a1 100644
--- a/git-index/tests/index/file/write.rs
+++ b/git-index/tests/index/file/write.rs
@@ -1,5 +1,17 @@
 use git_index::write::Options;
 
+#[test]
+fn roundtrips() {
+    for version in [Version::V2] {
+        for fixture_path in ["all fixtures"] {
+            let mut buf = Vec::<u8>::new();
+            let actual = git_index::File::at(fixture_path)?;
+            actual.state.write_to(&mut buf, Options { version })?;
+            let foo = git_index::State::from_bytes(&buf)?;
+        }
+    }
+}
+
 #[test]
 fn v2_empty() {
     let path = crate::fixture_index_path("V2_empty");

@Byron
Copy link
Owner

Byron commented Aug 4, 2022

Session Notes

  • next step would be creating an index from a tree, as it's something needed on the critical path towards supporting clones.

@Byron
Copy link
Owner

Byron commented Aug 12, 2022

Thanks a lot!

I took a couple of notes in the tracking issue and plan to look at it a little more thoroughly to generalize the end-of-index extension a little more.

The main refactorings done here should help to…

  • …put extension write implementations to the extension itself
  • …add documentation to new bits and pieces as allow(missing_docs) was now removed. Doing that helped to recap what's actually present in this crate as I haven't touched it in a while.

What's currently in main should be a good basis for the read-tree work.

@Byron Byron merged commit 618736b into Byron:main Aug 12, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants