forked from git-for-windows/git
-
Notifications
You must be signed in to change notification settings - Fork 106
Commit 4cf05f6
Merge pull request #107 use more structured data for midx expire
This replaces #106. That PR was complicated and difficult to understand because we didn't use structured data, but instead relied on our simple arrays and overloaded that data.
This is a bigger change, but results in code that is (hopefully) easier to understand. The new flow for writing a multi-pack-index is as follows:
1. Construct a list of `midx_info` structs that contain the details of the packs. This list starts with the packs in the existing midx, followed by the new packs to add. Keep track of the `orig_pack_int_id` for these packs.
2. Construct the list of object entries. The `pack_int_id` we use here corresponds to the `orig_pack_int_id` for the pack we are using.
3. Sort the packs by name.
4. If we have packs to drop, identify where they are in the list of packs. We can use the sorted nature of the list to know we will find them in the correct order.
5. Determine the `new_pack_int_id` for each `struct midx_info` by tracking how many are dropped by that point in the list.
6. Construct a new permutation array that maps from `orig_pack_int_id` to `new_pack_int_id`. If the pack is expired, then the value used here is invalid and will error if any object tries to use that value.
7. Count the length of the pack names we will write, and modify the length to be properly aligned if necessary.
8. Write the midx as usual, tracking that we have `packs.nr - drop_count` packs to write.
9. When writing the object offsets, use `packs.perm` to translate from the `orig_pack_int_id` to `new_pack_int_id`.
While this PR is just one giant commit, I will peel parts across multiple commits for upstream. These will be interleaved with the commits already in `microsoft/git:master`.File tree
Expand file treeCollapse file tree
2 files changed
+154
-124
lines changedOpen diff view settings
Filter options
- t
Expand file treeCollapse file tree
2 files changed
+154
-124
lines changedOpen diff view settings
0 commit comments