Skip to content

Commit fcb2205

Browse files
ttaylorrgitster
authored andcommitted
midx: implement support for writing incremental MIDX chains
Now that the rest of the MIDX subsystem and relevant callers have been updated to learn about how to read and process incremental MIDX chains, let's finally update the implementation in `write_midx_internal()` to be able to write incremental MIDX chains. This new feature is available behind the `--incremental` option for the `multi-pack-index` builtin, like so: $ git multi-pack-index write --incremental The implementation for doing so is relatively straightforward, and boils down to a handful of different kinds of changes implemented in this patch: - The `compute_sorted_entries()` function is taught to reject objects which appear in any existing MIDX layer. - Functions like `write_midx_revindex()` are adjusted to write pack_order values which are offset by the number of objects in the base MIDX layer. - The end of `write_midx_internal()` is adjusted to move non-incremental MIDX files when necessary (i.e. when creating an incremental chain with an existing non-incremental MIDX in the repository). There are a handful of other changes that are introduced, like new functions to clear incremental MIDX files that are unrelated to the current chain (using the same "keep_hash" mechanism as in the non-incremental case). The tests explicitly exercising the new incremental MIDX feature are relatively limited for two reasons: 1. Most of the "interesting" behavior is already thoroughly covered in t5319-multi-pack-index.sh, which handles the core logic of reading objects through a MIDX. The new tests in t5334-incremental-multi-pack-index.sh are mostly focused on creating and destroying incremental MIDXs, as well as stitching their results together across layers. 2. A new GIT_TEST environment variable is added called "GIT_TEST_MULTI_PACK_INDEX_WRITE_INCREMENTAL", which modifies the entire test suite to write incremental MIDXs after repacking when combined with the "GIT_TEST_MULTI_PACK_INDEX" variable. This exercises the long tail of other interesting behavior that is defined implicitly throughout the rest of the CI suite. It is likewise added to the linux-TEST-vars job. Signed-off-by: Taylor Blau <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 147c3f6 commit fcb2205

18 files changed

+459
-103
lines changed

Documentation/git-multi-pack-index.txt

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,12 @@ The file given at `<path>` is expected to be readable, and can contain
6464
duplicates. (If a given OID is given more than once, it is marked as
6565
preferred if at least one instance of it begins with the special `+`
6666
marker).
67+
68+
--incremental::
69+
Write an incremental MIDX file containing only objects
70+
and packs not present in an existing MIDX layer.
71+
Migrates non-incremental MIDXs to incremental ones when
72+
necessary. Incompatible with `--bitmap`.
6773
--
6874

6975
verify::
@@ -74,6 +80,8 @@ expire::
7480
have no objects referenced by the MIDX (with the exception of
7581
`.keep` packs and cruft packs). Rewrite the MIDX file afterward
7682
to remove all references to these pack-files.
83+
+
84+
NOTE: this mode is incompatible with incremental MIDX files.
7785

7886
repack::
7987
Create a new pack-file containing objects in small pack-files
@@ -95,7 +103,8 @@ repack::
95103
+
96104
If `repack.packKeptObjects` is `false`, then any pack-files with an
97105
associated `.keep` file will not be selected for the batch to repack.
98-
106+
+
107+
NOTE: this mode is incompatible with incremental MIDX files.
99108

100109
EXAMPLES
101110
--------

builtin/multi-pack-index.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,8 @@ static int cmd_multi_pack_index_write(int argc, const char **argv,
129129
MIDX_WRITE_BITMAP | MIDX_WRITE_REV_INDEX),
130130
OPT_BIT(0, "progress", &opts.flags,
131131
N_("force progress reporting"), MIDX_PROGRESS),
132+
OPT_BIT(0, "incremental", &opts.flags,
133+
N_("write a new incremental MIDX"), MIDX_WRITE_INCREMENTAL),
132134
OPT_BOOL(0, "stdin-packs", &opts.stdin_packs,
133135
N_("write multi-pack index containing only given indexes")),
134136
OPT_FILENAME(0, "refs-snapshot", &opts.refs_snapshot,

builtin/repack.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1514,8 +1514,12 @@ int cmd_repack(int argc, const char **argv, const char *prefix)
15141514
if (run_update_server_info)
15151515
update_server_info(0);
15161516

1517-
if (git_env_bool(GIT_TEST_MULTI_PACK_INDEX, 0))
1518-
write_midx_file(get_object_directory(), NULL, NULL, 0);
1517+
if (git_env_bool(GIT_TEST_MULTI_PACK_INDEX, 0)) {
1518+
unsigned flags = 0;
1519+
if (git_env_bool(GIT_TEST_MULTI_PACK_INDEX_WRITE_INCREMENTAL, 0))
1520+
flags |= MIDX_WRITE_INCREMENTAL;
1521+
write_midx_file(get_object_directory(), NULL, NULL, flags);
1522+
}
15191523

15201524
cleanup:
15211525
string_list_clear(&names, 1);

ci/run-build-and-tests.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ linux-TEST-vars)
2525
export GIT_TEST_COMMIT_GRAPH=1
2626
export GIT_TEST_COMMIT_GRAPH_CHANGED_PATHS=1
2727
export GIT_TEST_MULTI_PACK_INDEX=1
28+
export GIT_TEST_MULTI_PACK_INDEX_WRITE_INCREMENTAL=1
2829
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=master
2930
export GIT_TEST_NO_WRITE_REV_INDEX=1
3031
export GIT_TEST_CHECKOUT_WORKERS=2

0 commit comments

Comments
 (0)