]> git.ipfire.org Git - thirdparty/git.git/commitdiff
Merge branch 'ds/chunked-file-api'
authorJunio C Hamano <gitster@pobox.com>
Mon, 1 Mar 2021 22:02:57 +0000 (14:02 -0800)
committerJunio C Hamano <gitster@pobox.com>
Mon, 1 Mar 2021 22:02:57 +0000 (14:02 -0800)
The common code to deal with "chunked file format" that is shared
by the multi-pack-index and commit-graph files have been factored
out, to help codepaths for both filetypes to become more robust.

* ds/chunked-file-api:
  commit-graph.c: display correct number of chunks when writing
  chunk-format: add technical docs
  chunk-format: restore duplicate chunk checks
  midx: use 64-bit multiplication for chunk sizes
  midx: use chunk-format read API
  commit-graph: use chunk-format read API
  chunk-format: create read chunk API
  midx: use chunk-format API in write_midx_internal()
  midx: drop chunk progress during write
  midx: return success/failure in chunk write methods
  midx: add num_large_offsets to write_midx_context
  midx: add pack_perm to write_midx_context
  midx: add entries to write_midx_context
  midx: use context in write_midx_pack_names()
  midx: rename pack_info to write_midx_context
  commit-graph: use chunk-format write API
  chunk-format: create chunk format write API
  commit-graph: anonymize data in chunk_write_fn

1  2 
Documentation/technical/pack-format.txt
Makefile
commit-graph.c
midx.c
t/t5318-commit-graph.sh
t/t5319-multi-pack-index.sh

diff --cc Makefile
Simple merge
diff --cc commit-graph.c
index c6768bb2ae7015a29a580777bebbf3fa032e94f2,b9efeddeab6c3d0ef1eb2110b2b4ed8addbd5b3d..ca025ce8eb561181fb450e607c50cf3d9dc448cb
@@@ -1879,19 -1758,18 +1826,18 @@@ static int write_commit_graph_file(stru
        } else {
                hold_lock_file_for_update_mode(&lk, ctx->graph_name,
                                               LOCK_DIE_ON_ERROR, 0444);
 -              fd = lk.tempfile->fd;
 -              f = hashfd(lk.tempfile->fd, lk.tempfile->filename.buf);
 +              fd = get_lock_file_fd(&lk);
 +              f = hashfd(fd, get_lock_file_path(&lk));
        }
  
-       chunks[0].id = GRAPH_CHUNKID_OIDFANOUT;
-       chunks[0].size = GRAPH_FANOUT_SIZE;
-       chunks[0].write_fn = write_graph_chunk_fanout;
-       chunks[1].id = GRAPH_CHUNKID_OIDLOOKUP;
-       chunks[1].size = hashsz * ctx->commits.nr;
-       chunks[1].write_fn = write_graph_chunk_oids;
-       chunks[2].id = GRAPH_CHUNKID_DATA;
-       chunks[2].size = (hashsz + 16) * ctx->commits.nr;
-       chunks[2].write_fn = write_graph_chunk_data;
+       cf = init_chunkfile(f);
+       add_chunk(cf, GRAPH_CHUNKID_OIDFANOUT, GRAPH_FANOUT_SIZE,
+                 write_graph_chunk_fanout);
+       add_chunk(cf, GRAPH_CHUNKID_OIDLOOKUP, hashsz * ctx->commits.nr,
+                 write_graph_chunk_oids);
+       add_chunk(cf, GRAPH_CHUNKID_DATA, (hashsz + 16) * ctx->commits.nr,
+                 write_graph_chunk_data);
  
        if (git_env_bool(GIT_TEST_COMMIT_GRAPH_NO_GDAT, 0))
                ctx->write_generation_data = 0;
diff --cc midx.c
index 05c40a98e053905dc8b5e4587626e68acda6c62e,5c7f2ed23330fdd4e8fa3a5dfac7ff6890d8ffd3..971faa8cfc2f6e956933b26b29bbe76d4168be1f
--- 1/midx.c
--- 2/midx.c
+++ b/midx.c
@@@ -918,16 -894,13 +894,13 @@@ static int write_midx_internal(const ch
                                        (pack_name_concat_len % MIDX_CHUNK_ALIGNMENT);
  
        hold_lock_file_for_update(&lk, midx_name, LOCK_DIE_ON_ERROR);
 -      f = hashfd(lk.tempfile->fd, lk.tempfile->filename.buf);
 +      f = hashfd(get_lock_file_fd(&lk), get_lock_file_path(&lk));
        FREE_AND_NULL(midx_name);
  
-       if (packs.m)
-               close_midx(packs.m);
+       if (ctx.m)
+               close_midx(ctx.m);
  
-       cur_chunk = 0;
-       num_chunks = large_offsets_needed ? 5 : 4;
-       if (packs.nr - dropped_packs == 0) {
+       if (ctx.nr - dropped_packs == 0) {
                error(_("no pack files to index."));
                result = 1;
                goto cleanup;
Simple merge
Simple merge