Similar to the earlier patch series on cleaning up packfile.c and removing usage of global variables [1], we change the midx.c and midx-write.c files to no longer use global variables. This is done by the following: - Usage of repository variable already available in existing structs. - Passing down repository variable from other subsystems. - Modifying all subcommands to obtain repository variable from the command in `builtins/` and passing down the variable from there. The biggest change is in the first commit, wherein we modify all subcommands to add the repository variable. Since the subcommand definition are not often changed, it shouldn't cause too many conflicts with in flight topics. Since the `packfile.c` cleanup is still in flight, this series is based on top of master: b31fb630c0 (Merge https://github.com/j6t/git-gui, 2024-11-11) with those patches merged in. [1]: https://lore.kernel.org/git/cover.1729504640.git.karthik.188@xxxxxxxxx/ Signed-off-by: Karthik Nayak <karthik.188@xxxxxxxxx> --- Karthik Nayak (8): builtin: pass repository to sub commands midx-write: add repository field to `write_midx_context` midx-write: pass down repository to `write_midx_file[_only]` midx: cleanup internal usage of `the_repository` and `the_hash_algo` midx: pass `repository` to `load_multi_pack_index` midx: pass down `hash_algo` to `get_midx_filename[_ext]` midx: pass down `hash_algo` to `get_split_midx_filename_ext` midx: inline the `MIDX_MIN_SIZE` definition builtin/bisect.c | 32 +++++++---- builtin/bundle.c | 16 ++++-- builtin/commit-graph.c | 10 ++-- builtin/config.c | 25 +++++--- builtin/gc.c | 21 ++++--- builtin/hook.c | 7 ++- builtin/multi-pack-index.c | 20 ++++--- builtin/notes.c | 36 +++++++----- builtin/reflog.c | 17 ++++-- builtin/refs.c | 10 ++-- builtin/remote.c | 34 +++++++---- builtin/repack.c | 2 +- builtin/sparse-checkout.c | 25 +++++--- builtin/stash.c | 39 ++++++++----- builtin/submodule--helper.c | 46 +++++++++------ builtin/worktree.c | 28 +++++---- midx-write.c | 129 +++++++++++++++++++++--------------------- midx.c | 88 ++++++++++++++-------------- midx.h | 24 ++++---- pack-bitmap.c | 6 +- pack-revindex.c | 2 +- parse-options.h | 4 +- t/helper/test-parse-options.c | 11 +++- t/helper/test-read-midx.c | 8 +-- 24 files changed, 380 insertions(+), 260 deletions(-) --- base-commit: b31fb630c0fc6869a33ed717163e8a1210460d94 change-id: 20241111-374-refactor-midx-c-and-midx-write-c-to-not-depend-on-global-state-a88498c2590f prerequisite-message-id: <cover.1731323350.git.karthik.188@xxxxxxxxx> prerequisite-patch-id: 0c0b2f7ab45aa1c6a14b43577b527e388fbdbc38 prerequisite-patch-id: e3c455e9206c11da6df31b4fed1bb5a50f4b05a2 prerequisite-patch-id: d85a7bba34e100fe2fdcd69f9710d3791e5ea1bf prerequisite-patch-id: d3ad99374f4cca79ab58862ba31f61970e18eec2 prerequisite-patch-id: bc4ede2ad40588cc2a65598e875da121251012f9 prerequisite-patch-id: 74b62a5d62b178284a60d376aa0425758f15f514 prerequisite-patch-id: 4a70e65446538fff399de3b019a5c187e6ee9895 prerequisite-patch-id: bf5a723ee69217d389fc735b19b1cd04fd7a389a prerequisite-patch-id: 9d796bcf18fea156bd225787dbb4b8b0e2a7d23b Best regards, -- Karthik Nayak <karthik.188@xxxxxxxxx>