{"thread":{"id":"62650","subject":"[PATCH 00/14] Stop using `the_repository` in some trivial cases","startedAt":"2024-12-17T06:44:17Z","lastAt":"2025-01-07T21:15:38Z","messageCount":26,"participants":["Patrick Steinhardt","shejialuo","Karthik Nayak","Toon Claes","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":14},"messages":[{"id":"509189","messageId":"20241217-pks-use-the-repository-conversion-v1-0-0dba48bcc239@pks.im","threadId":"62650","inReplyTo":null,"subject":"[PATCH 00/14] Stop using `the_repository` in some trivial cases","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2024-12-17T06:43:47Z","receivedAt":"2024-12-17T06:44:17Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"Hi,\n\nthis small patch series performs some refactorings to stop using\n`the_repository` in several subsystems. There wasn't really any\ncriterium for which subsystems I picked, except that all of them have\nbeen trivial to convert.\n\nIn this patch series I'm merely bubbling up `the_repository` one more\nlayer even though some calling contexts already have a repository\navailable. For the sake of triviality I decided not to handle these\ncases though and instead let a future patch series worry about them.\n\nThis series is built on v2.48.0-rc0 with ps/build-sign-compare at\ne03d2a9ccb (t/helper: don't depend on implicit wraparound, 2024-12-06)\nmerged into it. There's a single merge conflict with 'seen' that can be\nsolved like this:\n\ndiff --cc pack-bitmap.c\nindex 48e3b99efb,7d8f910588..0000000000\n--- a/pack-bitmap.c\n+++ b/pack-bitmap.c\n@@@ -2572,16 -2761,8 +2761,10 @@@ void test_bitmap_walk(struct rev_info *\n        if (prepare_revision_walk(revs))\n                die(_(\"revision walk setup failed\"));\n\n-       tdata.bitmap_git = bitmap_git;\n-       tdata.base = bitmap_new();\n-       tdata.commits = ewah_to_bitmap(bitmap_git->commits);\n-       tdata.trees = ewah_to_bitmap(bitmap_git->trees);\n-       tdata.blobs = ewah_to_bitmap(bitmap_git->blobs);\n-       tdata.tags = ewah_to_bitmap(bitmap_git->tags);\n+       prepare_bitmap_test_data(&tdata, bitmap_git);\n -      tdata.prg = start_progress(\"Verifying bitmap entries\", result_popcnt);\n +      tdata.prg = start_progress(revs->repo,\n +                                 \"Verifying bitmap entries\",\n +                                 result_popcnt);\n-       tdata.seen = 0;\n\n        traverse_commit_list(revs, &test_show_commit, &test_show_object, &tdata);\n\nThanks!\n\nPatrick\n\n---\nPatrick Steinhardt (14):\n      progress: stop using `the_repository`\n      pager: stop using `the_repository`\n      trace: stop using `the_repository`\n      serve: stop using `the_repository`\n      send-pack: stop using `the_repository`\n      server-info: stop using `the_repository`\n      diagnose: stop using `the_repository`\n      mailinfo: stop using `the_repository`\n      credential: stop using `the_repository`\n      resolve-undo: stop using `the_repository`\n      tmp-objdir: stop using `the_repository`\n      add-interactive: stop using `the_repository`\n      graph: stop using `the_repository`\n      match-trees: stop using `the_repository`\n\n add-interactive.c            | 19 ++++++-----\n add-patch.c                  |  2 +-\n builtin/am.c                 |  6 ++--\n builtin/blame.c              |  6 ++--\n builtin/bugreport.c          |  2 +-\n builtin/commit-graph.c       |  1 +\n builtin/credential.c         |  6 ++--\n builtin/diagnose.c           |  4 ++-\n builtin/fsck.c               | 12 ++++---\n builtin/grep.c               |  4 +--\n builtin/help.c               |  4 +--\n builtin/index-pack.c         |  7 ++--\n builtin/log.c                |  7 ++--\n builtin/mailinfo.c           |  2 +-\n builtin/pack-objects.c       | 21 ++++++++----\n builtin/prune.c              |  3 +-\n builtin/receive-pack.c       |  4 +--\n builtin/remote.c             |  3 +-\n builtin/repack.c             |  2 +-\n builtin/rev-list.c           |  3 +-\n builtin/send-pack.c          |  2 +-\n builtin/unpack-objects.c     |  3 +-\n builtin/update-server-info.c |  2 +-\n builtin/upload-pack.c        |  6 ++--\n builtin/var.c                |  2 +-\n bulk-checkin.c               |  2 +-\n commit-graph.c               | 20 ++++++++++--\n credential.c                 | 34 +++++++++----------\n credential.h                 | 11 ++++---\n delta-islands.c              |  3 +-\n diagnose.c                   | 15 +++++----\n diagnose.h                   |  5 ++-\n diff.c                       |  4 +--\n diffcore-rename.c            |  1 +\n entry.c                      |  4 ++-\n git.c                        | 10 +++---\n graph.c                      |  3 +-\n http.c                       | 24 +++++++-------\n imap-send.c                  | 10 +++---\n log-tree.c                   |  2 +-\n mailinfo.c                   |  5 ++-\n mailinfo.h                   |  4 ++-\n match-trees.c                | 50 +++++++++++++++-------------\n midx-write.c                 | 11 +++++--\n midx.c                       | 13 +++++---\n pack-bitmap-write.c          |  6 ++--\n pack-bitmap.c                |  4 ++-\n pager.c                      | 14 ++++----\n pager.h                      |  7 ++--\n preload-index.c              |  4 ++-\n progress.c                   | 34 +++++++++++--------\n progress.h                   | 13 +++++---\n prune-packed.c               |  3 +-\n pseudo-merge.c               |  3 +-\n read-cache.c                 |  7 ++--\n remote-curl.c                |  4 +--\n resolve-undo.c               | 14 ++++----\n resolve-undo.h               |  6 ++--\n send-pack.c                  | 77 +++++++++++++++++++++++---------------------\n send-pack.h                  |  3 +-\n serve.c                      | 36 ++++++++++-----------\n serve.h                      |  6 ++--\n server-info.c                | 40 ++++++++++++-----------\n server-info.h                |  4 ++-\n t/helper/test-progress.c     |  6 +++-\n t/helper/test-serve-v2.c     |  7 ++--\n tmp-objdir.c                 | 15 +++++----\n tmp-objdir.h                 |  5 +--\n trace.c                      |  9 +++---\n trace.h                      |  4 ++-\n transport.c                  |  2 +-\n unpack-trees.c               |  4 ++-\n walker.c                     |  3 +-\n 73 files changed, 406 insertions(+), 298 deletions(-)\n\n\n---\nbase-commit: 063bcebf0c917140ca0e705cbe0fdea127e90086\nchange-id: 20241128-pks-use-the-repository-conversion-c346af3388ee\nprerequisite-message-id: <20241206-pks-meson-v11-0-525ed4792b88@pks.im>\nprerequisite-patch-id: 39559d044bc4db5a61d8d428ba227596b6f9a572\nprerequisite-patch-id: 76040d8ec266b78f698065cdc891c7a44a7deb59\nprerequisite-patch-id: 6a99a5acb7d2a9d331bd2fa364c5f048c4807630\nprerequisite-patch-id: f9bf8d3c7bd9ac8f1beeafc0d7bfa99809624ff5\nprerequisite-patch-id: b3b09e0cc0b35176a63e768e3dae4f39ed2bbd96\nprerequisite-patch-id: b2f0b893f4093ac7ac4466efe23472c381c207bf\nprerequisite-patch-id: 942b24fe8f6b5a1d2fd892e4dd52b83238b2bf6a\nprerequisite-patch-id: 95f28ecdf77807e7e6968c0bc75e29ea8fa5d687\nprerequisite-patch-id: 58e4f31b532d41d4394654ea1de6a3d2a3c54bff\nprerequisite-patch-id: 331073f51ccb93b8b02f14b6e52f8fb70651afc5\nprerequisite-patch-id: c357c6e7040737739a8d5d76424348bcc9444a79\nprerequisite-patch-id: d643b636c49ef0bca14fd198290ffbda331d2823\nprerequisite-patch-id: aeee0e7f421acd0c5e6d8a9cd45eb22b8f52a322\nprerequisite-patch-id: 88175b9418f0575a627ed6b592c61406bed0972c\nprerequisite-patch-id: 95241bfd7e6798b39187c3dfc03d47ab37ca50c4\nprerequisite-patch-id: 73dd2f88f2629f3a54ab01c2882962b9effd6055\nprerequisite-patch-id: 291c5ec532ed3738a59ad7001ef3a84e2c43aa78\nprerequisite-patch-id: 3b29840c001ec89f137b8e37796d710f60436a6a\nprerequisite-patch-id: 78bd944cca8c7404feb1f54d9adfcbfea481fa96\nprerequisite-patch-id: 9f34d87c5455cada6a68350daa86cb1069e7accc\nprerequisite-patch-id: 798827dcb73a002d4d604472e1b1a3b64f9b159d\nprerequisite-patch-id: a110e45c7f97287acbd8c69640d6f03d2e7d9bef\nprerequisite-patch-id: 3ce7cd65e984c138658841e3a4802178cc9129b2\nprerequisite-patch-id: 9cb10256bf2b131cf434ec078807f27be3a4d6cf\nprerequisite-patch-id: a97085715ee32eaaad3bcde53e7d41582424f0f9\nprerequisite-patch-id: 7a5e50bc7d49ec891a9679b1ea71575f41483187\n\n"},{"id":"509192","messageId":"20241217-pks-use-the-repository-conversion-v1-1-0dba48bcc239@pks.im","threadId":"62650","inReplyTo":"20241217-pks-use-the-repository-conversion-v1-0-0dba48bcc239@pks.im","subject":"[PATCH 01/14] progress: stop using `the_repository`","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2024-12-17T06:43:48Z","receivedAt":"2024-12-17T06:44:17Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"Stop using `the_repository` in the \"progress\" subsystem by passing in a\nrepository when initializing `struct progress`. Furthermore, store a\npointer to the repository in that struct so that we can pass it to the\ntrace2 API when logging information.\n\nAdjust callers accordingly by using `the_repository`. While there may be\nsome callers that have a repository available in their context, this\ntrivial conversion allows for easier verification and bubbles up the use\nof `the_repository` by one level.\n\nSigned-off-by: Patrick Steinhardt <ps@pks.im>\n---\n builtin/blame.c          |  4 +++-\n builtin/commit-graph.c   |  1 +\n builtin/fsck.c           | 12 ++++++++----\n builtin/index-pack.c     |  7 +++++--\n builtin/log.c            |  3 ++-\n builtin/pack-objects.c   | 21 ++++++++++++++-------\n builtin/prune.c          |  3 ++-\n builtin/remote.c         |  3 ++-\n builtin/rev-list.c       |  3 ++-\n builtin/unpack-objects.c |  3 ++-\n commit-graph.c           | 20 +++++++++++++++++---\n delta-islands.c          |  3 ++-\n diffcore-rename.c        |  1 +\n entry.c                  |  4 +++-\n midx-write.c             | 11 ++++++++---\n midx.c                   | 13 +++++++++----\n pack-bitmap-write.c      |  6 ++++--\n pack-bitmap.c            |  4 +++-\n preload-index.c          |  4 +++-\n progress.c               | 34 ++++++++++++++++++++--------------\n progress.h               | 13 +++++++++----\n prune-packed.c           |  3 ++-\n pseudo-merge.c           |  3 ++-\n read-cache.c             |  3 ++-\n t/helper/test-progress.c |  6 +++++-\n unpack-trees.c           |  4 +++-\n walker.c                 |  3 ++-\n 27 files changed, 136 insertions(+), 59 deletions(-)\n\ndiff --git a/builtin/blame.c b/builtin/blame.c\nindex 867032e4c16878ffd56df8a73162b89ca4bd2694..dd78288530f06efa99ec7a1ca767aa388805fd97 100644\n--- a/builtin/blame.c\n+++ b/builtin/blame.c\n@@ -1193,7 +1193,9 @@ int cmd_blame(int argc,\n \tsb.found_guilty_entry = &found_guilty_entry;\n \tsb.found_guilty_entry_data = &pi;\n \tif (show_progress)\n-\t\tpi.progress = start_delayed_progress(_(\"Blaming lines\"), num_lines);\n+\t\tpi.progress = start_delayed_progress(the_repository,\n+\t\t\t\t\t\t     _(\"Blaming lines\"),\n+\t\t\t\t\t\t     num_lines);\n \n \tassign_blame(&sb, opt);\n \ndiff --git a/builtin/commit-graph.c b/builtin/commit-graph.c\nindex bd70d052e706b6e34b5aaaceef158c63ea4863d5..8ca75262c59c480a33b53ce9010a882970066957 100644\n--- a/builtin/commit-graph.c\n+++ b/builtin/commit-graph.c\n@@ -305,6 +305,7 @@ static int graph_write(int argc, const char **argv, const char *prefix,\n \t\toidset_init(&commits, 0);\n \t\tif (opts.progress)\n \t\t\tprogress = start_delayed_progress(\n+\t\t\t\tthe_repository,\n \t\t\t\t_(\"Collecting commits from input\"), 0);\n \n \t\twhile (strbuf_getline(&buf, stdin) != EOF) {\ndiff --git a/builtin/fsck.c b/builtin/fsck.c\nindex 0196c54eb68ee54c22de72d64b3f31602594e50b..7a4dcb0716052ff1b9236ea66b8901960fe1c55d 100644\n--- a/builtin/fsck.c\n+++ b/builtin/fsck.c\n@@ -197,7 +197,8 @@ static int traverse_reachable(void)\n \tunsigned int nr = 0;\n \tint result = 0;\n \tif (show_progress)\n-\t\tprogress = start_delayed_progress(_(\"Checking connectivity\"), 0);\n+\t\tprogress = start_delayed_progress(the_repository,\n+\t\t\t\t\t\t  _(\"Checking connectivity\"), 0);\n \twhile (pending.nr) {\n \t\tresult |= traverse_one_object(object_array_pop(&pending));\n \t\tdisplay_progress(progress, ++nr);\n@@ -703,7 +704,8 @@ static void fsck_object_dir(const char *path)\n \t\tfprintf_ln(stderr, _(\"Checking object directory\"));\n \n \tif (show_progress)\n-\t\tprogress = start_progress(_(\"Checking object directories\"), 256);\n+\t\tprogress = start_progress(the_repository,\n+\t\t\t\t\t  _(\"Checking object directories\"), 256);\n \n \tfor_each_loose_file_in_objdir(path, fsck_loose, fsck_cruft, fsck_subdir,\n \t\t\t\t      &cb_data);\n@@ -879,7 +881,8 @@ static int check_pack_rev_indexes(struct repository *r, int show_progress)\n \tif (show_progress) {\n \t\tfor (struct packed_git *p = get_all_packs(r); p; p = p->next)\n \t\t\tpack_count++;\n-\t\tprogress = start_delayed_progress(\"Verifying reverse pack-indexes\", pack_count);\n+\t\tprogress = start_delayed_progress(the_repository,\n+\t\t\t\t\t\t  \"Verifying reverse pack-indexes\", pack_count);\n \t\tpack_count = 0;\n \t}\n \n@@ -989,7 +992,8 @@ int cmd_fsck(int argc,\n \t\t\t\t\ttotal += p->num_objects;\n \t\t\t\t}\n \n-\t\t\t\tprogress = start_progress(_(\"Checking objects\"), total);\n+\t\t\t\tprogress = start_progress(the_repository,\n+\t\t\t\t\t\t\t  _(\"Checking objects\"), total);\n \t\t\t}\n \t\t\tfor (p = get_all_packs(the_repository); p;\n \t\t\t     p = p->next) {\ndiff --git a/builtin/index-pack.c b/builtin/index-pack.c\nindex d773809c4c96604b7668b48d3c231460bd94c79b..05691104c36b4f18bf1287acac3f2a3719ea0261 100644\n--- a/builtin/index-pack.c\n+++ b/builtin/index-pack.c\n@@ -282,7 +282,8 @@ static unsigned check_objects(void)\n \tmax = get_max_object_index();\n \n \tif (verbose)\n-\t\tprogress = start_delayed_progress(_(\"Checking objects\"), max);\n+\t\tprogress = start_delayed_progress(the_repository,\n+\t\t\t\t\t\t  _(\"Checking objects\"), max);\n \n \tfor (i = 0; i < max; i++) {\n \t\tforeign_nr += check_object(get_indexed_object(i));\n@@ -1249,6 +1250,7 @@ static void parse_pack_objects(unsigned char *hash)\n \n \tif (verbose)\n \t\tprogress = start_progress(\n+\t\t\t\tthe_repository,\n \t\t\t\tprogress_title ? progress_title :\n \t\t\t\tfrom_stdin ? _(\"Receiving objects\") : _(\"Indexing objects\"),\n \t\t\t\tnr_objects);\n@@ -1329,7 +1331,8 @@ static void resolve_deltas(struct pack_idx_option *opts)\n \tQSORT(ref_deltas, nr_ref_deltas, compare_ref_delta_entry);\n \n \tif (verbose || show_resolving_progress)\n-\t\tprogress = start_progress(_(\"Resolving deltas\"),\n+\t\tprogress = start_progress(the_repository,\n+\t\t\t\t\t  _(\"Resolving deltas\"),\n \t\t\t\t\t  nr_ref_deltas + nr_ofs_deltas);\n \n \tnr_dispatched = 0;\ndiff --git a/builtin/log.c b/builtin/log.c\nindex cb41a035c6ead57e4d466ae0042a40435ebcde2f..317335e60d450128685d9fce99eb8fe8f9860fd9 100644\n--- a/builtin/log.c\n+++ b/builtin/log.c\n@@ -2495,7 +2495,8 @@ int cmd_format_patch(int argc,\n \trev.add_signoff = cfg.do_signoff;\n \n \tif (show_progress)\n-\t\tprogress = start_delayed_progress(_(\"Generating patches\"), total);\n+\t\tprogress = start_delayed_progress(the_repository,\n+\t\t\t\t\t\t  _(\"Generating patches\"), total);\n \twhile (0 <= --nr) {\n \t\tint shown;\n \t\tdisplay_progress(progress, total - nr);\ndiff --git a/builtin/pack-objects.c b/builtin/pack-objects.c\nindex 1c3b8426515c42f14c536eea559dd377212855f6..d51c021d99d9f470c04b7ec52565ab2f4c1c19ae 100644\n--- a/builtin/pack-objects.c\n+++ b/builtin/pack-objects.c\n@@ -1264,7 +1264,8 @@ static void write_pack_file(void)\n \tstruct object_entry **write_order;\n \n \tif (progress > pack_to_stdout)\n-\t\tprogress_state = start_progress(_(\"Writing objects\"), nr_result);\n+\t\tprogress_state = start_progress(the_repository,\n+\t\t\t\t\t\t_(\"Writing objects\"), nr_result);\n \tALLOC_ARRAY(written_list, to_pack.nr_objects);\n \twrite_order = compute_write_order();\n \n@@ -2400,7 +2401,8 @@ static void get_object_details(void)\n \tstruct object_entry **sorted_by_offset;\n \n \tif (progress)\n-\t\tprogress_state = start_progress(_(\"Counting objects\"),\n+\t\tprogress_state = start_progress(the_repository,\n+\t\t\t\t\t\t_(\"Counting objects\"),\n \t\t\t\t\t\tto_pack.nr_objects);\n \n \tCALLOC_ARRAY(sorted_by_offset, to_pack.nr_objects);\n@@ -3220,7 +3222,8 @@ static void prepare_pack(int window, int depth)\n \t\tunsigned nr_done = 0;\n \n \t\tif (progress)\n-\t\t\tprogress_state = start_progress(_(\"Compressing objects\"),\n+\t\t\tprogress_state = start_progress(the_repository,\n+\t\t\t\t\t\t\t_(\"Compressing objects\"),\n \t\t\t\t\t\t\tnr_deltas);\n \t\tQSORT(delta_list, n, type_size_sort);\n \t\tll_find_deltas(delta_list, n, window+1, depth, &nr_done);\n@@ -3648,7 +3651,8 @@ static void add_objects_in_unpacked_packs(void);\n static void enumerate_cruft_objects(void)\n {\n \tif (progress)\n-\t\tprogress_state = start_progress(_(\"Enumerating cruft objects\"), 0);\n+\t\tprogress_state = start_progress(the_repository,\n+\t\t\t\t\t\t_(\"Enumerating cruft objects\"), 0);\n \n \tadd_objects_in_unpacked_packs();\n \tadd_unreachable_loose_objects();\n@@ -3674,7 +3678,8 @@ static void enumerate_and_traverse_cruft_objects(struct string_list *fresh_packs\n \trevs.ignore_missing_links = 1;\n \n \tif (progress)\n-\t\tprogress_state = start_progress(_(\"Enumerating cruft objects\"), 0);\n+\t\tprogress_state = start_progress(the_repository,\n+\t\t\t\t\t\t_(\"Enumerating cruft objects\"), 0);\n \tret = add_unseen_recent_objects_to_traversal(&revs, cruft_expiration,\n \t\t\t\t\t\t     set_cruft_mtime, 1);\n \tstop_progress(&progress_state);\n@@ -3693,7 +3698,8 @@ static void enumerate_and_traverse_cruft_objects(struct string_list *fresh_packs\n \tif (prepare_revision_walk(&revs))\n \t\tdie(_(\"revision walk setup failed\"));\n \tif (progress)\n-\t\tprogress_state = start_progress(_(\"Traversing cruft objects\"), 0);\n+\t\tprogress_state = start_progress(the_repository,\n+\t\t\t\t\t\t_(\"Traversing cruft objects\"), 0);\n \tnr_seen = 0;\n \ttraverse_commit_list(&revs, show_cruft_commit, show_cruft_object, NULL);\n \n@@ -4625,7 +4631,8 @@ int cmd_pack_objects(int argc,\n \tprepare_packing_data(the_repository, &to_pack);\n \n \tif (progress && !cruft)\n-\t\tprogress_state = start_progress(_(\"Enumerating objects\"), 0);\n+\t\tprogress_state = start_progress(the_repository,\n+\t\t\t\t\t\t_(\"Enumerating objects\"), 0);\n \tif (stdin_packs) {\n \t\t/* avoids adding objects in excluded packs */\n \t\tignore_packed_keep_in_core = 1;\ndiff --git a/builtin/prune.c b/builtin/prune.c\nindex aeff9ca1b35c3f09c6bd334cbf52864df437fe05..1c357fffd8cde6816ecb598fb6588462f3074c09 100644\n--- a/builtin/prune.c\n+++ b/builtin/prune.c\n@@ -64,7 +64,8 @@ static void perform_reachability_traversal(struct rev_info *revs)\n \t\treturn;\n \n \tif (show_progress)\n-\t\tprogress = start_delayed_progress(_(\"Checking connectivity\"), 0);\n+\t\tprogress = start_delayed_progress(the_repository,\n+\t\t\t\t\t\t  _(\"Checking connectivity\"), 0);\n \tmark_reachable_objects(revs, 1, expire, progress);\n \tstop_progress(&progress);\n \tinitialized = 1;\ndiff --git a/builtin/remote.c b/builtin/remote.c\nindex b2b13a7dd2acd466081e7bb49186d45f167dce9f..95440bc9ff284eb109079e95f5a5f438040e7fd7 100644\n--- a/builtin/remote.c\n+++ b/builtin/remote.c\n@@ -820,7 +820,8 @@ static int mv(int argc, const char **argv, const char *prefix,\n \t\t * Count symrefs twice, since \"renaming\" them is done by\n \t\t * deleting and recreating them in two separate passes.\n \t\t */\n-\t\tprogress = start_progress(_(\"Renaming remote references\"),\n+\t\tprogress = start_progress(the_repository,\n+\t\t\t\t\t  _(\"Renaming remote references\"),\n \t\t\t\t\t  rename.remote_branches->nr + rename.symrefs_nr);\n \t}\n \tfor (i = 0; i < remote_branches.nr; i++) {\ndiff --git a/builtin/rev-list.c b/builtin/rev-list.c\nindex 3196da7b2d23e33fafde57a1af1c42a5c985f0b0..8a7db9b546196c76ce8e374915fffa378f1199c5 100644\n--- a/builtin/rev-list.c\n+++ b/builtin/rev-list.c\n@@ -735,7 +735,8 @@ int cmd_rev_list(int argc,\n \t\trevs.limited = 1;\n \n \tif (show_progress)\n-\t\tprogress = start_delayed_progress(show_progress, 0);\n+\t\tprogress = start_delayed_progress(the_repository,\n+\t\t\t\t\t\t  show_progress, 0);\n \n \tif (use_bitmap_index) {\n \t\tif (!try_bitmap_count(&revs, filter_provided_objects))\ndiff --git a/builtin/unpack-objects.c b/builtin/unpack-objects.c\nindex 2197d6d9332117636f31abadb5aff70424ba305d..842a90353a50b6a4be863237d2804e5ef509d478 100644\n--- a/builtin/unpack-objects.c\n+++ b/builtin/unpack-objects.c\n@@ -590,7 +590,8 @@ static void unpack_all(void)\n \tuse(sizeof(struct pack_header));\n \n \tif (!quiet)\n-\t\tprogress = start_progress(_(\"Unpacking objects\"), nr_objects);\n+\t\tprogress = start_progress(the_repository,\n+\t\t\t\t\t  _(\"Unpacking objects\"), nr_objects);\n \tCALLOC_ARRAY(obj_list, nr_objects);\n \tbegin_odb_transaction();\n \tfor (i = 0; i < nr_objects; i++) {\ndiff --git a/commit-graph.c b/commit-graph.c\nindex 0df66e5a243390bc1224b28e2b55c541f9d93fb1..2a2999a6b886905276a0c39dda6135f0c92aa361 100644\n--- a/commit-graph.c\n+++ b/commit-graph.c\n@@ -1534,6 +1534,7 @@ static void close_reachable(struct write_commit_graph_context *ctx)\n \n \tif (ctx->report_progress)\n \t\tctx->progress = start_delayed_progress(\n+\t\t\t\t\tthe_repository,\n \t\t\t\t\t_(\"Loading known commits in commit graph\"),\n \t\t\t\t\tctx->oids.nr);\n \tfor (i = 0; i < ctx->oids.nr; i++) {\n@@ -1551,6 +1552,7 @@ static void close_reachable(struct write_commit_graph_context *ctx)\n \t */\n \tif (ctx->report_progress)\n \t\tctx->progress = start_delayed_progress(\n+\t\t\t\t\tthe_repository,\n \t\t\t\t\t_(\"Expanding reachable commits in commit graph\"),\n \t\t\t\t\t0);\n \tfor (i = 0; i < ctx->oids.nr; i++) {\n@@ -1571,6 +1573,7 @@ static void close_reachable(struct write_commit_graph_context *ctx)\n \n \tif (ctx->report_progress)\n \t\tctx->progress = start_delayed_progress(\n+\t\t\t\t\tthe_repository,\n \t\t\t\t\t_(\"Clearing commit marks in commit graph\"),\n \t\t\t\t\tctx->oids.nr);\n \tfor (i = 0; i < ctx->oids.nr; i++) {\n@@ -1688,6 +1691,7 @@ static void compute_topological_levels(struct write_commit_graph_context *ctx)\n \tif (ctx->report_progress)\n \t\tinfo.progress = ctx->progress\n \t\t\t      = start_delayed_progress(\n+\t\t\t\t\tthe_repository,\n \t\t\t\t\t_(\"Computing commit graph topological levels\"),\n \t\t\t\t\tctx->commits.nr);\n \n@@ -1722,6 +1726,7 @@ static void compute_generation_numbers(struct write_commit_graph_context *ctx)\n \tif (ctx->report_progress)\n \t\tinfo.progress = ctx->progress\n \t\t\t      = start_delayed_progress(\n+\t\t\t\t\tthe_repository,\n \t\t\t\t\t_(\"Computing commit graph generation numbers\"),\n \t\t\t\t\tctx->commits.nr);\n \n@@ -1798,6 +1803,7 @@ static void compute_bloom_filters(struct write_commit_graph_context *ctx)\n \n \tif (ctx->report_progress)\n \t\tprogress = start_delayed_progress(\n+\t\t\tthe_repository,\n \t\t\t_(\"Computing commit changed paths Bloom filters\"),\n \t\t\tctx->commits.nr);\n \n@@ -1877,6 +1883,7 @@ int write_commit_graph_reachable(struct object_directory *odb,\n \tdata.commits = &commits;\n \tif (flags & COMMIT_GRAPH_WRITE_PROGRESS)\n \t\tdata.progress = start_delayed_progress(\n+\t\t\tthe_repository,\n \t\t\t_(\"Collecting referenced commits\"), 0);\n \n \trefs_for_each_ref(get_main_ref_store(the_repository), add_ref_to_set,\n@@ -1908,7 +1915,8 @@ static int fill_oids_from_packs(struct write_commit_graph_context *ctx,\n \t\t\t       \"Finding commits for commit graph in %\"PRIuMAX\" packs\",\n \t\t\t       pack_indexes->nr),\n \t\t\t    (uintmax_t)pack_indexes->nr);\n-\t\tctx->progress = start_delayed_progress(progress_title.buf, 0);\n+\t\tctx->progress = start_delayed_progress(the_repository,\n+\t\t\t\t\t\t       progress_title.buf, 0);\n \t\tctx->progress_done = 0;\n \t}\n \tfor (i = 0; i < pack_indexes->nr; i++) {\n@@ -1959,6 +1967,7 @@ static void fill_oids_from_all_packs(struct write_commit_graph_context *ctx)\n {\n \tif (ctx->report_progress)\n \t\tctx->progress = start_delayed_progress(\n+\t\t\tthe_repository,\n \t\t\t_(\"Finding commits for commit graph among packed objects\"),\n \t\t\tctx->approx_nr_objects);\n \tfor_each_packed_object(ctx->r, add_packed_commits, ctx,\n@@ -1977,6 +1986,7 @@ static void copy_oids_to_commits(struct write_commit_graph_context *ctx)\n \tctx->num_extra_edges = 0;\n \tif (ctx->report_progress)\n \t\tctx->progress = start_delayed_progress(\n+\t\t\tthe_repository,\n \t\t\t_(\"Finding extra edges in commit graph\"),\n \t\t\tctx->oids.nr);\n \toid_array_sort(&ctx->oids);\n@@ -2136,6 +2146,7 @@ static int write_commit_graph_file(struct write_commit_graph_context *ctx)\n \t\t\t       get_num_chunks(cf)),\n \t\t\t    get_num_chunks(cf));\n \t\tctx->progress = start_delayed_progress(\n+\t\t\tthe_repository,\n \t\t\tprogress_title.buf,\n \t\t\tst_mult(get_num_chunks(cf), ctx->commits.nr));\n \t}\n@@ -2348,6 +2359,7 @@ static void sort_and_scan_merged_commits(struct write_commit_graph_context *ctx)\n \n \tif (ctx->report_progress)\n \t\tctx->progress = start_delayed_progress(\n+\t\t\t\t\tthe_repository,\n \t\t\t\t\t_(\"Scanning merged commits\"),\n \t\t\t\t\tctx->commits.nr);\n \n@@ -2392,7 +2404,8 @@ static void merge_commit_graphs(struct write_commit_graph_context *ctx)\n \t\tcurrent_graph_number--;\n \n \t\tif (ctx->report_progress)\n-\t\t\tctx->progress = start_delayed_progress(_(\"Merging commit-graph\"), 0);\n+\t\t\tctx->progress = start_delayed_progress(the_repository,\n+\t\t\t\t\t\t\t       _(\"Merging commit-graph\"), 0);\n \n \t\tmerge_commit_graph(ctx, g);\n \t\tstop_progress(&ctx->progress);\n@@ -2874,7 +2887,8 @@ int verify_commit_graph(struct repository *r, struct commit_graph *g, int flags)\n \t\tif (!(flags & COMMIT_GRAPH_VERIFY_SHALLOW))\n \t\t\ttotal += g->num_commits_in_base;\n \n-\t\tprogress = start_progress(_(\"Verifying commits in commit graph\"),\n+\t\tprogress = start_progress(the_repository,\n+\t\t\t\t\t  _(\"Verifying commits in commit graph\"),\n \t\t\t\t\t  total);\n \t}\n \ndiff --git a/delta-islands.c b/delta-islands.c\nindex 1c465a6041914538bcb8be51c500653d8fa1a626..3aec43fada36f7052b825dcb2ac0e1ad79f028b7 100644\n--- a/delta-islands.c\n+++ b/delta-islands.c\n@@ -267,7 +267,8 @@ void resolve_tree_islands(struct repository *r,\n \tQSORT(todo, nr, tree_depth_compare);\n \n \tif (progress)\n-\t\tprogress_state = start_progress(_(\"Propagating island marks\"), nr);\n+\t\tprogress_state = start_progress(the_repository,\n+\t\t\t\t\t\t_(\"Propagating island marks\"), nr);\n \n \tfor (i = 0; i < nr; i++) {\n \t\tstruct object_entry *ent = todo[i].entry;\ndiff --git a/diffcore-rename.c b/diffcore-rename.c\nindex 10bb0321b10d5896aaa6a26a624d2066598bf51f..91b77993c7827f9ddc7b444b42f480b8209fd821 100644\n--- a/diffcore-rename.c\n+++ b/diffcore-rename.c\n@@ -1567,6 +1567,7 @@ void diffcore_rename_extended(struct diff_options *options,\n \ttrace2_region_enter(\"diff\", \"inexact renames\", options->repo);\n \tif (options->show_rename_progress) {\n \t\tprogress = start_delayed_progress(\n+\t\t\t\tthe_repository,\n \t\t\t\t_(\"Performing inexact rename detection\"),\n \t\t\t\t(uint64_t)num_destinations * (uint64_t)num_sources);\n \t}\ndiff --git a/entry.c b/entry.c\nindex 53a1c393582b2e6be4398985ca3c5f4fadece3cb..81b321e53d1b960976723ec1da49483bfd223ce8 100644\n--- a/entry.c\n+++ b/entry.c\n@@ -188,7 +188,9 @@ int finish_delayed_checkout(struct checkout *state, int show_progress)\n \n \tdco->state = CE_RETRY;\n \tif (show_progress)\n-\t\tprogress = start_delayed_progress(_(\"Filtering content\"), dco->paths.nr);\n+\t\tprogress = start_delayed_progress(the_repository,\n+\t\t\t\t\t\t  _(\"Filtering content\"),\n+\t\t\t\t\t\t  dco->paths.nr);\n \twhile (dco->filters.nr > 0) {\n \t\tfor_each_string_list_item(filter, &dco->filters) {\n \t\t\tstruct string_list available_paths = STRING_LIST_INIT_DUP;\ndiff --git a/midx-write.c b/midx-write.c\nindex 0066594fa6310b37903972e150c7cd1d7e232c38..b3827b936bdb1df12c73fb7d9b98ff65fc875cc3 100644\n--- a/midx-write.c\n+++ b/midx-write.c\n@@ -1131,7 +1131,8 @@ static int write_midx_internal(struct repository *r, const char *object_dir,\n \n \tctx.pack_paths_checked = 0;\n \tif (flags & MIDX_PROGRESS)\n-\t\tctx.progress = start_delayed_progress(_(\"Adding packfiles to multi-pack-index\"), 0);\n+\t\tctx.progress = start_delayed_progress(r,\n+\t\t\t\t\t\t      _(\"Adding packfiles to multi-pack-index\"), 0);\n \telse\n \t\tctx.progress = NULL;\n \n@@ -1539,7 +1540,9 @@ int expire_midx_packs(struct repository *r, const char *object_dir, unsigned fla\n \tCALLOC_ARRAY(count, m->num_packs);\n \n \tif (flags & MIDX_PROGRESS)\n-\t\tprogress = start_delayed_progress(_(\"Counting referenced objects\"),\n+\t\tprogress = start_delayed_progress(\n+\t\t\t\t\t  r,\n+\t\t\t\t\t  _(\"Counting referenced objects\"),\n \t\t\t\t\t  m->num_objects);\n \tfor (i = 0; i < m->num_objects; i++) {\n \t\tint pack_int_id = nth_midxed_pack_int_id(m, i);\n@@ -1549,7 +1552,9 @@ int expire_midx_packs(struct repository *r, const char *object_dir, unsigned fla\n \tstop_progress(&progress);\n \n \tif (flags & MIDX_PROGRESS)\n-\t\tprogress = start_delayed_progress(_(\"Finding and deleting unreferenced packfiles\"),\n+\t\tprogress = start_delayed_progress(\n+\t\t\t\t\t  r,\n+\t\t\t\t\t  _(\"Finding and deleting unreferenced packfiles\"),\n \t\t\t\t\t  m->num_packs);\n \tfor (i = 0; i < m->num_packs; i++) {\n \t\tchar *pack_name;\ndiff --git a/midx.c b/midx.c\nindex f8a75cafd4efeabd273268ba04cddefaa434e5b2..d91088efb87ca0d59b1ad215556a8cfe1612b8af 100644\n--- a/midx.c\n+++ b/midx.c\n@@ -907,7 +907,8 @@ int verify_midx_file(struct repository *r, const char *object_dir, unsigned flag\n \t\tmidx_report(_(\"incorrect checksum\"));\n \n \tif (flags & MIDX_PROGRESS)\n-\t\tprogress = start_delayed_progress(_(\"Looking for referenced packfiles\"),\n+\t\tprogress = start_delayed_progress(r,\n+\t\t\t\t\t\t  _(\"Looking for referenced packfiles\"),\n \t\t\t\t\t\t  m->num_packs + m->num_packs_in_base);\n \tfor (i = 0; i < m->num_packs + m->num_packs_in_base; i++) {\n \t\tif (prepare_midx_pack(r, m, i))\n@@ -927,7 +928,8 @@ int verify_midx_file(struct repository *r, const char *object_dir, unsigned flag\n \t}\n \n \tif (flags & MIDX_PROGRESS)\n-\t\tprogress = start_sparse_progress(_(\"Verifying OID order in multi-pack-index\"),\n+\t\tprogress = start_sparse_progress(r,\n+\t\t\t\t\t\t _(\"Verifying OID order in multi-pack-index\"),\n \t\t\t\t\t\t m->num_objects - 1);\n \n \tfor (curr = m; curr; curr = curr->base_midx) {\n@@ -959,14 +961,17 @@ int verify_midx_file(struct repository *r, const char *object_dir, unsigned flag\n \t}\n \n \tif (flags & MIDX_PROGRESS)\n-\t\tprogress = start_sparse_progress(_(\"Sorting objects by packfile\"),\n+\t\tprogress = start_sparse_progress(r,\n+\t\t\t\t\t\t _(\"Sorting objects by packfile\"),\n \t\t\t\t\t\t m->num_objects);\n \tdisplay_progress(progress, 0); /* TODO: Measure QSORT() progress */\n \tQSORT(pairs, m->num_objects, compare_pair_pos_vs_id);\n \tstop_progress(&progress);\n \n \tif (flags & MIDX_PROGRESS)\n-\t\tprogress = start_sparse_progress(_(\"Verifying object offsets\"), m->num_objects);\n+\t\tprogress = start_sparse_progress(r,\n+\t\t\t\t\t\t _(\"Verifying object offsets\"),\n+\t\t\t\t\t\t m->num_objects);\n \tfor (i = 0; i < m->num_objects + m->num_objects_in_base; i++) {\n \t\tstruct object_id oid;\n \t\tstruct pack_entry e;\ndiff --git a/pack-bitmap-write.c b/pack-bitmap-write.c\nindex 4f8be53c2bd75f83a0555e2a5510c2bbca07b36d..a06a1f35c619b3b01e63a506a6d4312e14cf181c 100644\n--- a/pack-bitmap-write.c\n+++ b/pack-bitmap-write.c\n@@ -590,7 +590,8 @@ int bitmap_writer_build(struct bitmap_writer *writer)\n \tint closed = 1; /* until proven otherwise */\n \n \tif (writer->show_progress)\n-\t\twriter->progress = start_progress(\"Building bitmaps\",\n+\t\twriter->progress = start_progress(the_repository,\n+\t\t\t\t\t\t  \"Building bitmaps\",\n \t\t\t\t\t\t  writer->selected_nr);\n \ttrace2_region_enter(\"pack-bitmap-write\", \"building_bitmaps_total\",\n \t\t\t    the_repository);\n@@ -710,7 +711,8 @@ void bitmap_writer_select_commits(struct bitmap_writer *writer,\n \t}\n \n \tif (writer->show_progress)\n-\t\twriter->progress = start_progress(\"Selecting bitmap commits\", 0);\n+\t\twriter->progress = start_progress(the_repository,\n+\t\t\t\t\t\t  \"Selecting bitmap commits\", 0);\n \n \tfor (;;) {\n \t\tstruct commit *chosen = NULL;\ndiff --git a/pack-bitmap.c b/pack-bitmap.c\nindex bceb6da042772df7afa741bafe7e4893473cbca8..48e3b99efb2f554f685392f5e23f47fb1954ffdc 100644\n--- a/pack-bitmap.c\n+++ b/pack-bitmap.c\n@@ -2578,7 +2578,9 @@ void test_bitmap_walk(struct rev_info *revs)\n \ttdata.trees = ewah_to_bitmap(bitmap_git->trees);\n \ttdata.blobs = ewah_to_bitmap(bitmap_git->blobs);\n \ttdata.tags = ewah_to_bitmap(bitmap_git->tags);\n-\ttdata.prg = start_progress(\"Verifying bitmap entries\", result_popcnt);\n+\ttdata.prg = start_progress(revs->repo,\n+\t\t\t\t   \"Verifying bitmap entries\",\n+\t\t\t\t   result_popcnt);\n \ttdata.seen = 0;\n \n \ttraverse_commit_list(revs, &test_show_commit, &test_show_object, &tdata);\ndiff --git a/preload-index.c b/preload-index.c\nindex ab94d6f39967ea4358f51ff8384aa60927bfe259..40ab2abafb8de500a5f2ec678a584a5fd5e1bc16 100644\n--- a/preload-index.c\n+++ b/preload-index.c\n@@ -132,7 +132,9 @@ void preload_index(struct index_state *index,\n \n \tmemset(&pd, 0, sizeof(pd));\n \tif (refresh_flags & REFRESH_PROGRESS && isatty(2)) {\n-\t\tpd.progress = start_delayed_progress(_(\"Refreshing index\"), index->cache_nr);\n+\t\tpd.progress = start_delayed_progress(the_repository,\n+\t\t\t\t\t\t     _(\"Refreshing index\"),\n+\t\t\t\t\t\t     index->cache_nr);\n \t\tpthread_mutex_init(&pd.mutex, NULL);\n \t}\n \ndiff --git a/progress.c b/progress.c\nindex a8fdfceb5cd12879ebac80589bb5b5e8661c2627..8d5ae70f3a9ec7042bf12782190f6514014b0287 100644\n--- a/progress.c\n+++ b/progress.c\n@@ -9,7 +9,6 @@\n  */\n \n #define GIT_TEST_PROGRESS_ONLY\n-#define USE_THE_REPOSITORY_VARIABLE\n #define DISABLE_SIGN_COMPARE_WARNINGS\n \n #include \"git-compat-util.h\"\n@@ -37,6 +36,7 @@ struct throughput {\n };\n \n struct progress {\n+\tstruct repository *repo;\n \tconst char *title;\n \tuint64_t last_value;\n \tuint64_t total;\n@@ -254,10 +254,12 @@ void display_progress(struct progress *progress, uint64_t n)\n \t\tdisplay(progress, n, NULL);\n }\n \n-static struct progress *start_progress_delay(const char *title, uint64_t total,\n+static struct progress *start_progress_delay(struct repository *r,\n+\t\t\t\t\t     const char *title, uint64_t total,\n \t\t\t\t\t     unsigned delay, unsigned sparse)\n {\n \tstruct progress *progress = xmalloc(sizeof(*progress));\n+\tprogress->repo = r;\n \tprogress->title = title;\n \tprogress->total = total;\n \tprogress->last_value = -1;\n@@ -270,7 +272,7 @@ static struct progress *start_progress_delay(const char *title, uint64_t total,\n \tprogress->title_len = utf8_strwidth(title);\n \tprogress->split = 0;\n \tset_progress_signal();\n-\ttrace2_region_enter(\"progress\", title, the_repository);\n+\ttrace2_region_enter(\"progress\", title, r);\n \treturn progress;\n }\n \n@@ -284,14 +286,16 @@ static int get_default_delay(void)\n \treturn delay_in_secs;\n }\n \n-struct progress *start_delayed_progress(const char *title, uint64_t total)\n+struct progress *start_delayed_progress(struct repository *r,\n+\t\t\t\t\tconst char *title, uint64_t total)\n {\n-\treturn start_progress_delay(title, total, get_default_delay(), 0);\n+\treturn start_progress_delay(r, title, total, get_default_delay(), 0);\n }\n \n-struct progress *start_progress(const char *title, uint64_t total)\n+struct progress *start_progress(struct repository *r,\n+\t\t\t\tconst char *title, uint64_t total)\n {\n-\treturn start_progress_delay(title, total, 0, 0);\n+\treturn start_progress_delay(r, title, total, 0, 0);\n }\n \n /*\n@@ -303,15 +307,17 @@ struct progress *start_progress(const char *title, uint64_t total)\n  * When \"sparse\" is set, stop_progress() will automatically force the done\n  * message to show 100%.\n  */\n-struct progress *start_sparse_progress(const char *title, uint64_t total)\n+struct progress *start_sparse_progress(struct repository *r,\n+\t\t\t\t       const char *title, uint64_t total)\n {\n-\treturn start_progress_delay(title, total, 0, 1);\n+\treturn start_progress_delay(r, title, total, 0, 1);\n }\n \n-struct progress *start_delayed_sparse_progress(const char *title,\n+struct progress *start_delayed_sparse_progress(struct repository *r,\n+\t\t\t\t\t       const char *title,\n \t\t\t\t\t       uint64_t total)\n {\n-\treturn start_progress_delay(title, total, get_default_delay(), 1);\n+\treturn start_progress_delay(r, title, total, get_default_delay(), 1);\n }\n \n static void finish_if_sparse(struct progress *progress)\n@@ -341,14 +347,14 @@ static void force_last_update(struct progress *progress, const char *msg)\n \n static void log_trace2(struct progress *progress)\n {\n-\ttrace2_data_intmax(\"progress\", the_repository, \"total_objects\",\n+\ttrace2_data_intmax(\"progress\", progress->repo, \"total_objects\",\n \t\t\t   progress->total);\n \n \tif (progress->throughput)\n-\t\ttrace2_data_intmax(\"progress\", the_repository, \"total_bytes\",\n+\t\ttrace2_data_intmax(\"progress\", progress->repo, \"total_bytes\",\n \t\t\t\t   progress->throughput->curr_total);\n \n-\ttrace2_region_leave(\"progress\", progress->title, the_repository);\n+\ttrace2_region_leave(\"progress\", progress->title, progress->repo);\n }\n \n void stop_progress_msg(struct progress **p_progress, const char *msg)\ndiff --git a/progress.h b/progress.h\nindex 3a945637c81c22734b563325b66956ee4fb33b0b..ed068c7bab845b17f55d4ed8f0907497ad23fd47 100644\n--- a/progress.h\n+++ b/progress.h\n@@ -3,6 +3,7 @@\n #include \"gettext.h\"\n \n struct progress;\n+struct repository;\n \n #ifdef GIT_TEST_PROGRESS_ONLY\n \n@@ -14,10 +15,14 @@ void progress_test_force_update(void);\n \n void display_throughput(struct progress *progress, uint64_t total);\n void display_progress(struct progress *progress, uint64_t n);\n-struct progress *start_progress(const char *title, uint64_t total);\n-struct progress *start_sparse_progress(const char *title, uint64_t total);\n-struct progress *start_delayed_progress(const char *title, uint64_t total);\n-struct progress *start_delayed_sparse_progress(const char *title,\n+struct progress *start_progress(struct repository *r,\n+\t\t\t\tconst char *title, uint64_t total);\n+struct progress *start_sparse_progress(struct repository *r,\n+\t\t\t\t       const char *title, uint64_t total);\n+struct progress *start_delayed_progress(struct repository *r,\n+\t\t\t\t\tconst char *title, uint64_t total);\n+struct progress *start_delayed_sparse_progress(struct repository *r,\n+\t\t\t\t\t       const char *title,\n \t\t\t\t\t       uint64_t total);\n void stop_progress_msg(struct progress **p_progress, const char *msg);\n static inline void stop_progress(struct progress **p_progress)\ndiff --git a/prune-packed.c b/prune-packed.c\nindex d1c65ab10ed6004aae8265ce05f8db9ae3a33ad9..7dad2fc0c169cf456ba646536cddae399b0555bd 100644\n--- a/prune-packed.c\n+++ b/prune-packed.c\n@@ -37,7 +37,8 @@ static int prune_object(const struct object_id *oid, const char *path,\n void prune_packed_objects(int opts)\n {\n \tif (opts & PRUNE_PACKED_VERBOSE)\n-\t\tprogress = start_delayed_progress(_(\"Removing duplicate objects\"), 256);\n+\t\tprogress = start_delayed_progress(the_repository,\n+\t\t\t\t\t\t  _(\"Removing duplicate objects\"), 256);\n \n \tfor_each_loose_file_in_objdir(repo_get_object_directory(the_repository),\n \t\t\t\t      prune_object, NULL, prune_subdir, &opts);\ndiff --git a/pseudo-merge.c b/pseudo-merge.c\nindex 971f54cfe1a895aed00f6d0a65c62aafc83a0cc8..893b763fe45490875ea226eaffff0c7cb1dafb06 100644\n--- a/pseudo-merge.c\n+++ b/pseudo-merge.c\n@@ -459,7 +459,8 @@ void select_pseudo_merges(struct bitmap_writer *writer)\n \t\treturn;\n \n \tif (writer->show_progress)\n-\t\tprogress = start_progress(\"Selecting pseudo-merge commits\",\n+\t\tprogress = start_progress(the_repository,\n+\t\t\t\t\t  \"Selecting pseudo-merge commits\",\n \t\t\t\t\t  writer->pseudo_merge_groups.nr);\n \n \trefs_for_each_ref(get_main_ref_store(the_repository),\ndiff --git a/read-cache.c b/read-cache.c\nindex 15d79839c205176f9161f537aa706dac44b3023c..38c36caa7fef4d44da74c29e059839d88426df15 100644\n--- a/read-cache.c\n+++ b/read-cache.c\n@@ -1523,7 +1523,8 @@ int refresh_index(struct index_state *istate, unsigned int flags,\n \tint t2_sum_scan = 0;\n \n \tif (flags & REFRESH_PROGRESS && isatty(2))\n-\t\tprogress = start_delayed_progress(_(\"Refresh index\"),\n+\t\tprogress = start_delayed_progress(the_repository,\n+\t\t\t\t\t\t  _(\"Refresh index\"),\n \t\t\t\t\t\t  istate->cache_nr);\n \n \ttrace_performance_enter();\ndiff --git a/t/helper/test-progress.c b/t/helper/test-progress.c\nindex 44be2645e9c7cb66e54b07832bd84f6efe6fc772..1f75b7bd199aff9e332c2601e444ce7b165e78c2 100644\n--- a/t/helper/test-progress.c\n+++ b/t/helper/test-progress.c\n@@ -17,10 +17,14 @@\n  *\n  * See 't0500-progress-display.sh' for examples.\n  */\n+\n+#define USE_THE_REPOSITORY_VARIABLE\n #define GIT_TEST_PROGRESS_ONLY\n+\n #include \"test-tool.h\"\n #include \"parse-options.h\"\n #include \"progress.h\"\n+#include \"repository.h\"\n #include \"strbuf.h\"\n #include \"string-list.h\"\n \n@@ -64,7 +68,7 @@ int cmd__progress(int argc, const char **argv)\n \t\t\telse\n \t\t\t\tdie(\"invalid input: '%s'\", line.buf);\n \n-\t\t\tprogress = start_progress(title, total);\n+\t\t\tprogress = start_progress(the_repository, title, total);\n \t\t} else if (skip_prefix(line.buf, \"progress \", (const char **) &end)) {\n \t\t\tuint64_t item_count = strtoull(end, &end, 10);\n \t\t\tif (*end != '\\0')\ndiff --git a/unpack-trees.c b/unpack-trees.c\nindex b3be5d542f5fc5a02b8838101f7334ff44b2c626..334cb84f6531b588688d5a43c538c8d1a5f7e768 100644\n--- a/unpack-trees.c\n+++ b/unpack-trees.c\n@@ -372,7 +372,8 @@ static struct progress *get_progress(struct unpack_trees_options *o,\n \t\t\ttotal++;\n \t}\n \n-\treturn start_delayed_progress(_(\"Updating files\"), total);\n+\treturn start_delayed_progress(the_repository,\n+\t\t\t\t      _(\"Updating files\"), total);\n }\n \n static void setup_collided_checkout_detection(struct checkout *state,\n@@ -1773,6 +1774,7 @@ static int clear_ce_flags(struct index_state *istate,\n \tstrbuf_reset(&prefix);\n \tif (show_progress)\n \t\tistate->progress = start_delayed_progress(\n+\t\t\t\t\tthe_repository,\n \t\t\t\t\t_(\"Updating index flags\"),\n \t\t\t\t\tistate->cache_nr);\n \ndiff --git a/walker.c b/walker.c\nindex 7cc9dbea46d64d6bd3336025d640f284a6202157..1cf3da02193531a17fd11dbd2e8aadf36f38b200 100644\n--- a/walker.c\n+++ b/walker.c\n@@ -172,7 +172,8 @@ static int loop(struct walker *walker)\n \tuint64_t nr = 0;\n \n \tif (walker->get_progress)\n-\t\tprogress = start_delayed_progress(_(\"Fetching objects\"), 0);\n+\t\tprogress = start_delayed_progress(the_repository,\n+\t\t\t\t\t\t  _(\"Fetching objects\"), 0);\n \n \twhile (process_queue) {\n \t\tstruct object *obj = process_queue->item;\n\n-- \n2.48.0.rc0.184.g0fc57dec57.dirty\n\n"},{"id":"509190","messageId":"20241217-pks-use-the-repository-conversion-v1-2-0dba48bcc239@pks.im","threadId":"62650","inReplyTo":"20241217-pks-use-the-repository-conversion-v1-0-0dba48bcc239@pks.im","subject":"[PATCH 02/14] pager: stop using `the_repository`","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2024-12-17T06:43:49Z","receivedAt":"2024-12-17T06:44:18Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"Stop using `the_repository` in the \"pager\" subsystem by passing in a\nrepository when setting up the pager and when configuring it.\n\nAdjust callers accordingly by using `the_repository`. While there may be\nsome callers that have a repository available in their context, this\ntrivial conversion allows for easier verification and bubbles up the use\nof `the_repository` by one level.\n\nSigned-off-by: Patrick Steinhardt <ps@pks.im>\n---\n add-patch.c     |  2 +-\n builtin/am.c    |  4 ++--\n builtin/blame.c |  2 +-\n builtin/grep.c  |  4 ++--\n builtin/help.c  |  4 ++--\n builtin/log.c   |  4 ++--\n builtin/var.c   |  2 +-\n diff.c          |  4 ++--\n git.c           |  8 ++++----\n pager.c         | 14 ++++++--------\n pager.h         |  7 ++++---\n 11 files changed, 27 insertions(+), 28 deletions(-)\n\ndiff --git a/add-patch.c b/add-patch.c\nindex 7b598e14df016402ca41e1998466b5ba45623f90..95c67d8c80c4f33bfa6180f69fdf2065d0b5b85c 100644\n--- a/add-patch.c\n+++ b/add-patch.c\n@@ -1464,7 +1464,7 @@ static int patch_update_file(struct add_p_state *s,\n \t\tif (file_diff->hunk_nr) {\n \t\t\tif (rendered_hunk_index != hunk_index) {\n \t\t\t\tif (use_pager) {\n-\t\t\t\t\tsetup_pager();\n+\t\t\t\t\tsetup_pager(the_repository);\n \t\t\t\t\tsigchain_push(SIGPIPE, SIG_IGN);\n \t\t\t\t}\n \t\t\t\trender_hunk(s, hunk, 0, colored, &s->buf);\ndiff --git a/builtin/am.c b/builtin/am.c\nindex 1338b606febdde6700c573b45f89aa70785f54e8..27ccca8341feefcda5e1c4a850f14fce9e4deecb 100644\n--- a/builtin/am.c\n+++ b/builtin/am.c\n@@ -1786,7 +1786,7 @@ static int do_interactive(struct am_state *state)\n \t\t\t}\n \t\t\tstrbuf_release(&msg);\n \t\t} else if (*reply == 'v' || *reply == 'V') {\n-\t\t\tconst char *pager = git_pager(1);\n+\t\t\tconst char *pager = git_pager(the_repository, 1);\n \t\t\tstruct child_process cp = CHILD_PROCESS_INIT;\n \n \t\t\tif (!pager)\n@@ -2246,7 +2246,7 @@ static int show_patch(struct am_state *state, enum resume_type resume_mode)\n \tif (len < 0)\n \t\tdie_errno(_(\"failed to read '%s'\"), patch_path);\n \n-\tsetup_pager();\n+\tsetup_pager(the_repository);\n \twrite_in_full(1, sb.buf, sb.len);\n \tstrbuf_release(&sb);\n \treturn 0;\ndiff --git a/builtin/blame.c b/builtin/blame.c\nindex dd78288530f06efa99ec7a1ca767aa388805fd97..1f44c341c50ecd80fd76d2f055d488884cfcd20c 100644\n--- a/builtin/blame.c\n+++ b/builtin/blame.c\n@@ -1202,7 +1202,7 @@ int cmd_blame(int argc,\n \tstop_progress(&pi.progress);\n \n \tif (!incremental)\n-\t\tsetup_pager();\n+\t\tsetup_pager(the_repository);\n \telse\n \t\tgoto cleanup;\n \ndiff --git a/builtin/grep.c b/builtin/grep.c\nindex d00ee76f24cfdea8ac15e08f812aa5868906940c..d1427290f773b6cec539fcd838ada2b61acb22c8 100644\n--- a/builtin/grep.c\n+++ b/builtin/grep.c\n@@ -1084,7 +1084,7 @@ int cmd_grep(int argc,\n \t}\n \n \tif (show_in_pager == default_pager)\n-\t\tshow_in_pager = git_pager(1);\n+\t\tshow_in_pager = git_pager(the_repository, 1);\n \tif (show_in_pager) {\n \t\topt.color = 0;\n \t\topt.name_only = 1;\n@@ -1246,7 +1246,7 @@ int cmd_grep(int argc,\n \t}\n \n \tif (!show_in_pager && !opt.status_only)\n-\t\tsetup_pager();\n+\t\tsetup_pager(the_repository);\n \n \tdie_for_incompatible_opt3(!use_index, \"--no-index\",\n \t\t\t\t  untracked, \"--untracked\",\ndiff --git a/builtin/help.c b/builtin/help.c\nindex 05136279cf7b1007ab754f5630c34536a5f9461f..c257079cebc3c09fb91f258c3b0148e2f204c0e7 100644\n--- a/builtin/help.c\n+++ b/builtin/help.c\n@@ -658,7 +658,7 @@ int cmd_help(int argc,\n \tcase HELP_ACTION_ALL:\n \t\topt_mode_usage(argc, \"--all\", help_format);\n \t\tif (verbose) {\n-\t\t\tsetup_pager();\n+\t\t\tsetup_pager(the_repository);\n \t\t\tlist_all_cmds_help(show_external_commands,\n \t\t\t\t\t   show_aliases);\n \t\t\treturn 0;\n@@ -692,7 +692,7 @@ int cmd_help(int argc,\n \t\treturn 0;\n \tcase HELP_ACTION_CONFIG:\n \t\topt_mode_usage(argc, \"--config\", help_format);\n-\t\tsetup_pager();\n+\t\tsetup_pager(the_repository);\n \t\tlist_config_help(SHOW_CONFIG_HUMAN);\n \t\tprintf(\"\\n%s\\n\", _(\"'git help config' for more information\"));\n \t\treturn 0;\ndiff --git a/builtin/log.c b/builtin/log.c\nindex 317335e60d450128685d9fce99eb8fe8f9860fd9..3a6a3362f3c36ee257215e79cf40085f76c9efb3 100644\n--- a/builtin/log.c\n+++ b/builtin/log.c\n@@ -369,7 +369,7 @@ static void cmd_log_init_finish(int argc, const char **argv, const char *prefix,\n \tif (rev->line_level_traverse)\n \t\tline_log_init(rev, line_cb.prefix, &line_cb.args);\n \n-\tsetup_pager();\n+\tsetup_pager(the_repository);\n }\n \n static void cmd_log_init(int argc, const char **argv, const char *prefix,\n@@ -2292,7 +2292,7 @@ int cmd_format_patch(int argc,\n \t\trev.commit_format = CMIT_FMT_MBOXRD;\n \n \tif (use_stdout) {\n-\t\tsetup_pager();\n+\t\tsetup_pager(the_repository);\n \t} else if (!rev.diffopt.close_file) {\n \t\tint saved;\n \ndiff --git a/builtin/var.c b/builtin/var.c\nindex 1449656cc924f849ee9c881c18b734a3ec55e9f3..50d024de66604ab9e8faa1bd59f662127bc62159 100644\n--- a/builtin/var.c\n+++ b/builtin/var.c\n@@ -42,7 +42,7 @@ static char *sequence_editor(int ident_flag UNUSED)\n \n static char *pager(int ident_flag UNUSED)\n {\n-\tconst char *pgm = git_pager(1);\n+\tconst char *pgm = git_pager(the_repository, 1);\n \n \tif (!pgm)\n \t\tpgm = \"cat\";\ndiff --git a/diff.c b/diff.c\nindex d28b4114c8dffba5cb5339152d198588550135a0..0822ae443361f80271c91a863a6f03b0e8c403c3 100644\n--- a/diff.c\n+++ b/diff.c\n@@ -7386,6 +7386,6 @@ void setup_diff_pager(struct diff_options *opt)\n \t * --exit-code\" in hooks and other scripts, we do not do so.\n \t */\n \tif (!opt->flags.exit_with_status &&\n-\t    check_pager_config(\"diff\") != 0)\n-\t\tsetup_pager();\n+\t    check_pager_config(the_repository, \"diff\") != 0)\n+\t\tsetup_pager(the_repository);\n }\ndiff --git a/git.c b/git.c\nindex 71d644dc1c59902b2f14c14914c78285ffa92638..d977ebc84cfba611c3e452cace3bda1ce13faf5d 100644\n--- a/git.c\n+++ b/git.c\n@@ -125,7 +125,7 @@ static void commit_pager_choice(void)\n \t\tsetenv(\"GIT_PAGER\", \"cat\", 1);\n \t\tbreak;\n \tcase 1:\n-\t\tsetup_pager();\n+\t\tsetup_pager(the_repository);\n \t\tbreak;\n \tdefault:\n \t\tbreak;\n@@ -136,7 +136,7 @@ void setup_auto_pager(const char *cmd, int def)\n {\n \tif (use_pager != -1 || pager_in_use())\n \t\treturn;\n-\tuse_pager = check_pager_config(cmd);\n+\tuse_pager = check_pager_config(the_repository, cmd);\n \tif (use_pager == -1)\n \t\tuse_pager = def;\n \tcommit_pager_choice();\n@@ -462,7 +462,7 @@ static int run_builtin(struct cmd_struct *p, int argc, const char **argv, struct\n \tprecompose_argv_prefix(argc, argv, NULL);\n \tif (use_pager == -1 && run_setup &&\n \t\t!(p->option & DELAY_PAGER_CONFIG))\n-\t\tuse_pager = check_pager_config(p->cmd);\n+\t\tuse_pager = check_pager_config(the_repository, p->cmd);\n \tif (use_pager == -1 && p->option & USE_PAGER)\n \t\tuse_pager = 1;\n \tif (run_setup && startup_info->have_repository)\n@@ -750,7 +750,7 @@ static void execv_dashed_external(const char **argv)\n \tint status;\n \n \tif (use_pager == -1 && !is_builtin(argv[0]))\n-\t\tuse_pager = check_pager_config(argv[0]);\n+\t\tuse_pager = check_pager_config(the_repository, argv[0]);\n \tcommit_pager_choice();\n \n \tstrvec_pushf(&cmd.args, \"git-%s\", argv[0]);\ndiff --git a/pager.c b/pager.c\nindex 40b664f893c8ec61af0e6d00d58956f45b247d65..5531fff50eb73f7d22defcc7d8e752c94f741d66 100644\n--- a/pager.c\n+++ b/pager.c\n@@ -1,5 +1,3 @@\n-#define USE_THE_REPOSITORY_VARIABLE\n-\n #include \"git-compat-util.h\"\n #include \"config.h\"\n #include \"editor.h\"\n@@ -84,7 +82,7 @@ static int core_pager_config(const char *var, const char *value,\n \treturn 0;\n }\n \n-const char *git_pager(int stdout_is_tty)\n+const char *git_pager(struct repository *r, int stdout_is_tty)\n {\n \tconst char *pager;\n \n@@ -94,7 +92,7 @@ const char *git_pager(int stdout_is_tty)\n \tpager = getenv(\"GIT_PAGER\");\n \tif (!pager) {\n \t\tif (!pager_program)\n-\t\t\tread_early_config(the_repository,\n+\t\t\tread_early_config(r,\n \t\t\t\t\t  core_pager_config, NULL);\n \t\tpager = pager_program;\n \t}\n@@ -143,10 +141,10 @@ void prepare_pager_args(struct child_process *pager_process, const char *pager)\n \tpager_process->trace2_child_class = \"pager\";\n }\n \n-void setup_pager(void)\n+void setup_pager(struct repository *r)\n {\n \tstatic int once = 0;\n-\tconst char *pager = git_pager(isatty(1));\n+\tconst char *pager = git_pager(r, isatty(1));\n \n \tif (!pager)\n \t\treturn;\n@@ -293,7 +291,7 @@ static int pager_command_config(const char *var, const char *value,\n }\n \n /* returns 0 for \"no pager\", 1 for \"use pager\", and -1 for \"not specified\" */\n-int check_pager_config(const char *cmd)\n+int check_pager_config(struct repository *r, const char *cmd)\n {\n \tstruct pager_command_config_data data;\n \n@@ -301,7 +299,7 @@ int check_pager_config(const char *cmd)\n \tdata.want = -1;\n \tdata.value = NULL;\n \n-\tread_early_config(the_repository, pager_command_config, &data);\n+\tread_early_config(r, pager_command_config, &data);\n \n \tif (data.value)\n \t\tpager_program = data.value;\ndiff --git a/pager.h b/pager.h\nindex 103ecac476fdd6523930d7ff8fe542eeec038438..d070be6348971663d3ac913ed702a7ba541cb4e8 100644\n--- a/pager.h\n+++ b/pager.h\n@@ -2,15 +2,16 @@\n #define PAGER_H\n \n struct child_process;\n+struct repository;\n \n-const char *git_pager(int stdout_is_tty);\n-void setup_pager(void);\n+const char *git_pager(struct repository *r, int stdout_is_tty);\n+void setup_pager(struct repository *r);\n void wait_for_pager(void);\n int pager_in_use(void);\n int term_columns(void);\n void term_clear_line(void);\n int decimal_width(uintmax_t);\n-int check_pager_config(const char *cmd);\n+int check_pager_config(struct repository *r, const char *cmd);\n void prepare_pager_args(struct child_process *, const char *pager);\n \n extern int pager_use_color;\n\n-- \n2.48.0.rc0.184.g0fc57dec57.dirty\n\n"},{"id":"509191","messageId":"20241217-pks-use-the-repository-conversion-v1-3-0dba48bcc239@pks.im","threadId":"62650","inReplyTo":"20241217-pks-use-the-repository-conversion-v1-0-0dba48bcc239@pks.im","subject":"[PATCH 03/14] trace: stop using `the_repository`","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2024-12-17T06:43:50Z","receivedAt":"2024-12-17T06:44:18Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"Stop using `the_repository` in the \"trace\" subsystem by passing in a\nrepository when setting up tracing.\n\nAdjust the only caller accordingly.\n\nSigned-off-by: Patrick Steinhardt <ps@pks.im>\n---\n git.c   | 2 +-\n trace.c | 9 ++++-----\n trace.h | 4 +++-\n 3 files changed, 8 insertions(+), 7 deletions(-)\n\ndiff --git a/git.c b/git.c\nindex d977ebc84cfba611c3e452cace3bda1ce13faf5d..a94dab3770251fa8b7b466daa85c2d61ca730670 100644\n--- a/git.c\n+++ b/git.c\n@@ -467,7 +467,7 @@ static int run_builtin(struct cmd_struct *p, int argc, const char **argv, struct\n \t\tuse_pager = 1;\n \tif (run_setup && startup_info->have_repository)\n \t\t/* get_git_dir() may set up repo, avoid that */\n-\t\ttrace_repo_setup();\n+\t\ttrace_repo_setup(the_repository);\n \tcommit_pager_choice();\n \n \tif (!help && p->option & NEED_WORK_TREE)\ndiff --git a/trace.c b/trace.c\nindex 2cfd25942ee725b022e8dea26096f01f2164a407..9b99460db82a28634c09260b42f311f7c69f4d59 100644\n--- a/trace.c\n+++ b/trace.c\n@@ -21,7 +21,6 @@\n  *  along with this program; if not, see <https://www.gnu.org/licenses/>.\n  */\n \n-#define USE_THE_REPOSITORY_VARIABLE\n #define DISABLE_SIGN_COMPARE_WARNINGS\n \n #include \"git-compat-util.h\"\n@@ -298,7 +297,7 @@ static const char *quote_crnl(const char *path)\n \treturn new_path.buf;\n }\n \n-void trace_repo_setup(void)\n+void trace_repo_setup(struct repository *r)\n {\n \tconst char *git_work_tree, *prefix = startup_info->prefix;\n \tchar *cwd;\n@@ -308,14 +307,14 @@ void trace_repo_setup(void)\n \n \tcwd = xgetcwd();\n \n-\tif (!(git_work_tree = repo_get_work_tree(the_repository)))\n+\tif (!(git_work_tree = repo_get_work_tree(r)))\n \t\tgit_work_tree = \"(null)\";\n \n \tif (!startup_info->prefix)\n \t\tprefix = \"(null)\";\n \n-\ttrace_printf_key(&trace_setup_key, \"setup: git_dir: %s\\n\", quote_crnl(repo_get_git_dir(the_repository)));\n-\ttrace_printf_key(&trace_setup_key, \"setup: git_common_dir: %s\\n\", quote_crnl(repo_get_common_dir(the_repository)));\n+\ttrace_printf_key(&trace_setup_key, \"setup: git_dir: %s\\n\", quote_crnl(repo_get_git_dir(r)));\n+\ttrace_printf_key(&trace_setup_key, \"setup: git_common_dir: %s\\n\", quote_crnl(repo_get_common_dir(r)));\n \ttrace_printf_key(&trace_setup_key, \"setup: worktree: %s\\n\", quote_crnl(git_work_tree));\n \ttrace_printf_key(&trace_setup_key, \"setup: cwd: %s\\n\", quote_crnl(cwd));\n \ttrace_printf_key(&trace_setup_key, \"setup: prefix: %s\\n\", quote_crnl(prefix));\ndiff --git a/trace.h b/trace.h\nindex d304d55aa1d706dc3f65bbf15c7b2506bc0e9499..9152fe9b3e565ee8dde1ddf185f30f021812a416 100644\n--- a/trace.h\n+++ b/trace.h\n@@ -92,7 +92,9 @@ extern struct trace_key trace_default_key;\n extern struct trace_key trace_perf_key;\n extern struct trace_key trace_setup_key;\n \n-void trace_repo_setup(void);\n+struct repository;\n+\n+void trace_repo_setup(struct repository *r);\n \n /**\n  * Checks whether the trace key is enabled. Used to prevent expensive\n\n-- \n2.48.0.rc0.184.g0fc57dec57.dirty\n\n"},{"id":"509193","messageId":"20241217-pks-use-the-repository-conversion-v1-4-0dba48bcc239@pks.im","threadId":"62650","inReplyTo":"20241217-pks-use-the-repository-conversion-v1-0-0dba48bcc239@pks.im","subject":"[PATCH 04/14] serve: stop using `the_repository`","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2024-12-17T06:43:51Z","receivedAt":"2024-12-17T06:44:19Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"Stop using `the_repository` in the \"serve\" subsystem by passing in a\nrepository when advertising capabilities or serving requests.\n\nAdjust callers accordingly by using `the_repository`. While there may be\nsome callers that have a repository available in their context, this\ntrivial conversion allows for easier verification and bubbles up the use\nof `the_repository` by one level.\n\nSigned-off-by: Patrick Steinhardt <ps@pks.im>\n---\n builtin/upload-pack.c    |  6 ++++--\n serve.c                  | 36 +++++++++++++++++-------------------\n serve.h                  |  6 ++++--\n t/helper/test-serve-v2.c |  7 +++++--\n 4 files changed, 30 insertions(+), 25 deletions(-)\n\ndiff --git a/builtin/upload-pack.c b/builtin/upload-pack.c\nindex dd63d6eadfe0028b3a62d7d14f777c919f567cc8..c2bbc035ab0c91baf5d66cee8bb370ecf1640505 100644\n--- a/builtin/upload-pack.c\n+++ b/builtin/upload-pack.c\n@@ -1,3 +1,5 @@\n+#define USE_THE_REPOSITORY_VARIABLE\n+\n #include \"builtin.h\"\n #include \"exec-cmd.h\"\n #include \"gettext.h\"\n@@ -63,9 +65,9 @@ int cmd_upload_pack(int argc,\n \tswitch (determine_protocol_version_server()) {\n \tcase protocol_v2:\n \t\tif (advertise_refs)\n-\t\t\tprotocol_v2_advertise_capabilities();\n+\t\t\tprotocol_v2_advertise_capabilities(the_repository);\n \t\telse\n-\t\t\tprotocol_v2_serve_loop(stateless_rpc);\n+\t\t\tprotocol_v2_serve_loop(the_repository, stateless_rpc);\n \t\tbreak;\n \tcase protocol_v1:\n \t\t/*\ndiff --git a/serve.c b/serve.c\nindex c8694e375159ca0044cb045500954770e1e5cb93..f6dfe34a2bee6b24bedace2c272f8377dec9fb91 100644\n--- a/serve.c\n+++ b/serve.c\n@@ -1,5 +1,3 @@\n-#define USE_THE_REPOSITORY_VARIABLE\n-\n #include \"git-compat-util.h\"\n #include \"repository.h\"\n #include \"config.h\"\n@@ -159,7 +157,7 @@ static struct protocol_capability capabilities[] = {\n \t},\n };\n \n-void protocol_v2_advertise_capabilities(void)\n+void protocol_v2_advertise_capabilities(struct repository *r)\n {\n \tstruct strbuf capability = STRBUF_INIT;\n \tstruct strbuf value = STRBUF_INIT;\n@@ -170,7 +168,7 @@ void protocol_v2_advertise_capabilities(void)\n \tfor (size_t i = 0; i < ARRAY_SIZE(capabilities); i++) {\n \t\tstruct protocol_capability *c = &capabilities[i];\n \n-\t\tif (c->advertise(the_repository, &value)) {\n+\t\tif (c->advertise(r, &value)) {\n \t\t\tstrbuf_addstr(&capability, c->name);\n \n \t\t\tif (value.len) {\n@@ -214,20 +212,20 @@ static struct protocol_capability *get_capability(const char *key, const char **\n \treturn NULL;\n }\n \n-static int receive_client_capability(const char *key)\n+static int receive_client_capability(struct repository *r, const char *key)\n {\n \tconst char *value;\n \tconst struct protocol_capability *c = get_capability(key, &value);\n \n-\tif (!c || c->command || !c->advertise(the_repository, NULL))\n+\tif (!c || c->command || !c->advertise(r, NULL))\n \t\treturn 0;\n \n \tif (c->receive)\n-\t\tc->receive(the_repository, value);\n+\t\tc->receive(r, value);\n \treturn 1;\n }\n \n-static int parse_command(const char *key, struct protocol_capability **command)\n+static int parse_command(struct repository *r, const char *key, struct protocol_capability **command)\n {\n \tconst char *out;\n \n@@ -238,7 +236,7 @@ static int parse_command(const char *key, struct protocol_capability **command)\n \t\tif (*command)\n \t\t\tdie(\"command '%s' requested after already requesting command '%s'\",\n \t\t\t    out, (*command)->name);\n-\t\tif (!cmd || !cmd->advertise(the_repository, NULL) || !cmd->command || value)\n+\t\tif (!cmd || !cmd->advertise(r, NULL) || !cmd->command || value)\n \t\t\tdie(\"invalid command '%s'\", out);\n \n \t\t*command = cmd;\n@@ -253,7 +251,7 @@ enum request_state {\n \tPROCESS_REQUEST_DONE,\n };\n \n-static int process_request(void)\n+static int process_request(struct repository *r)\n {\n \tenum request_state state = PROCESS_REQUEST_KEYS;\n \tstruct packet_reader reader;\n@@ -278,8 +276,8 @@ static int process_request(void)\n \t\tcase PACKET_READ_EOF:\n \t\t\tBUG(\"Should have already died when seeing EOF\");\n \t\tcase PACKET_READ_NORMAL:\n-\t\t\tif (parse_command(reader.line, &command) ||\n-\t\t\t    receive_client_capability(reader.line))\n+\t\t\tif (parse_command(r, reader.line, &command) ||\n+\t\t\t    receive_client_capability(r, reader.line))\n \t\t\t\tseen_capability_or_command = 1;\n \t\t\telse\n \t\t\t\tdie(\"unknown capability '%s'\", reader.line);\n@@ -319,30 +317,30 @@ static int process_request(void)\n \tif (!command)\n \t\tdie(\"no command requested\");\n \n-\tif (client_hash_algo != hash_algo_by_ptr(the_repository->hash_algo))\n+\tif (client_hash_algo != hash_algo_by_ptr(r->hash_algo))\n \t\tdie(\"mismatched object format: server %s; client %s\",\n-\t\t    the_repository->hash_algo->name,\n+\t\t    r->hash_algo->name,\n \t\t    hash_algos[client_hash_algo].name);\n \n-\tcommand->command(the_repository, &reader);\n+\tcommand->command(r, &reader);\n \n \treturn 0;\n }\n \n-void protocol_v2_serve_loop(int stateless_rpc)\n+void protocol_v2_serve_loop(struct repository *r, int stateless_rpc)\n {\n \tif (!stateless_rpc)\n-\t\tprotocol_v2_advertise_capabilities();\n+\t\tprotocol_v2_advertise_capabilities(r);\n \n \t/*\n \t * If stateless-rpc was requested then exit after\n \t * a single request/response exchange\n \t */\n \tif (stateless_rpc) {\n-\t\tprocess_request();\n+\t\tprocess_request(r);\n \t} else {\n \t\tfor (;;)\n-\t\t\tif (process_request())\n+\t\t\tif (process_request(r))\n \t\t\t\tbreak;\n \t}\n }\ndiff --git a/serve.h b/serve.h\nindex f946cf904a242db5106625e280d7daa671348516..85bf73cfe53cb9cbb4b042c43a1f6a55338ad6ed 100644\n--- a/serve.h\n+++ b/serve.h\n@@ -1,7 +1,9 @@\n #ifndef SERVE_H\n #define SERVE_H\n \n-void protocol_v2_advertise_capabilities(void);\n-void protocol_v2_serve_loop(int stateless_rpc);\n+struct repository;\n+\n+void protocol_v2_advertise_capabilities(struct repository *r);\n+void protocol_v2_serve_loop(struct repository *r, int stateless_rpc);\n \n #endif /* SERVE_H */\ndiff --git a/t/helper/test-serve-v2.c b/t/helper/test-serve-v2.c\nindex 054cbcf5d83946b225774dc9da6b0ec1d112e79d..63a200b8d46f68bfd69f63f844977cc8e382bb32 100644\n--- a/t/helper/test-serve-v2.c\n+++ b/t/helper/test-serve-v2.c\n@@ -1,6 +1,9 @@\n+#define USE_THE_REPOSITORY_VARIABLE\n+\n #include \"test-tool.h\"\n #include \"gettext.h\"\n #include \"parse-options.h\"\n+#include \"repository.h\"\n #include \"serve.h\"\n #include \"setup.h\"\n \n@@ -28,9 +31,9 @@ int cmd__serve_v2(int argc, const char **argv)\n \t\t\t     PARSE_OPT_KEEP_UNKNOWN_OPT);\n \n \tif (advertise_capabilities)\n-\t\tprotocol_v2_advertise_capabilities();\n+\t\tprotocol_v2_advertise_capabilities(the_repository);\n \telse\n-\t\tprotocol_v2_serve_loop(stateless_rpc);\n+\t\tprotocol_v2_serve_loop(the_repository, stateless_rpc);\n \n \treturn 0;\n }\n\n-- \n2.48.0.rc0.184.g0fc57dec57.dirty\n\n"},{"id":"509194","messageId":"20241217-pks-use-the-repository-conversion-v1-5-0dba48bcc239@pks.im","threadId":"62650","inReplyTo":"20241217-pks-use-the-repository-conversion-v1-0-0dba48bcc239@pks.im","subject":"[PATCH 05/14] send-pack: stop using `the_repository`","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2024-12-17T06:43:52Z","receivedAt":"2024-12-17T06:44:19Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"Stop using `the_repository` in the \"send-pack\" subsystem by passing in a\nrepository when sending a packfile.\n\nAdjust callers accordingly by using `the_repository`. While there may be\nsome callers that have a repository available in their context, this\ntrivial conversion allows for easier verification and bubbles up the use\nof `the_repository` by one level.\n\nSigned-off-by: Patrick Steinhardt <ps@pks.im>\n---\n builtin/send-pack.c |  2 +-\n send-pack.c         | 77 ++++++++++++++++++++++++++++-------------------------\n send-pack.h         |  3 ++-\n transport.c         |  2 +-\n 4 files changed, 44 insertions(+), 40 deletions(-)\n\ndiff --git a/builtin/send-pack.c b/builtin/send-pack.c\nindex 59b626aae8cd8291104d83b5ec201207c97715e8..8d461008e2e860a3de91a69412d66dcbde4d7b96 100644\n--- a/builtin/send-pack.c\n+++ b/builtin/send-pack.c\n@@ -317,7 +317,7 @@ int cmd_send_pack(int argc,\n \tset_ref_status_for_push(remote_refs, args.send_mirror,\n \t\targs.force_update);\n \n-\tret = send_pack(&args, fd, conn, remote_refs, &extra_have);\n+\tret = send_pack(the_repository, &args, fd, conn, remote_refs, &extra_have);\n \n \tif (helper_status)\n \t\tprint_helper_status(remote_refs);\ndiff --git a/send-pack.c b/send-pack.c\nindex 7e8321368379efe2600a1f573e2e4cd5140a008d..772c7683a0157004ede74e56157e3a5d7f082e75 100644\n--- a/send-pack.c\n+++ b/send-pack.c\n@@ -1,5 +1,3 @@\n-#define USE_THE_REPOSITORY_VARIABLE\n-\n #include \"git-compat-util.h\"\n #include \"config.h\"\n #include \"commit.h\"\n@@ -44,10 +42,11 @@ int option_parse_push_signed(const struct option *opt,\n \tdie(\"bad %s argument: %s\", opt->long_name, arg);\n }\n \n-static void feed_object(const struct object_id *oid, FILE *fh, int negative)\n+static void feed_object(struct repository *r,\n+\t\t\tconst struct object_id *oid, FILE *fh, int negative)\n {\n \tif (negative &&\n-\t    !repo_has_object_file_with_flags(the_repository, oid,\n+\t    !repo_has_object_file_with_flags(r, oid,\n \t\t\t\t\t     OBJECT_INFO_SKIP_FETCH_OBJECT |\n \t\t\t\t\t     OBJECT_INFO_QUICK))\n \t\treturn;\n@@ -61,7 +60,8 @@ static void feed_object(const struct object_id *oid, FILE *fh, int negative)\n /*\n  * Make a pack stream and spit it out into file descriptor fd\n  */\n-static int pack_objects(int fd, struct ref *refs, struct oid_array *advertised,\n+static int pack_objects(struct repository *r,\n+\t\t\tint fd, struct ref *refs, struct oid_array *advertised,\n \t\t\tstruct oid_array *negotiated,\n \t\t\tstruct send_pack_args *args)\n {\n@@ -74,7 +74,7 @@ static int pack_objects(int fd, struct ref *refs, struct oid_array *advertised,\n \tFILE *po_in;\n \tint rc;\n \n-\ttrace2_region_enter(\"send_pack\", \"pack_objects\", the_repository);\n+\ttrace2_region_enter(\"send_pack\", \"pack_objects\", r);\n \tstrvec_push(&po.args, \"pack-objects\");\n \tstrvec_push(&po.args, \"--all-progress-implied\");\n \tstrvec_push(&po.args, \"--revs\");\n@@ -87,7 +87,7 @@ static int pack_objects(int fd, struct ref *refs, struct oid_array *advertised,\n \t\tstrvec_push(&po.args, \"-q\");\n \tif (args->progress)\n \t\tstrvec_push(&po.args, \"--progress\");\n-\tif (is_repository_shallow(the_repository))\n+\tif (is_repository_shallow(r))\n \t\tstrvec_push(&po.args, \"--shallow\");\n \tif (args->disable_bitmaps)\n \t\tstrvec_push(&po.args, \"--no-use-bitmap-index\");\n@@ -104,15 +104,15 @@ static int pack_objects(int fd, struct ref *refs, struct oid_array *advertised,\n \t */\n \tpo_in = xfdopen(po.in, \"w\");\n \tfor (size_t i = 0; i < advertised->nr; i++)\n-\t\tfeed_object(&advertised->oid[i], po_in, 1);\n+\t\tfeed_object(r, &advertised->oid[i], po_in, 1);\n \tfor (size_t i = 0; i < negotiated->nr; i++)\n-\t\tfeed_object(&negotiated->oid[i], po_in, 1);\n+\t\tfeed_object(r, &negotiated->oid[i], po_in, 1);\n \n \twhile (refs) {\n \t\tif (!is_null_oid(&refs->old_oid))\n-\t\t\tfeed_object(&refs->old_oid, po_in, 1);\n+\t\t\tfeed_object(r, &refs->old_oid, po_in, 1);\n \t\tif (!is_null_oid(&refs->new_oid))\n-\t\t\tfeed_object(&refs->new_oid, po_in, 0);\n+\t\t\tfeed_object(r, &refs->new_oid, po_in, 0);\n \t\trefs = refs->next;\n \t}\n \n@@ -146,10 +146,10 @@ static int pack_objects(int fd, struct ref *refs, struct oid_array *advertised,\n \t\t */\n \t\tif (rc > 128 && rc != 141)\n \t\t\terror(\"pack-objects died of signal %d\", rc - 128);\n-\t\ttrace2_region_leave(\"send_pack\", \"pack_objects\", the_repository);\n+\t\ttrace2_region_leave(\"send_pack\", \"pack_objects\", r);\n \t\treturn -1;\n \t}\n-\ttrace2_region_leave(\"send_pack\", \"pack_objects\", the_repository);\n+\ttrace2_region_leave(\"send_pack\", \"pack_objects\", r);\n \treturn 0;\n }\n \n@@ -164,7 +164,8 @@ static int receive_unpack_status(struct packet_reader *reader)\n \treturn 0;\n }\n \n-static int receive_status(struct packet_reader *reader, struct ref *refs)\n+static int receive_status(struct repository *r,\n+\t\t\t  struct packet_reader *reader, struct ref *refs)\n {\n \tstruct ref *hint;\n \tint ret;\n@@ -172,7 +173,7 @@ static int receive_status(struct packet_reader *reader, struct ref *refs)\n \tint new_report = 0;\n \tint once = 0;\n \n-\ttrace2_region_enter(\"send_pack\", \"receive_status\", the_repository);\n+\ttrace2_region_enter(\"send_pack\", \"receive_status\", r);\n \thint = NULL;\n \tret = receive_unpack_status(reader);\n \twhile (1) {\n@@ -221,10 +222,10 @@ static int receive_status(struct packet_reader *reader, struct ref *refs)\n \t\t\tif (!strcmp(key, \"refname\"))\n \t\t\t\treport->ref_name = xstrdup_or_null(val);\n \t\t\telse if (!strcmp(key, \"old-oid\") && val &&\n-\t\t\t\t !parse_oid_hex(val, &old_oid, &val))\n+\t\t\t\t !parse_oid_hex_algop(val, &old_oid, &val, r->hash_algo))\n \t\t\t\treport->old_oid = oiddup(&old_oid);\n \t\t\telse if (!strcmp(key, \"new-oid\") && val &&\n-\t\t\t\t !parse_oid_hex(val, &new_oid, &val))\n+\t\t\t\t !parse_oid_hex_algop(val, &new_oid, &val, r->hash_algo))\n \t\t\t\treport->new_oid = oiddup(&new_oid);\n \t\t\telse if (!strcmp(key, \"forced-update\"))\n \t\t\t\treport->forced_update = 1;\n@@ -271,7 +272,7 @@ static int receive_status(struct packet_reader *reader, struct ref *refs)\n \t\t\tnew_report = 1;\n \t\t}\n \t}\n-\ttrace2_region_leave(\"send_pack\", \"receive_status\", the_repository);\n+\ttrace2_region_leave(\"send_pack\", \"receive_status\", r);\n \treturn ret;\n }\n \n@@ -293,9 +294,9 @@ static int advertise_shallow_grafts_cb(const struct commit_graft *graft, void *c\n \treturn 0;\n }\n \n-static void advertise_shallow_grafts_buf(struct strbuf *sb)\n+static void advertise_shallow_grafts_buf(struct repository *r, struct strbuf *sb)\n {\n-\tif (!is_repository_shallow(the_repository))\n+\tif (!is_repository_shallow(r))\n \t\treturn;\n \tfor_each_commit_graft(advertise_shallow_grafts_cb, sb);\n }\n@@ -426,13 +427,14 @@ static void reject_invalid_nonce(const char *nonce, int len)\n \t}\n }\n \n-static void get_commons_through_negotiation(const char *url,\n+static void get_commons_through_negotiation(struct repository *r,\n+\t\t\t\t\t    const char *url,\n \t\t\t\t\t    const struct ref *remote_refs,\n \t\t\t\t\t    struct oid_array *commons)\n {\n \tstruct child_process child = CHILD_PROCESS_INIT;\n \tconst struct ref *ref;\n-\tint len = the_hash_algo->hexsz + 1; /* hash + NL */\n+\tint len = r->hash_algo->hexsz + 1; /* hash + NL */\n \tint nr_negotiation_tip = 0;\n \n \tchild.git_cmd = 1;\n@@ -466,7 +468,7 @@ static void get_commons_through_negotiation(const char *url,\n \t\t\tbreak;\n \t\tif (read_len != len)\n \t\t\tdie(\"invalid length read %d\", read_len);\n-\t\tif (parse_oid_hex(hex_hash, &oid, &end) || *end != '\\n')\n+\t\tif (parse_oid_hex_algop(hex_hash, &oid, &end, r->hash_algo) || *end != '\\n')\n \t\t\tdie(\"invalid hash\");\n \t\toid_array_append(commons, &oid);\n \t} while (1);\n@@ -480,7 +482,8 @@ static void get_commons_through_negotiation(const char *url,\n \t}\n }\n \n-int send_pack(struct send_pack_args *args,\n+int send_pack(struct repository *r,\n+\t      struct send_pack_args *args,\n \t      int fd[], struct child_process *conn,\n \t      struct ref *remote_refs,\n \t      struct oid_array *extra_have)\n@@ -518,17 +521,17 @@ int send_pack(struct send_pack_args *args,\n \t\tgoto out;\n \t}\n \n-\tgit_config_get_bool(\"push.negotiate\", &push_negotiate);\n+\trepo_config_get_bool(r, \"push.negotiate\", &push_negotiate);\n \tif (push_negotiate) {\n-\t\ttrace2_region_enter(\"send_pack\", \"push_negotiate\", the_repository);\n-\t\tget_commons_through_negotiation(args->url, remote_refs, &commons);\n-\t\ttrace2_region_leave(\"send_pack\", \"push_negotiate\", the_repository);\n+\t\ttrace2_region_enter(\"send_pack\", \"push_negotiate\", r);\n+\t\tget_commons_through_negotiation(r, args->url, remote_refs, &commons);\n+\t\ttrace2_region_leave(\"send_pack\", \"push_negotiate\", r);\n \t}\n \n-\tif (!git_config_get_bool(\"push.usebitmaps\", &use_bitmaps))\n+\tif (!repo_config_get_bool(r, \"push.usebitmaps\", &use_bitmaps))\n \t\targs->disable_bitmaps = !use_bitmaps;\n \n-\tgit_config_get_bool(\"transfer.advertisesid\", &advertise_sid);\n+\trepo_config_get_bool(r, \"transfer.advertisesid\", &advertise_sid);\n \n \t/* Does the other end support the reporting? */\n \tif (server_supports(\"report-status-v2\"))\n@@ -554,7 +557,7 @@ int send_pack(struct send_pack_args *args,\n \tif (server_supports(\"push-options\"))\n \t\tpush_options_supported = 1;\n \n-\tif (!server_supports_hash(the_hash_algo->name, &object_format_supported))\n+\tif (!server_supports_hash(r->hash_algo->name, &object_format_supported))\n \t\tdie(_(\"the receiving end does not support this repository's hash algorithm\"));\n \n \tif (args->push_cert != SEND_PACK_PUSH_CERT_NEVER) {\n@@ -596,7 +599,7 @@ int send_pack(struct send_pack_args *args,\n \tif (use_push_options)\n \t\tstrbuf_addstr(&cap_buf, \" push-options\");\n \tif (object_format_supported)\n-\t\tstrbuf_addf(&cap_buf, \" object-format=%s\", the_hash_algo->name);\n+\t\tstrbuf_addf(&cap_buf, \" object-format=%s\", r->hash_algo->name);\n \tif (agent_supported)\n \t\tstrbuf_addf(&cap_buf, \" agent=%s\", git_user_agent_sanitized());\n \tif (advertise_sid)\n@@ -646,7 +649,7 @@ int send_pack(struct send_pack_args *args,\n \t}\n \n \tif (!args->dry_run)\n-\t\tadvertise_shallow_grafts_buf(&req_buf);\n+\t\tadvertise_shallow_grafts_buf(r, &req_buf);\n \n \t/*\n \t * Finally, tell the other end!\n@@ -686,7 +689,7 @@ int send_pack(struct send_pack_args *args,\n \t}\n \n \tif (args->stateless_rpc) {\n-\t\tif (!args->dry_run && (cmds_sent || is_repository_shallow(the_repository))) {\n+\t\tif (!args->dry_run && (cmds_sent || is_repository_shallow(r))) {\n \t\t\tpacket_buf_flush(&req_buf);\n \t\t\tsend_sideband(out, -1, req_buf.buf, req_buf.len, LARGE_PACKET_MAX);\n \t\t}\n@@ -711,7 +714,7 @@ int send_pack(struct send_pack_args *args,\n \t\t\t   PACKET_READ_DIE_ON_ERR_PACKET);\n \n \tif (need_pack_data && cmds_sent) {\n-\t\tif (pack_objects(out, remote_refs, extra_have, &commons, args) < 0) {\n+\t\tif (pack_objects(r, out, remote_refs, extra_have, &commons, args) < 0) {\n \t\t\tif (args->stateless_rpc)\n \t\t\t\tclose(out);\n \t\t\tif (git_connection_is_socket(conn))\n@@ -724,7 +727,7 @@ int send_pack(struct send_pack_args *args,\n \t\t\t * we get one).\n \t\t\t */\n \t\t\tif (status_report)\n-\t\t\t\treceive_status(&reader, remote_refs);\n+\t\t\t\treceive_status(r, &reader, remote_refs);\n \n \t\t\tif (use_sideband) {\n \t\t\t\tclose(demux.out);\n@@ -743,7 +746,7 @@ int send_pack(struct send_pack_args *args,\n \t\tpacket_flush(out);\n \n \tif (status_report && cmds_sent)\n-\t\tret = receive_status(&reader, remote_refs);\n+\t\tret = receive_status(r, &reader, remote_refs);\n \telse\n \t\tret = 0;\n \tif (args->stateless_rpc)\ndiff --git a/send-pack.h b/send-pack.h\nindex 7edb80596c7b0edf607ea5cd0f01315106d02b73..d256715681b363d46db284b7ed22658960781571 100644\n--- a/send-pack.h\n+++ b/send-pack.h\n@@ -6,6 +6,7 @@\n struct child_process;\n struct oid_array;\n struct ref;\n+struct repository;\n \n /* Possible values for push_cert field in send_pack_args. */\n #define SEND_PACK_PUSH_CERT_NEVER 0\n@@ -35,7 +36,7 @@ struct option;\n int option_parse_push_signed(const struct option *opt,\n \t\t\t     const char *arg, int unset);\n \n-int send_pack(struct send_pack_args *args,\n+int send_pack(struct repository *r, struct send_pack_args *args,\n \t      int fd[], struct child_process *conn,\n \t      struct ref *remote_refs, struct oid_array *extra_have);\n \ndiff --git a/transport.c b/transport.c\nindex 10d820c33353f695691506560f817c7515218139..81ae8243b9a32ab5289149e51a5a4b46340ac1fe 100644\n--- a/transport.c\n+++ b/transport.c\n@@ -932,7 +932,7 @@ static int git_transport_push(struct transport *transport, struct ref *remote_re\n \t\tbreak;\n \tcase protocol_v1:\n \tcase protocol_v0:\n-\t\tret = send_pack(&args, data->fd, data->conn, remote_refs,\n+\t\tret = send_pack(the_repository, &args, data->fd, data->conn, remote_refs,\n \t\t\t\t&data->extra_have);\n \t\tbreak;\n \tcase protocol_unknown_version:\n\n-- \n2.48.0.rc0.184.g0fc57dec57.dirty\n\n"},{"id":"509195","messageId":"20241217-pks-use-the-repository-conversion-v1-6-0dba48bcc239@pks.im","threadId":"62650","inReplyTo":"20241217-pks-use-the-repository-conversion-v1-0-0dba48bcc239@pks.im","subject":"[PATCH 06/14] server-info: stop using `the_repository`","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2024-12-17T06:43:53Z","receivedAt":"2024-12-17T06:44:19Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"Stop using `the_repository` in the \"server-info\" subsystem by passing in\na repository when updating server info and storing the repository in the\n`update_info_ctx` structure to make it accessible to other functions.\n\nAdjust callers accordingly by using `the_repository`. While there may be\nsome callers that have a repository available in their context, this\ntrivial conversion allows for easier verification and bubbles up the use\nof `the_repository` by one level.\n\nSigned-off-by: Patrick Steinhardt <ps@pks.im>\n---\n builtin/receive-pack.c       |  2 +-\n builtin/repack.c             |  2 +-\n builtin/update-server-info.c |  2 +-\n server-info.c                | 40 ++++++++++++++++++++++------------------\n server-info.h                |  4 +++-\n 5 files changed, 28 insertions(+), 22 deletions(-)\n\ndiff --git a/builtin/receive-pack.c b/builtin/receive-pack.c\nindex c2e9103f112c1e37e9f030308633daf49eec1ecf..191b5eeb34e6791776f93a3a9509efa887e4e087 100644\n--- a/builtin/receive-pack.c\n+++ b/builtin/receive-pack.c\n@@ -2628,7 +2628,7 @@ int cmd_receive_pack(int argc,\n \t\t\t}\n \t\t}\n \t\tif (auto_update_server_info)\n-\t\t\tupdate_server_info(0);\n+\t\t\tupdate_server_info(the_repository, 0);\n \t\tclear_shallow_info(&si);\n \t}\n \tif (use_sideband)\ndiff --git a/builtin/repack.c b/builtin/repack.c\nindex 0c6dad7df47a1665026a348921c33b2067b59976..81d13630ea41f832bd0210971c13a82a3ddc0971 100644\n--- a/builtin/repack.c\n+++ b/builtin/repack.c\n@@ -1565,7 +1565,7 @@ int cmd_repack(int argc,\n \t}\n \n \tif (run_update_server_info)\n-\t\tupdate_server_info(0);\n+\t\tupdate_server_info(the_repository, 0);\n \n \tif (git_env_bool(GIT_TEST_MULTI_PACK_INDEX, 0)) {\n \t\tunsigned flags = 0;\ndiff --git a/builtin/update-server-info.c b/builtin/update-server-info.c\nindex 6769611a025d0d69bcd3dbbd06f5fed056262911..47a3f0bdd9c3498808b86c2e31f4489926226102 100644\n--- a/builtin/update-server-info.c\n+++ b/builtin/update-server-info.c\n@@ -27,5 +27,5 @@ int cmd_update_server_info(int argc,\n \tif (argc > 0)\n \t\tusage_with_options(update_server_info_usage, options);\n \n-\treturn !!update_server_info(force);\n+\treturn !!update_server_info(the_repository, force);\n }\ndiff --git a/server-info.c b/server-info.c\nindex ef2f3f4b5c7b04c46520b2fd9d4352b806658f40..31c3fdc118447d42745362935e3483c59b7e0bc2 100644\n--- a/server-info.c\n+++ b/server-info.c\n@@ -1,4 +1,3 @@\n-#define USE_THE_REPOSITORY_VARIABLE\n #define DISABLE_SIGN_COMPARE_WARNINGS\n \n #include \"git-compat-util.h\"\n@@ -18,6 +17,7 @@\n #include \"tempfile.h\"\n \n struct update_info_ctx {\n+\tstruct repository *repo;\n \tFILE *cur_fp;\n \tFILE *old_fp; /* becomes NULL if it differs from cur_fp */\n \tstruct strbuf cur_sb;\n@@ -73,7 +73,7 @@ static int uic_printf(struct update_info_ctx *uic, const char *fmt, ...)\n  * it into place. The contents of the file come from \"generate\", which\n  * should return non-zero if it encounters an error.\n  */\n-static int update_info_file(char *path,\n+static int update_info_file(struct repository *r, char *path,\n \t\t\tint (*generate)(struct update_info_ctx *),\n \t\t\tint force)\n {\n@@ -81,6 +81,7 @@ static int update_info_file(char *path,\n \tstruct tempfile *f = NULL;\n \tint ret = -1;\n \tstruct update_info_ctx uic = {\n+\t\t.repo = r,\n \t\t.cur_fp = NULL,\n \t\t.old_fp = NULL,\n \t\t.cur_sb = STRBUF_INIT,\n@@ -152,7 +153,7 @@ static int add_info_ref(const char *path, const char *referent UNUSED, const str\n \t\t\tvoid *cb_data)\n {\n \tstruct update_info_ctx *uic = cb_data;\n-\tstruct object *o = parse_object(the_repository, oid);\n+\tstruct object *o = parse_object(uic->repo, oid);\n \tif (!o)\n \t\treturn -1;\n \n@@ -160,7 +161,7 @@ static int add_info_ref(const char *path, const char *referent UNUSED, const str\n \t\treturn -1;\n \n \tif (o->type == OBJ_TAG) {\n-\t\to = deref_tag(the_repository, o, path, 0);\n+\t\to = deref_tag(uic->repo, o, path, 0);\n \t\tif (o)\n \t\t\tif (uic_printf(uic, \"%s\t%s^{}\\n\",\n \t\t\t\toid_to_hex(&o->oid), path) < 0)\n@@ -171,14 +172,14 @@ static int add_info_ref(const char *path, const char *referent UNUSED, const str\n \n static int generate_info_refs(struct update_info_ctx *uic)\n {\n-\treturn refs_for_each_ref(get_main_ref_store(the_repository),\n+\treturn refs_for_each_ref(get_main_ref_store(uic->repo),\n \t\t\t\t add_info_ref, uic);\n }\n \n-static int update_info_refs(int force)\n+static int update_info_refs(struct repository *r, int force)\n {\n-\tchar *path = git_pathdup(\"info/refs\");\n-\tint ret = update_info_file(path, generate_info_refs, force);\n+\tchar *path = repo_git_path(r, \"info/refs\");\n+\tint ret = update_info_file(r, path, generate_info_refs, force);\n \tfree(path);\n \treturn ret;\n }\n@@ -284,14 +285,14 @@ static int compare_info(const void *a_, const void *b_)\n \t\treturn 1;\n }\n \n-static void init_pack_info(const char *infofile, int force)\n+static void init_pack_info(struct repository *r, const char *infofile, int force)\n {\n \tstruct packed_git *p;\n \tint stale;\n \tint i;\n \tsize_t alloc = 0;\n \n-\tfor (p = get_all_packs(the_repository); p; p = p->next) {\n+\tfor (p = get_all_packs(r); p; p = p->next) {\n \t\t/* we ignore things on alternate path since they are\n \t\t * not available to the pullers in general.\n \t\t */\n@@ -340,33 +341,36 @@ static int write_pack_info_file(struct update_info_ctx *uic)\n \treturn 0;\n }\n \n-static int update_info_packs(int force)\n+static int update_info_packs(struct repository *r, int force)\n {\n \tchar *infofile = mkpathdup(\"%s/info/packs\",\n-\t\t\t\t   repo_get_object_directory(the_repository));\n+\t\t\t\t   repo_get_object_directory(r));\n \tint ret;\n \n-\tinit_pack_info(infofile, force);\n-\tret = update_info_file(infofile, write_pack_info_file, force);\n+\tinit_pack_info(r, infofile, force);\n+\tret = update_info_file(r, infofile, write_pack_info_file, force);\n \tfree_pack_info();\n \tfree(infofile);\n \treturn ret;\n }\n \n /* public */\n-int update_server_info(int force)\n+int update_server_info(struct repository *r, int force)\n {\n \t/* We would add more dumb-server support files later,\n \t * including index of available pack files and their\n \t * intended audiences.\n \t */\n \tint errs = 0;\n+\tchar *path;\n \n-\terrs = errs | update_info_refs(force);\n-\terrs = errs | update_info_packs(force);\n+\terrs = errs | update_info_refs(r, force);\n+\terrs = errs | update_info_packs(r, force);\n \n \t/* remove leftover rev-cache file if there is any */\n-\tunlink_or_warn(git_path(\"info/rev-cache\"));\n+\tpath = repo_git_path(r, \"info/rev-cache\");\n+\tunlink_or_warn(path);\n+\tfree(path);\n \n \treturn errs;\n }\ndiff --git a/server-info.h b/server-info.h\nindex 13bbde2c55fafe7bf07eb38377cec2f109de3164..e634d1722bdfaaa506777b4df370d908b05005e9 100644\n--- a/server-info.h\n+++ b/server-info.h\n@@ -1,7 +1,9 @@\n #ifndef SERVER_INFO_H\n #define SERVER_INFO_H\n \n+struct repository;\n+\n /* Dumb servers support */\n-int update_server_info(int);\n+int update_server_info(struct repository *r, int force);\n \n #endif /* SERVER_INFO_H */\n\n-- \n2.48.0.rc0.184.g0fc57dec57.dirty\n\n"},{"id":"509196","messageId":"20241217-pks-use-the-repository-conversion-v1-7-0dba48bcc239@pks.im","threadId":"62650","inReplyTo":"20241217-pks-use-the-repository-conversion-v1-0-0dba48bcc239@pks.im","subject":"[PATCH 07/14] diagnose: stop using `the_repository`","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2024-12-17T06:43:54Z","receivedAt":"2024-12-17T06:44:21Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"Stop using `the_repository` in the \"diagnose\" subsystem by passing in a\nrepository when generating a diagnostics archive.\n\nAdjust callers accordingly by using `the_repository`. While there may be\nsome callers that have a repository available in their context, this\ntrivial conversion allows for easier verification and bubbles up the use\nof `the_repository` by one level.\n\nSigned-off-by: Patrick Steinhardt <ps@pks.im>\n---\n builtin/bugreport.c |  2 +-\n builtin/diagnose.c  |  4 +++-\n diagnose.c          | 15 ++++++++-------\n diagnose.h          |  5 ++++-\n 4 files changed, 16 insertions(+), 10 deletions(-)\n\ndiff --git a/builtin/bugreport.c b/builtin/bugreport.c\nindex 7c2df035c9cff06f649c2b35394ea3db3d39f469..0ac59cc8dc5824fbc155674e9107bb845d8e054c 100644\n--- a/builtin/bugreport.c\n+++ b/builtin/bugreport.c\n@@ -167,7 +167,7 @@ int cmd_bugreport(int argc,\n \t\tstrbuf_addftime(&zip_path, option_suffix, localtime_r(&now, &tm), 0, 0);\n \t\tstrbuf_addstr(&zip_path, \".zip\");\n \n-\t\tif (create_diagnostics_archive(&zip_path, diagnose))\n+\t\tif (create_diagnostics_archive(the_repository, &zip_path, diagnose))\n \t\t\tdie_errno(_(\"unable to create diagnostics archive %s\"), zip_path.buf);\n \n \t\tstrbuf_release(&zip_path);\ndiff --git a/builtin/diagnose.c b/builtin/diagnose.c\nindex 66a22d918e68a48a7c31ef3b75335f9a2bad7ab1..33c39bd5981f22d96b1b19e19ff83dec1c2873a6 100644\n--- a/builtin/diagnose.c\n+++ b/builtin/diagnose.c\n@@ -1,3 +1,5 @@\n+#define USE_THE_REPOSITORY_VARIABLE\n+\n #include \"builtin.h\"\n #include \"abspath.h\"\n #include \"gettext.h\"\n@@ -58,7 +60,7 @@ int cmd_diagnose(int argc,\n \t}\n \n \t/* Prepare diagnostics */\n-\tif (create_diagnostics_archive(&zip_path, mode))\n+\tif (create_diagnostics_archive(the_repository, &zip_path, mode))\n \t\tdie_errno(_(\"unable to create diagnostics archive %s\"),\n \t\t\t  zip_path.buf);\n \ndiff --git a/diagnose.c b/diagnose.c\nindex b11931df86c4ba84f7aec77cb7965083f5aa31fa..bd485effea22ce400c4300a1e085b45204a3b42e 100644\n--- a/diagnose.c\n+++ b/diagnose.c\n@@ -1,5 +1,3 @@\n-#define USE_THE_REPOSITORY_VARIABLE\n-\n #include \"git-compat-util.h\"\n #include \"diagnose.h\"\n #include \"compat/disk.h\"\n@@ -12,6 +10,7 @@\n #include \"object-store-ll.h\"\n #include \"packfile.h\"\n #include \"parse-options.h\"\n+#include \"repository.h\"\n #include \"write-or-die.h\"\n \n struct archive_dir {\n@@ -179,7 +178,9 @@ static int add_directory_to_archiver(struct strvec *archiver_args,\n \treturn res;\n }\n \n-int create_diagnostics_archive(struct strbuf *zip_path, enum diagnose_mode mode)\n+int create_diagnostics_archive(struct repository *r,\n+\t\t\t       struct strbuf *zip_path,\n+\t\t\t       enum diagnose_mode mode)\n {\n \tstruct strvec archiver_args = STRVEC_INIT;\n \tchar **argv_copy = NULL;\n@@ -218,7 +219,7 @@ int create_diagnostics_archive(struct strbuf *zip_path, enum diagnose_mode mode)\n \tstrbuf_addstr(&buf, \"Collecting diagnostic info\\n\\n\");\n \tget_version_info(&buf, 1);\n \n-\tstrbuf_addf(&buf, \"Repository root: %s\\n\", the_repository->worktree);\n+\tstrbuf_addf(&buf, \"Repository root: %s\\n\", r->worktree);\n \tget_disk_info(&buf);\n \twrite_or_die(stdout_fd, buf.buf, buf.len);\n \tstrvec_pushf(&archiver_args,\n@@ -227,7 +228,7 @@ int create_diagnostics_archive(struct strbuf *zip_path, enum diagnose_mode mode)\n \n \tstrbuf_reset(&buf);\n \tstrbuf_addstr(&buf, \"--add-virtual-file=packs-local.txt:\");\n-\tdir_file_stats(the_repository->objects->odb, &buf);\n+\tdir_file_stats(r->objects->odb, &buf);\n \tforeach_alt_odb(dir_file_stats, &buf);\n \tstrvec_push(&archiver_args, buf.buf);\n \n@@ -250,13 +251,13 @@ int create_diagnostics_archive(struct strbuf *zip_path, enum diagnose_mode mode)\n \t}\n \n \tstrvec_pushl(&archiver_args, \"--prefix=\",\n-\t\t     oid_to_hex(the_hash_algo->empty_tree), \"--\", NULL);\n+\t\t     oid_to_hex(r->hash_algo->empty_tree), \"--\", NULL);\n \n \t/* `write_archive()` modifies the `argv` passed to it. Let it. */\n \targv_copy = xmemdupz(archiver_args.v,\n \t\t\t     sizeof(char *) * archiver_args.nr);\n \tres = write_archive(archiver_args.nr, (const char **)argv_copy, NULL,\n-\t\t\t    the_repository, NULL, 0);\n+\t\t\t    r, NULL, 0);\n \tif (res) {\n \t\terror(_(\"failed to write archive\"));\n \t\tgoto diagnose_cleanup;\ndiff --git a/diagnose.h b/diagnose.h\nindex f525219ab0cf9b36249892c847e731b952b081af..f7b38f49f5271ad00bf17d14e7b2aab3e9e174d5 100644\n--- a/diagnose.h\n+++ b/diagnose.h\n@@ -4,6 +4,7 @@\n #include \"strbuf.h\"\n \n struct option;\n+struct repository;\n \n enum diagnose_mode {\n \tDIAGNOSE_NONE,\n@@ -13,6 +14,8 @@ enum diagnose_mode {\n \n int option_parse_diagnose(const struct option *opt, const char *arg, int unset);\n \n-int create_diagnostics_archive(struct strbuf *zip_path, enum diagnose_mode mode);\n+int create_diagnostics_archive(struct repository *r,\n+\t\t\t       struct strbuf *zip_path,\n+\t\t\t       enum diagnose_mode mode);\n \n #endif /* DIAGNOSE_H */\n\n-- \n2.48.0.rc0.184.g0fc57dec57.dirty\n\n"},{"id":"509197","messageId":"20241217-pks-use-the-repository-conversion-v1-8-0dba48bcc239@pks.im","threadId":"62650","inReplyTo":"20241217-pks-use-the-repository-conversion-v1-0-0dba48bcc239@pks.im","subject":"[PATCH 08/14] mailinfo: stop using `the_repository`","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2024-12-17T06:43:55Z","receivedAt":"2024-12-17T06:44:22Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"Stop using `the_repository` in the \"mailinfo\" subsystem by passing in\na repository when setting up the mailinfo structure.\n\nAdjust callers accordingly by using `the_repository`. While there may be\nsome callers that have a repository available in their context, this\ntrivial conversion allows for easier verification and bubbles up the use\nof `the_repository` by one level.\n\nSigned-off-by: Patrick Steinhardt <ps@pks.im>\n---\n builtin/am.c       | 2 +-\n builtin/mailinfo.c | 2 +-\n mailinfo.c         | 5 ++---\n mailinfo.h         | 4 +++-\n 4 files changed, 7 insertions(+), 6 deletions(-)\n\ndiff --git a/builtin/am.c b/builtin/am.c\nindex 27ccca8341feefcda5e1c4a850f14fce9e4deecb..e94d08e04b2387b6d45053e17c78c93038fa9531 100644\n--- a/builtin/am.c\n+++ b/builtin/am.c\n@@ -1211,7 +1211,7 @@ static int parse_mail(struct am_state *state, const char *mail)\n \tint ret = 0;\n \tstruct mailinfo mi;\n \n-\tsetup_mailinfo(&mi);\n+\tsetup_mailinfo(the_repository, &mi);\n \n \tif (state->utf8)\n \t\tmi.metainfo_charset = get_commit_output_encoding();\ndiff --git a/builtin/mailinfo.c b/builtin/mailinfo.c\nindex e17dec27b1df69c1e2a1020f245dd99c0973eaad..8de7ba7de1d6aadc610adec11e7394f7b1f538b9 100644\n--- a/builtin/mailinfo.c\n+++ b/builtin/mailinfo.c\n@@ -83,7 +83,7 @@ int cmd_mailinfo(int argc,\n \t\tOPT_END()\n \t};\n \n-\tsetup_mailinfo(&mi);\n+\tsetup_mailinfo(the_repository, &mi);\n \tmeta_charset.policy = CHARSET_DEFAULT;\n \n \targc = parse_options(argc, argv, prefix, options, mailinfo_usage, 0);\ndiff --git a/mailinfo.c b/mailinfo.c\nindex aa263bf490881daa915a03a681c00979f138d09b..7b001fa5dbd685cbe2b51c880e961e68461bef31 100644\n--- a/mailinfo.c\n+++ b/mailinfo.c\n@@ -1,4 +1,3 @@\n-#define USE_THE_REPOSITORY_VARIABLE\n #define DISABLE_SIGN_COMPARE_WARNINGS\n \n #include \"git-compat-util.h\"\n@@ -1269,7 +1268,7 @@ static int git_mailinfo_config(const char *var, const char *value,\n \treturn 0;\n }\n \n-void setup_mailinfo(struct mailinfo *mi)\n+void setup_mailinfo(struct repository *r, struct mailinfo *mi)\n {\n \tmemset(mi, 0, sizeof(*mi));\n \tstrbuf_init(&mi->name, 0);\n@@ -1281,7 +1280,7 @@ void setup_mailinfo(struct mailinfo *mi)\n \tmi->header_stage = 1;\n \tmi->use_inbody_headers = 1;\n \tmi->content_top = mi->content;\n-\tgit_config(git_mailinfo_config, mi);\n+\trepo_config(r, git_mailinfo_config, mi);\n }\n \n void clear_mailinfo(struct mailinfo *mi)\ndiff --git a/mailinfo.h b/mailinfo.h\nindex f2ffd0349e8007256f5b2118d41faf35a53edf0d..1f2066416578ace2fe6798e543959da43d718a5d 100644\n--- a/mailinfo.h\n+++ b/mailinfo.h\n@@ -5,6 +5,8 @@\n \n #define MAX_BOUNDARIES 5\n \n+struct repository;\n+\n enum quoted_cr_action {\n \tquoted_cr_unset = -1,\n \tquoted_cr_nowarn,\n@@ -49,7 +51,7 @@ struct mailinfo {\n };\n \n int mailinfo_parse_quoted_cr_action(const char *actionstr, int *action);\n-void setup_mailinfo(struct mailinfo *);\n+void setup_mailinfo(struct repository *r, struct mailinfo *);\n int mailinfo(struct mailinfo *, const char *msg, const char *patch);\n void clear_mailinfo(struct mailinfo *);\n \n\n-- \n2.48.0.rc0.184.g0fc57dec57.dirty\n\n"},{"id":"509198","messageId":"20241217-pks-use-the-repository-conversion-v1-9-0dba48bcc239@pks.im","threadId":"62650","inReplyTo":"20241217-pks-use-the-repository-conversion-v1-0-0dba48bcc239@pks.im","subject":"[PATCH 09/14] credential: stop using `the_repository`","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2024-12-17T06:43:56Z","receivedAt":"2024-12-17T06:44:23Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"Stop using `the_repository` in the \"credential\" subsystem by passing in\na repository when filling, approving or rejecting credentials.\n\nAdjust callers accordingly by using `the_repository`. While there may be\nsome callers that have a repository available in their context, this\ntrivial conversion allows for easier verification and bubbles up the use\nof `the_repository` by one level.\n\nSigned-off-by: Patrick Steinhardt <ps@pks.im>\n---\n builtin/credential.c |  6 +++---\n credential.c         | 34 +++++++++++++++++-----------------\n credential.h         | 11 +++++++----\n http.c               | 24 ++++++++++++------------\n imap-send.c          | 10 +++++-----\n remote-curl.c        |  4 ++--\n 6 files changed, 46 insertions(+), 43 deletions(-)\n\ndiff --git a/builtin/credential.c b/builtin/credential.c\nindex 14c8c6608b2fbd7091a11c14537d08783d5c281d..614b195b753ed8d0c2495ff9b26672250bf4edcb 100644\n--- a/builtin/credential.c\n+++ b/builtin/credential.c\n@@ -32,15 +32,15 @@ int cmd_credential(int argc,\n \t\tdie(\"unable to read credential from stdin\");\n \n \tif (!strcmp(op, \"fill\")) {\n-\t\tcredential_fill(&c, 0);\n+\t\tcredential_fill(the_repository, &c, 0);\n \t\tcredential_next_state(&c);\n \t\tcredential_write(&c, stdout, CREDENTIAL_OP_RESPONSE);\n \t} else if (!strcmp(op, \"approve\")) {\n \t\tcredential_set_all_capabilities(&c, CREDENTIAL_OP_HELPER);\n-\t\tcredential_approve(&c);\n+\t\tcredential_approve(the_repository, &c);\n \t} else if (!strcmp(op, \"reject\")) {\n \t\tcredential_set_all_capabilities(&c, CREDENTIAL_OP_HELPER);\n-\t\tcredential_reject(&c);\n+\t\tcredential_reject(the_repository, &c);\n \t} else {\n \t\tusage(usage_msg);\n \t}\ndiff --git a/credential.c b/credential.c\nindex a995031c5f5d842f8e82d5e44e4f7a3e51a9e815..b3f87b5b2f16c547d7889c7c60327cd75f3c27d9 100644\n--- a/credential.c\n+++ b/credential.c\n@@ -1,4 +1,3 @@\n-#define USE_THE_REPOSITORY_VARIABLE\n #define DISABLE_SIGN_COMPARE_WARNINGS\n \n #include \"git-compat-util.h\"\n@@ -166,7 +165,7 @@ static int match_partial_url(const char *url, void *cb)\n \treturn matches;\n }\n \n-static void credential_apply_config(struct credential *c)\n+static void credential_apply_config(struct repository *r, struct credential *c)\n {\n \tchar *normalized_url;\n \tstruct urlmatch_config config = URLMATCH_CONFIG_INIT;\n@@ -191,7 +190,7 @@ static void credential_apply_config(struct credential *c)\n \tcredential_format(c, &url);\n \tnormalized_url = url_normalize(url.buf, &config.url);\n \n-\tgit_config(urlmatch_config_entry, &config);\n+\trepo_config(r, urlmatch_config_entry, &config);\n \tstring_list_clear(&config.vars, 1);\n \tfree(normalized_url);\n \turlmatch_config_release(&config);\n@@ -254,34 +253,34 @@ static char *credential_ask_one(const char *what, struct credential *c,\n \treturn xstrdup(r);\n }\n \n-static int credential_getpass(struct credential *c)\n+static int credential_getpass(struct repository *r, struct credential *c)\n {\n \tint interactive;\n \tchar *value;\n-\tif (!git_config_get_maybe_bool(\"credential.interactive\", &interactive) &&\n+\tif (!repo_config_get_maybe_bool(r, \"credential.interactive\", &interactive) &&\n \t    !interactive) {\n-\t\ttrace2_data_intmax(\"credential\", the_repository,\n+\t\ttrace2_data_intmax(\"credential\", r,\n \t\t\t\t   \"interactive/skipped\", 1);\n \t\treturn -1;\n \t}\n-\tif (!git_config_get_string(\"credential.interactive\", &value)) {\n+\tif (!repo_config_get_string(r, \"credential.interactive\", &value)) {\n \t\tint same = !strcmp(value, \"never\");\n \t\tfree(value);\n \t\tif (same) {\n-\t\t\ttrace2_data_intmax(\"credential\", the_repository,\n+\t\t\ttrace2_data_intmax(\"credential\", r,\n \t\t\t\t\t   \"interactive/skipped\", 1);\n \t\t\treturn -1;\n \t\t}\n \t}\n \n-\ttrace2_region_enter(\"credential\", \"interactive\", the_repository);\n+\ttrace2_region_enter(\"credential\", \"interactive\", r);\n \tif (!c->username)\n \t\tc->username = credential_ask_one(\"Username\", c,\n \t\t\t\t\t\t PROMPT_ASKPASS|PROMPT_ECHO);\n \tif (!c->password)\n \t\tc->password = credential_ask_one(\"Password\", c,\n \t\t\t\t\t\t PROMPT_ASKPASS);\n-\ttrace2_region_leave(\"credential\", \"interactive\", the_repository);\n+\ttrace2_region_leave(\"credential\", \"interactive\", r);\n \n \treturn 0;\n }\n@@ -489,7 +488,8 @@ static int credential_do(struct credential *c, const char *helper,\n \treturn r;\n }\n \n-void credential_fill(struct credential *c, int all_capabilities)\n+void credential_fill(struct repository *r,\n+\t\t     struct credential *c, int all_capabilities)\n {\n \tint i;\n \n@@ -499,7 +499,7 @@ void credential_fill(struct credential *c, int all_capabilities)\n \tcredential_next_state(c);\n \tc->multistage = 0;\n \n-\tcredential_apply_config(c);\n+\tcredential_apply_config(r, c);\n \tif (all_capabilities)\n \t\tcredential_set_all_capabilities(c, CREDENTIAL_OP_INITIAL);\n \n@@ -526,12 +526,12 @@ void credential_fill(struct credential *c, int all_capabilities)\n \t\t\t    c->helpers.items[i].string);\n \t}\n \n-\tif (credential_getpass(c) ||\n+\tif (credential_getpass(r, c) ||\n \t    (!c->username && !c->password && !c->credential))\n \t\tdie(\"unable to get password from user\");\n }\n \n-void credential_approve(struct credential *c)\n+void credential_approve(struct repository *r, struct credential *c)\n {\n \tint i;\n \n@@ -542,20 +542,20 @@ void credential_approve(struct credential *c)\n \n \tcredential_next_state(c);\n \n-\tcredential_apply_config(c);\n+\tcredential_apply_config(r, c);\n \n \tfor (i = 0; i < c->helpers.nr; i++)\n \t\tcredential_do(c, c->helpers.items[i].string, \"store\");\n \tc->approved = 1;\n }\n \n-void credential_reject(struct credential *c)\n+void credential_reject(struct repository *r, struct credential *c)\n {\n \tint i;\n \n \tcredential_next_state(c);\n \n-\tcredential_apply_config(c);\n+\tcredential_apply_config(r, c);\n \n \tfor (i = 0; i < c->helpers.nr; i++)\n \t\tcredential_do(c, c->helpers.items[i].string, \"erase\");\ndiff --git a/credential.h b/credential.h\nindex 5f9e6ff2efef55fff8452fc6e50997a759a27118..1e6b0dc5b0f4654435c876b396ca0b6d833567ab 100644\n--- a/credential.h\n+++ b/credential.h\n@@ -4,6 +4,8 @@\n #include \"string-list.h\"\n #include \"strvec.h\"\n \n+struct repository;\n+\n /**\n  * The credentials API provides an abstracted way of gathering\n  * authentication credentials from the user.\n@@ -65,7 +67,7 @@\n  * // Fill in the username and password fields by contacting\n  * // helpers and/or asking the user. The function will die if it\n  * // fails.\n- * credential_fill(&c);\n+ * credential_fill(repo, &c);\n  *\n  * // Otherwise, we have a username and password. Try to use it.\n  *\n@@ -218,7 +220,8 @@ void credential_clear(struct credential *);\n  * If all_capabilities is set, this is an internal user that is prepared\n  * to deal with all known capabilities, and we should advertise that fact.\n  */\n-void credential_fill(struct credential *, int all_capabilities);\n+void credential_fill(struct repository *, struct credential *,\n+\t\t     int all_capabilities);\n \n /**\n  * Inform the credential subsystem that the provided credentials\n@@ -227,7 +230,7 @@ void credential_fill(struct credential *, int all_capabilities);\n  * that they may store the result to be used again.  Any errors\n  * from helpers are ignored.\n  */\n-void credential_approve(struct credential *);\n+void credential_approve(struct repository *, struct credential *);\n \n /**\n  * Inform the credential subsystem that the provided credentials\n@@ -239,7 +242,7 @@ void credential_approve(struct credential *);\n  * for another call to `credential_fill`). Any errors from helpers\n  * are ignored.\n  */\n-void credential_reject(struct credential *);\n+void credential_reject(struct repository *, struct credential *);\n \n /**\n  * Enable all of the supported credential flags in this credential.\ndiff --git a/http.c b/http.c\nindex c8fc15aa118d3b1c0e8db1c804948c92a7314b5c..f08b2ae47465332714494cd5ea054880d42702c1 100644\n--- a/http.c\n+++ b/http.c\n@@ -609,7 +609,7 @@ static void init_curl_http_auth(CURL *result)\n \t\t}\n \t}\n \n-\tcredential_fill(&http_auth, 1);\n+\tcredential_fill(the_repository, &http_auth, 1);\n \n \tif (http_auth.password) {\n \t\tif (always_auth_proactively()) {\n@@ -652,7 +652,7 @@ static void init_curl_proxy_auth(CURL *result)\n {\n \tif (proxy_auth.username) {\n \t\tif (!proxy_auth.password && !proxy_auth.credential)\n-\t\t\tcredential_fill(&proxy_auth, 1);\n+\t\t\tcredential_fill(the_repository, &proxy_auth, 1);\n \t\tset_proxyauth_name_password(result);\n \t}\n \n@@ -686,7 +686,7 @@ static int has_cert_password(void)\n \t\tcert_auth.host = xstrdup(\"\");\n \t\tcert_auth.username = xstrdup(\"\");\n \t\tcert_auth.path = xstrdup(ssl_cert);\n-\t\tcredential_fill(&cert_auth, 0);\n+\t\tcredential_fill(the_repository, &cert_auth, 0);\n \t}\n \treturn 1;\n }\n@@ -700,7 +700,7 @@ static int has_proxy_cert_password(void)\n \t\tproxy_cert_auth.host = xstrdup(\"\");\n \t\tproxy_cert_auth.username = xstrdup(\"\");\n \t\tproxy_cert_auth.path = xstrdup(http_proxy_ssl_cert);\n-\t\tcredential_fill(&proxy_cert_auth, 0);\n+\t\tcredential_fill(the_repository, &proxy_cert_auth, 0);\n \t}\n \treturn 1;\n }\n@@ -1784,9 +1784,9 @@ static int handle_curl_result(struct slot_results *results)\n \t\t\t      curl_errorstr, sizeof(curl_errorstr));\n \n \tif (results->curl_result == CURLE_OK) {\n-\t\tcredential_approve(&http_auth);\n-\t\tcredential_approve(&proxy_auth);\n-\t\tcredential_approve(&cert_auth);\n+\t\tcredential_approve(the_repository, &http_auth);\n+\t\tcredential_approve(the_repository, &proxy_auth);\n+\t\tcredential_approve(the_repository, &cert_auth);\n \t\treturn HTTP_OK;\n \t} else if (results->curl_result == CURLE_SSL_CERTPROBLEM) {\n \t\t/*\n@@ -1795,7 +1795,7 @@ static int handle_curl_result(struct slot_results *results)\n \t\t * with the certificate.  So we reject the credential to\n \t\t * avoid caching or saving a bad password.\n \t\t */\n-\t\tcredential_reject(&cert_auth);\n+\t\tcredential_reject(the_repository, &cert_auth);\n \t\treturn HTTP_NOAUTH;\n \t} else if (results->curl_result == CURLE_SSL_PINNEDPUBKEYNOTMATCH) {\n \t\treturn HTTP_NOMATCHPUBLICKEY;\n@@ -1808,7 +1808,7 @@ static int handle_curl_result(struct slot_results *results)\n \t\t\t\tcredential_clear_secrets(&http_auth);\n \t\t\t\treturn HTTP_REAUTH;\n \t\t\t}\n-\t\t\tcredential_reject(&http_auth);\n+\t\t\tcredential_reject(the_repository, &http_auth);\n \t\t\tif (always_auth_proactively())\n \t\t\t\thttp_proactive_auth = PROACTIVE_AUTH_NONE;\n \t\t\treturn HTTP_NOAUTH;\n@@ -1822,7 +1822,7 @@ static int handle_curl_result(struct slot_results *results)\n \t\t}\n \t} else {\n \t\tif (results->http_connectcode == 407)\n-\t\t\tcredential_reject(&proxy_auth);\n+\t\t\tcredential_reject(the_repository, &proxy_auth);\n \t\tif (!curl_errorstr[0])\n \t\t\tstrlcpy(curl_errorstr,\n \t\t\t\tcurl_easy_strerror(results->curl_result),\n@@ -2210,7 +2210,7 @@ static int http_request_reauth(const char *url,\n \tint ret;\n \n \tif (always_auth_proactively())\n-\t\tcredential_fill(&http_auth, 1);\n+\t\tcredential_fill(the_repository, &http_auth, 1);\n \n \tret = http_request(url, result, target, options);\n \n@@ -2251,7 +2251,7 @@ static int http_request_reauth(const char *url,\n \t\t\tBUG(\"Unknown http_request target\");\n \t\t}\n \n-\t\tcredential_fill(&http_auth, 1);\n+\t\tcredential_fill(the_repository, &http_auth, 1);\n \n \t\tret = http_request(url, result, target, options);\n \t}\ndiff --git a/imap-send.c b/imap-send.c\nindex 68ab1aea837c3549a56675407edae19e12c6bfdf..6c8f84e836bb4018d93520b6b5f96687c975d33a 100644\n--- a/imap-send.c\n+++ b/imap-send.c\n@@ -922,7 +922,7 @@ static void server_fill_credential(struct imap_server_conf *srvc, struct credent\n \tcred->username = xstrdup_or_null(srvc->user);\n \tcred->password = xstrdup_or_null(srvc->pass);\n \n-\tcredential_fill(cred, 1);\n+\tcredential_fill(the_repository, cred, 1);\n \n \tif (!srvc->user)\n \t\tsrvc->user = xstrdup(cred->username);\n@@ -1123,7 +1123,7 @@ static struct imap_store *imap_open_store(struct imap_server_conf *srvc, const c\n \t} /* !preauth */\n \n \tif (cred.username)\n-\t\tcredential_approve(&cred);\n+\t\tcredential_approve(the_repository, &cred);\n \tcredential_clear(&cred);\n \n \t/* check the target mailbox exists */\n@@ -1150,7 +1150,7 @@ static struct imap_store *imap_open_store(struct imap_server_conf *srvc, const c\n \n bail:\n \tif (cred.username)\n-\t\tcredential_reject(&cred);\n+\t\tcredential_reject(the_repository, &cred);\n \tcredential_clear(&cred);\n \n  out:\n@@ -1492,9 +1492,9 @@ static int curl_append_msgs_to_imap(struct imap_server_conf *server,\n \n \tif (cred.username) {\n \t\tif (res == CURLE_OK)\n-\t\t\tcredential_approve(&cred);\n+\t\t\tcredential_approve(the_repository, &cred);\n \t\telse if (res == CURLE_LOGIN_DENIED)\n-\t\t\tcredential_reject(&cred);\n+\t\t\tcredential_reject(the_repository, &cred);\n \t}\n \n \tcredential_clear(&cred);\ndiff --git a/remote-curl.c b/remote-curl.c\nindex a24e3a8b9abcc9f01d862a18dbd237fdad8d3d3a..1273507a96cae97eeaac9a95a47618e5e4f72850 100644\n--- a/remote-curl.c\n+++ b/remote-curl.c\n@@ -942,7 +942,7 @@ static int post_rpc(struct rpc_state *rpc, int stateless_connect, int flush_rece\n \t\tdo {\n \t\t\terr = probe_rpc(rpc, &results);\n \t\t\tif (err == HTTP_REAUTH)\n-\t\t\t\tcredential_fill(&http_auth, 0);\n+\t\t\t\tcredential_fill(the_repository, &http_auth, 0);\n \t\t} while (err == HTTP_REAUTH);\n \t\tif (err != HTTP_OK)\n \t\t\treturn -1;\n@@ -1064,7 +1064,7 @@ static int post_rpc(struct rpc_state *rpc, int stateless_connect, int flush_rece\n \trpc->any_written = 0;\n \terr = run_slot(slot, NULL);\n \tif (err == HTTP_REAUTH && !large_request) {\n-\t\tcredential_fill(&http_auth, 0);\n+\t\tcredential_fill(the_repository, &http_auth, 0);\n \t\tcurl_slist_free_all(headers);\n \t\tgoto retry;\n \t}\n\n-- \n2.48.0.rc0.184.g0fc57dec57.dirty\n\n"},{"id":"509199","messageId":"20241217-pks-use-the-repository-conversion-v1-10-0dba48bcc239@pks.im","threadId":"62650","inReplyTo":"20241217-pks-use-the-repository-conversion-v1-0-0dba48bcc239@pks.im","subject":"[PATCH 10/14] resolve-undo: stop using `the_repository`","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2024-12-17T06:43:57Z","receivedAt":"2024-12-17T06:44:24Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"Stop using `the_repository` in the \"resolve-undo\" subsystem by passing\nin the hash algorithm when reading or writing resolve-undo information.\n\nWhile we could trivially update the caller to pass in the hash algorithm\nused by the index itself, we instead pass in `the_hash_algo`. This is\nmostly done to stay consistent with the rest of the code in that file,\nwhich isn't prepared to handle arbitrary repositories, either.\n\nSigned-off-by: Patrick Steinhardt <ps@pks.im>\n---\n read-cache.c   |  4 ++--\n resolve-undo.c | 14 +++++++-------\n resolve-undo.h |  6 ++++--\n 3 files changed, 13 insertions(+), 11 deletions(-)\n\ndiff --git a/read-cache.c b/read-cache.c\nindex 38c36caa7fef4d44da74c29e059839d88426df15..d54be2c17268728caf3e1e3ef94a5832d2cbfa60 100644\n--- a/read-cache.c\n+++ b/read-cache.c\n@@ -1754,7 +1754,7 @@ static int read_index_extension(struct index_state *istate,\n \t\tistate->cache_tree = cache_tree_read(data, sz);\n \t\tbreak;\n \tcase CACHE_EXT_RESOLVE_UNDO:\n-\t\tistate->resolve_undo = resolve_undo_read(data, sz);\n+\t\tistate->resolve_undo = resolve_undo_read(data, sz, the_hash_algo);\n \t\tbreak;\n \tcase CACHE_EXT_LINK:\n \t\tif (read_link_extension(istate, data, sz))\n@@ -3033,7 +3033,7 @@ static int do_write_index(struct index_state *istate, struct tempfile *tempfile,\n \t    istate->resolve_undo) {\n \t\tstrbuf_reset(&sb);\n \n-\t\tresolve_undo_write(&sb, istate->resolve_undo);\n+\t\tresolve_undo_write(&sb, istate->resolve_undo, the_hash_algo);\n \t\terr = write_index_ext_header(f, eoie_c, CACHE_EXT_RESOLVE_UNDO,\n \t\t\t\t\t     sb.len) < 0;\n \t\thashwrite(f, sb.buf, sb.len);\ndiff --git a/resolve-undo.c b/resolve-undo.c\nindex b5a9dfb4acc51173b1d9b7b1b044a1fc611d3f74..52c45e5a49463656a48fc036749ee2749debaaac 100644\n--- a/resolve-undo.c\n+++ b/resolve-undo.c\n@@ -1,4 +1,3 @@\n-#define USE_THE_REPOSITORY_VARIABLE\n #define DISABLE_SIGN_COMPARE_WARNINGS\n \n #include \"git-compat-util.h\"\n@@ -34,7 +33,8 @@ void record_resolve_undo(struct index_state *istate, struct cache_entry *ce)\n \tui->mode[stage - 1] = ce->ce_mode;\n }\n \n-void resolve_undo_write(struct strbuf *sb, struct string_list *resolve_undo)\n+void resolve_undo_write(struct strbuf *sb, struct string_list *resolve_undo,\n+\t\t\tconst struct git_hash_algo *algop)\n {\n \tstruct string_list_item *item;\n \tfor_each_string_list_item(item, resolve_undo) {\n@@ -50,18 +50,19 @@ void resolve_undo_write(struct strbuf *sb, struct string_list *resolve_undo)\n \t\tfor (i = 0; i < 3; i++) {\n \t\t\tif (!ui->mode[i])\n \t\t\t\tcontinue;\n-\t\t\tstrbuf_add(sb, ui->oid[i].hash, the_hash_algo->rawsz);\n+\t\t\tstrbuf_add(sb, ui->oid[i].hash, algop->rawsz);\n \t\t}\n \t}\n }\n \n-struct string_list *resolve_undo_read(const char *data, unsigned long size)\n+struct string_list *resolve_undo_read(const char *data, unsigned long size,\n+\t\t\t\t      const struct git_hash_algo *algop)\n {\n \tstruct string_list *resolve_undo;\n \tsize_t len;\n \tchar *endptr;\n \tint i;\n-\tconst unsigned rawsz = the_hash_algo->rawsz;\n+\tconst unsigned rawsz = algop->rawsz;\n \n \tCALLOC_ARRAY(resolve_undo, 1);\n \tresolve_undo->strdup_strings = 1;\n@@ -96,8 +97,7 @@ struct string_list *resolve_undo_read(const char *data, unsigned long size)\n \t\t\t\tcontinue;\n \t\t\tif (size < rawsz)\n \t\t\t\tgoto error;\n-\t\t\toidread(&ui->oid[i], (const unsigned char *)data,\n-\t\t\t\tthe_repository->hash_algo);\n+\t\t\toidread(&ui->oid[i], (const unsigned char *)data, algop);\n \t\t\tsize -= rawsz;\n \t\t\tdata += rawsz;\n \t\t}\ndiff --git a/resolve-undo.h b/resolve-undo.h\nindex 89a32272620f2b9e93102039204c72c7886306b3..7ed11a1c59b8192df9bdc9bdad560e06d9f0b9e5 100644\n--- a/resolve-undo.h\n+++ b/resolve-undo.h\n@@ -14,8 +14,10 @@ struct resolve_undo_info {\n };\n \n void record_resolve_undo(struct index_state *, struct cache_entry *);\n-void resolve_undo_write(struct strbuf *, struct string_list *);\n-struct string_list *resolve_undo_read(const char *, unsigned long);\n+void resolve_undo_write(struct strbuf *, struct string_list *,\n+\t\t\tconst struct git_hash_algo *algop);\n+struct string_list *resolve_undo_read(const char *, unsigned long,\n+\t\t\t\t      const struct git_hash_algo *algop);\n void resolve_undo_clear_index(struct index_state *);\n int unmerge_index_entry(struct index_state *, const char *, struct resolve_undo_info *, unsigned);\n void unmerge_index(struct index_state *, const struct pathspec *, unsigned);\n\n-- \n2.48.0.rc0.184.g0fc57dec57.dirty\n\n"},{"id":"509201","messageId":"20241217-pks-use-the-repository-conversion-v1-11-0dba48bcc239@pks.im","threadId":"62650","inReplyTo":"20241217-pks-use-the-repository-conversion-v1-0-0dba48bcc239@pks.im","subject":"[PATCH 11/14] tmp-objdir: stop using `the_repository`","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2024-12-17T06:43:58Z","receivedAt":"2024-12-17T06:44:24Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"Stop using `the_repository` in the \"tmp-objdir\" subsystem by passing\nin the repostiroy when creating a new temporary object directory.\n\nWhile we could trivially update the caller to pass in the hash algorithm\nused by the index itself, we instead pass in `the_hash_algo`. This is\nmostly done to stay consistent with the rest of the code in that file,\nwhich isn't prepared to handle arbitrary repositories, either.\n\nSigned-off-by: Patrick Steinhardt <ps@pks.im>\n---\n builtin/receive-pack.c |  2 +-\n bulk-checkin.c         |  2 +-\n log-tree.c             |  2 +-\n tmp-objdir.c           | 15 ++++++++-------\n tmp-objdir.h           |  5 +++--\n 5 files changed, 14 insertions(+), 12 deletions(-)\n\ndiff --git a/builtin/receive-pack.c b/builtin/receive-pack.c\nindex 191b5eeb34e6791776f93a3a9509efa887e4e087..56347a79633505efe8dc05acf1583b4c9995eefe 100644\n--- a/builtin/receive-pack.c\n+++ b/builtin/receive-pack.c\n@@ -2239,7 +2239,7 @@ static const char *unpack(int err_fd, struct shallow_info *si)\n \t\tstrvec_push(&child.args, alt_shallow_file);\n \t}\n \n-\ttmp_objdir = tmp_objdir_create(\"incoming\");\n+\ttmp_objdir = tmp_objdir_create(the_repository, \"incoming\");\n \tif (!tmp_objdir) {\n \t\tif (err_fd > 0)\n \t\t\tclose(err_fd);\ndiff --git a/bulk-checkin.c b/bulk-checkin.c\nindex 4a70a70a951cfd1a488339a33bf3a76b5152a344..f7b15e3999f2c7e3fdb0d7bde01975ae4449bda3 100644\n--- a/bulk-checkin.c\n+++ b/bulk-checkin.c\n@@ -333,7 +333,7 @@ void prepare_loose_object_bulk_checkin(void)\n \tif (!odb_transaction_nesting || bulk_fsync_objdir)\n \t\treturn;\n \n-\tbulk_fsync_objdir = tmp_objdir_create(\"bulk-fsync\");\n+\tbulk_fsync_objdir = tmp_objdir_create(the_repository, \"bulk-fsync\");\n \tif (bulk_fsync_objdir)\n \t\ttmp_objdir_replace_primary_odb(bulk_fsync_objdir, 0);\n }\ndiff --git a/log-tree.c b/log-tree.c\nindex d08eb672a933900558b305b31860f6753a470bf0..8b184d6776344bbc2ba4c00a9d50b44db17f2ede 100644\n--- a/log-tree.c\n+++ b/log-tree.c\n@@ -1042,7 +1042,7 @@ static int do_remerge_diff(struct rev_info *opt,\n \t * into the alternative object store list as the primary.\n \t */\n \tif (opt->remerge_diff && !opt->remerge_objdir) {\n-\t\topt->remerge_objdir = tmp_objdir_create(\"remerge-diff\");\n+\t\topt->remerge_objdir = tmp_objdir_create(the_repository, \"remerge-diff\");\n \t\tif (!opt->remerge_objdir)\n \t\t\treturn error(_(\"unable to create temporary object directory\"));\n \t\ttmp_objdir_replace_primary_odb(opt->remerge_objdir, 1);\ndiff --git a/tmp-objdir.c b/tmp-objdir.c\nindex 659fcdcc2954ed392f9e241667ea6a7d2c79b828..0ea078a5c5f4eb1ff465aa64ae962a0ccd44fb8b 100644\n--- a/tmp-objdir.c\n+++ b/tmp-objdir.c\n@@ -1,5 +1,3 @@\n-#define USE_THE_REPOSITORY_VARIABLE\n-\n #include \"git-compat-util.h\"\n #include \"tmp-objdir.h\"\n #include \"abspath.h\"\n@@ -16,6 +14,7 @@\n #include \"repository.h\"\n \n struct tmp_objdir {\n+\tstruct repository *repo;\n \tstruct strbuf path;\n \tstruct strvec env;\n \tstruct object_directory *prev_odb;\n@@ -116,7 +115,8 @@ static int setup_tmp_objdir(const char *root)\n \treturn ret;\n }\n \n-struct tmp_objdir *tmp_objdir_create(const char *prefix)\n+struct tmp_objdir *tmp_objdir_create(struct repository *r,\n+\t\t\t\t     const char *prefix)\n {\n \tstatic int installed_handlers;\n \tstruct tmp_objdir *t;\n@@ -125,6 +125,7 @@ struct tmp_objdir *tmp_objdir_create(const char *prefix)\n \t\tBUG(\"only one tmp_objdir can be used at a time\");\n \n \tt = xcalloc(1, sizeof(*t));\n+\tt->repo = r;\n \tstrbuf_init(&t->path, 0);\n \tstrvec_init(&t->env);\n \n@@ -134,7 +135,7 @@ struct tmp_objdir *tmp_objdir_create(const char *prefix)\n \t * them.\n \t */\n \tstrbuf_addf(&t->path, \"%s/tmp_objdir-%s-XXXXXX\",\n-\t\t    repo_get_object_directory(the_repository), prefix);\n+\t\t    repo_get_object_directory(r), prefix);\n \n \tif (!mkdtemp(t->path.buf)) {\n \t\t/* free, not destroy, as we never touched the filesystem */\n@@ -154,7 +155,7 @@ struct tmp_objdir *tmp_objdir_create(const char *prefix)\n \t}\n \n \tenv_append(&t->env, ALTERNATE_DB_ENVIRONMENT,\n-\t\t   absolute_path(repo_get_object_directory(the_repository)));\n+\t\t   absolute_path(repo_get_object_directory(r)));\n \tenv_replace(&t->env, DB_ENVIRONMENT, absolute_path(t->path.buf));\n \tenv_replace(&t->env, GIT_QUARANTINE_ENVIRONMENT,\n \t\t    absolute_path(t->path.buf));\n@@ -273,14 +274,14 @@ int tmp_objdir_migrate(struct tmp_objdir *t)\n \t\treturn 0;\n \n \tif (t->prev_odb) {\n-\t\tif (the_repository->objects->odb->will_destroy)\n+\t\tif (t->repo->objects->odb->will_destroy)\n \t\t\tBUG(\"migrating an ODB that was marked for destruction\");\n \t\trestore_primary_odb(t->prev_odb, t->path.buf);\n \t\tt->prev_odb = NULL;\n \t}\n \n \tstrbuf_addbuf(&src, &t->path);\n-\tstrbuf_addstr(&dst, repo_get_object_directory(the_repository));\n+\tstrbuf_addstr(&dst, repo_get_object_directory(t->repo));\n \n \tret = migrate_paths(&src, &dst, 0);\n \ndiff --git a/tmp-objdir.h b/tmp-objdir.h\nindex 237d96b66050c82340af3c18b531bd5c877c15ab..fceda14979648f50bb28b6c527889b12d334b098 100644\n--- a/tmp-objdir.h\n+++ b/tmp-objdir.h\n@@ -11,7 +11,7 @@\n  * Example:\n  *\n  *\tstruct child_process child = CHILD_PROCESS_INIT;\n- *\tstruct tmp_objdir *t = tmp_objdir_create(\"incoming\");\n+ *\tstruct tmp_objdir *t = tmp_objdir_create(repo, \"incoming\");\n  *\tstrvec_push(&child.args, cmd);\n  *\tstrvec_pushv(&child.env, tmp_objdir_env(t));\n  *\tif (!run_command(&child)) && !tmp_objdir_migrate(t))\n@@ -21,13 +21,14 @@\n  *\n  */\n \n+struct repository;\n struct tmp_objdir;\n \n /*\n  * Create a new temporary object directory with the specified prefix;\n  * returns NULL on failure.\n  */\n-struct tmp_objdir *tmp_objdir_create(const char *prefix);\n+struct tmp_objdir *tmp_objdir_create(struct repository *r, const char *prefix);\n \n /*\n  * Return a list of environment strings, suitable for use with\n\n-- \n2.48.0.rc0.184.g0fc57dec57.dirty\n\n"},{"id":"509200","messageId":"20241217-pks-use-the-repository-conversion-v1-12-0dba48bcc239@pks.im","threadId":"62650","inReplyTo":"20241217-pks-use-the-repository-conversion-v1-0-0dba48bcc239@pks.im","subject":"[PATCH 12/14] add-interactive: stop using `the_repository`","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2024-12-17T06:43:59Z","receivedAt":"2024-12-17T06:44:25Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"Stop using `the_repository` in the \"add-interactive\" subsystem by\nreusing the repository we already have available via parameters or in\nthe `add_i_state` structure.\n\nSigned-off-by: Patrick Steinhardt <ps@pks.im>\n---\n add-interactive.c | 19 +++++++++----------\n 1 file changed, 9 insertions(+), 10 deletions(-)\n\ndiff --git a/add-interactive.c b/add-interactive.c\nindex d0f8c10e6fd460c67c564a1040d12780dfafbc69..97ff35b6f12a32e4154fbe4d195d444c0f71c347 100644\n--- a/add-interactive.c\n+++ b/add-interactive.c\n@@ -1,4 +1,3 @@\n-#define USE_THE_REPOSITORY_VARIABLE\n #define DISABLE_SIGN_COMPARE_WARNINGS\n \n #include \"git-compat-util.h\"\n@@ -72,14 +71,14 @@ void init_add_i_state(struct add_i_state *s, struct repository *r)\n \t\ts->use_color ? GIT_COLOR_RESET : \"\", COLOR_MAXLEN);\n \n \tFREE_AND_NULL(s->interactive_diff_filter);\n-\tgit_config_get_string(\"interactive.difffilter\",\n-\t\t\t      &s->interactive_diff_filter);\n+\trepo_config_get_string(r, \"interactive.difffilter\",\n+\t\t\t       &s->interactive_diff_filter);\n \n \tFREE_AND_NULL(s->interactive_diff_algorithm);\n-\tgit_config_get_string(\"diff.algorithm\",\n-\t\t\t      &s->interactive_diff_algorithm);\n+\trepo_config_get_string(r, \"diff.algorithm\",\n+\t\t\t       &s->interactive_diff_algorithm);\n \n-\tgit_config_get_bool(\"interactive.singlekey\", &s->use_single_key);\n+\trepo_config_get_bool(r, \"interactive.singlekey\", &s->use_single_key);\n \tif (s->use_single_key)\n \t\tsetbuf(stdin, NULL);\n }\n@@ -535,7 +534,7 @@ static int get_modified_files(struct repository *r,\n \t\t\t      size_t *binary_count)\n {\n \tstruct object_id head_oid;\n-\tint is_initial = !refs_resolve_ref_unsafe(get_main_ref_store(the_repository),\n+\tint is_initial = !refs_resolve_ref_unsafe(get_main_ref_store(r),\n \t\t\t\t\t\t  \"HEAD\", RESOLVE_REF_READING,\n \t\t\t\t\t\t  &head_oid, NULL);\n \tstruct collection_status s = { 0 };\n@@ -560,7 +559,7 @@ static int get_modified_files(struct repository *r,\n \t\ts.skip_unseen = filter && i;\n \n \t\topt.def = is_initial ?\n-\t\t\tempty_tree_oid_hex(the_repository->hash_algo) : oid_to_hex(&head_oid);\n+\t\t\tempty_tree_oid_hex(r->hash_algo) : oid_to_hex(&head_oid);\n \n \t\trepo_init_revisions(r, &rev, NULL);\n \t\tsetup_revisions(0, NULL, &rev, &opt);\n@@ -765,7 +764,7 @@ static int run_revert(struct add_i_state *s, const struct pathspec *ps,\n \tsize_t count, i, j;\n \n \tstruct object_id oid;\n-\tint is_initial = !refs_resolve_ref_unsafe(get_main_ref_store(the_repository),\n+\tint is_initial = !refs_resolve_ref_unsafe(get_main_ref_store(s->r),\n \t\t\t\t\t\t  \"HEAD\", RESOLVE_REF_READING,\n \t\t\t\t\t\t  &oid,\n \t\t\t\t\t\t  NULL);\n@@ -996,7 +995,7 @@ static int run_diff(struct add_i_state *s, const struct pathspec *ps,\n \tssize_t count, i;\n \n \tstruct object_id oid;\n-\tint is_initial = !refs_resolve_ref_unsafe(get_main_ref_store(the_repository),\n+\tint is_initial = !refs_resolve_ref_unsafe(get_main_ref_store(s->r),\n \t\t\t\t\t\t  \"HEAD\", RESOLVE_REF_READING,\n \t\t\t\t\t\t  &oid,\n \t\t\t\t\t\t  NULL);\n\n-- \n2.48.0.rc0.184.g0fc57dec57.dirty\n\n"},{"id":"509202","messageId":"20241217-pks-use-the-repository-conversion-v1-13-0dba48bcc239@pks.im","threadId":"62650","inReplyTo":"20241217-pks-use-the-repository-conversion-v1-0-0dba48bcc239@pks.im","subject":"[PATCH 13/14] graph: stop using `the_repository`","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2024-12-17T06:44:00Z","receivedAt":"2024-12-17T06:44:26Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"Stop using `the_repository` in the \"graph\" subsystem by reusing the\nrepository we already have available via `struct rev_info`.\n\nSigned-off-by: Patrick Steinhardt <ps@pks.im>\n---\n graph.c | 3 +--\n 1 file changed, 1 insertion(+), 2 deletions(-)\n\ndiff --git a/graph.c b/graph.c\nindex 52205f75c37cf3467ac5e9de1574425d6c203359..26f6fbf000aef5ef1fa46aeed5851a8fbb2d8fe3 100644\n--- a/graph.c\n+++ b/graph.c\n@@ -1,4 +1,3 @@\n-#define USE_THE_REPOSITORY_VARIABLE\n #define DISABLE_SIGN_COMPARE_WARNINGS\n \n #include \"git-compat-util.h\"\n@@ -351,7 +350,7 @@ struct git_graph *graph_init(struct rev_info *opt)\n \n \tif (!column_colors) {\n \t\tchar *string;\n-\t\tif (git_config_get_string(\"log.graphcolors\", &string)) {\n+\t\tif (repo_config_get_string(opt->repo, \"log.graphcolors\", &string)) {\n \t\t\t/* not configured -- use default */\n \t\t\tgraph_set_column_colors(column_colors_ansi,\n \t\t\t\t\t\tcolumn_colors_ansi_max);\n\n-- \n2.48.0.rc0.184.g0fc57dec57.dirty\n\n"},{"id":"509203","messageId":"20241217-pks-use-the-repository-conversion-v1-14-0dba48bcc239@pks.im","threadId":"62650","inReplyTo":"20241217-pks-use-the-repository-conversion-v1-0-0dba48bcc239@pks.im","subject":"[PATCH 14/14] match-trees: stop using `the_repository`","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2024-12-17T06:44:01Z","receivedAt":"2024-12-17T06:44:27Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"Stop using `the_repository` in the \"match-trees\" subsystem by passing\ndown the already-available repository parameters to internal functions\nas required.\n\nSigned-off-by: Patrick Steinhardt <ps@pks.im>\n---\n match-trees.c | 50 +++++++++++++++++++++++++++-----------------------\n 1 file changed, 27 insertions(+), 23 deletions(-)\n\ndiff --git a/match-trees.c b/match-trees.c\nindex a1c8b91eaef8fa7c1714e6c2b4ec78ac365ae99d..ef14ceb594c72ada250013b2b4653cfaa822bf3b 100644\n--- a/match-trees.c\n+++ b/match-trees.c\n@@ -1,4 +1,3 @@\n-#define USE_THE_REPOSITORY_VARIABLE\n #define DISABLE_SIGN_COMPARE_WARNINGS\n \n #include \"git-compat-util.h\"\n@@ -8,6 +7,7 @@\n #include \"tree.h\"\n #include \"tree-walk.h\"\n #include \"object-store-ll.h\"\n+#include \"repository.h\"\n \n static int score_missing(unsigned mode)\n {\n@@ -54,14 +54,15 @@ static int score_matches(unsigned mode1, unsigned mode2)\n \treturn score;\n }\n \n-static void *fill_tree_desc_strict(struct tree_desc *desc,\n+static void *fill_tree_desc_strict(struct repository *r,\n+\t\t\t\t   struct tree_desc *desc,\n \t\t\t\t   const struct object_id *hash)\n {\n \tvoid *buffer;\n \tenum object_type type;\n \tunsigned long size;\n \n-\tbuffer = repo_read_object_file(the_repository, hash, &type, &size);\n+\tbuffer = repo_read_object_file(r, hash, &type, &size);\n \tif (!buffer)\n \t\tdie(\"unable to read tree (%s)\", oid_to_hex(hash));\n \tif (type != OBJ_TREE)\n@@ -80,12 +81,13 @@ static int base_name_entries_compare(const struct name_entry *a,\n /*\n  * Inspect two trees, and give a score that tells how similar they are.\n  */\n-static int score_trees(const struct object_id *hash1, const struct object_id *hash2)\n+static int score_trees(struct repository *r,\n+\t\t       const struct object_id *hash1, const struct object_id *hash2)\n {\n \tstruct tree_desc one;\n \tstruct tree_desc two;\n-\tvoid *one_buf = fill_tree_desc_strict(&one, hash1);\n-\tvoid *two_buf = fill_tree_desc_strict(&two, hash2);\n+\tvoid *one_buf = fill_tree_desc_strict(r, &one, hash1);\n+\tvoid *two_buf = fill_tree_desc_strict(r, &two, hash2);\n \tint score = 0;\n \n \tfor (;;) {\n@@ -133,7 +135,8 @@ static int score_trees(const struct object_id *hash1, const struct object_id *ha\n /*\n  * Match one itself and its subtrees with two and pick the best match.\n  */\n-static void match_trees(const struct object_id *hash1,\n+static void match_trees(struct repository *r,\n+\t\t\tconst struct object_id *hash1,\n \t\t\tconst struct object_id *hash2,\n \t\t\tint *best_score,\n \t\t\tchar **best_match,\n@@ -141,7 +144,7 @@ static void match_trees(const struct object_id *hash1,\n \t\t\tint recurse_limit)\n {\n \tstruct tree_desc one;\n-\tvoid *one_buf = fill_tree_desc_strict(&one, hash1);\n+\tvoid *one_buf = fill_tree_desc_strict(r, &one, hash1);\n \n \twhile (one.size) {\n \t\tconst char *path;\n@@ -152,7 +155,7 @@ static void match_trees(const struct object_id *hash1,\n \t\telem = tree_entry_extract(&one, &path, &mode);\n \t\tif (!S_ISDIR(mode))\n \t\t\tgoto next;\n-\t\tscore = score_trees(elem, hash2);\n+\t\tscore = score_trees(r, elem, hash2);\n \t\tif (*best_score < score) {\n \t\t\tfree(*best_match);\n \t\t\t*best_match = xstrfmt(\"%s%s\", base, path);\n@@ -160,7 +163,7 @@ static void match_trees(const struct object_id *hash1,\n \t\t}\n \t\tif (recurse_limit) {\n \t\t\tchar *newbase = xstrfmt(\"%s%s/\", base, path);\n-\t\t\tmatch_trees(elem, hash2, best_score, best_match,\n+\t\t\tmatch_trees(r, elem, hash2, best_score, best_match,\n \t\t\t\t    newbase, recurse_limit - 1);\n \t\t\tfree(newbase);\n \t\t}\n@@ -175,7 +178,8 @@ static void match_trees(const struct object_id *hash1,\n  * A tree \"oid1\" has a subdirectory at \"prefix\".  Come up with a tree object by\n  * replacing it with another tree \"oid2\".\n  */\n-static int splice_tree(const struct object_id *oid1, const char *prefix,\n+static int splice_tree(struct repository *r,\n+\t\t       const struct object_id *oid1, const char *prefix,\n \t\t       const struct object_id *oid2, struct object_id *result)\n {\n \tchar *subpath;\n@@ -194,7 +198,7 @@ static int splice_tree(const struct object_id *oid1, const char *prefix,\n \tif (*subpath)\n \t\tsubpath++;\n \n-\tbuf = repo_read_object_file(the_repository, oid1, &type, &sz);\n+\tbuf = repo_read_object_file(r, oid1, &type, &sz);\n \tif (!buf)\n \t\tdie(\"cannot read tree %s\", oid_to_hex(oid1));\n \tinit_tree_desc(&desc, oid1, buf, sz);\n@@ -232,15 +236,15 @@ static int splice_tree(const struct object_id *oid1, const char *prefix,\n \t\t    oid_to_hex(oid1));\n \tif (*subpath) {\n \t\tstruct object_id tree_oid;\n-\t\toidread(&tree_oid, rewrite_here, the_repository->hash_algo);\n-\t\tstatus = splice_tree(&tree_oid, subpath, oid2, &subtree);\n+\t\toidread(&tree_oid, rewrite_here, r->hash_algo);\n+\t\tstatus = splice_tree(r, &tree_oid, subpath, oid2, &subtree);\n \t\tif (status)\n \t\t\treturn status;\n \t\trewrite_with = &subtree;\n \t} else {\n \t\trewrite_with = oid2;\n \t}\n-\thashcpy(rewrite_here, rewrite_with->hash, the_repository->hash_algo);\n+\thashcpy(rewrite_here, rewrite_with->hash, r->hash_algo);\n \tstatus = write_object_file(buf, sz, OBJ_TREE, result);\n \tfree(buf);\n \treturn status;\n@@ -271,7 +275,7 @@ void shift_tree(struct repository *r,\n \tif (!depth_limit)\n \t\tdepth_limit = 2;\n \n-\tadd_score = del_score = score_trees(hash1, hash2);\n+\tadd_score = del_score = score_trees(r, hash1, hash2);\n \tadd_prefix = xcalloc(1, 1);\n \tdel_prefix = xcalloc(1, 1);\n \n@@ -279,13 +283,13 @@ void shift_tree(struct repository *r,\n \t * See if one's subtree resembles two; if so we need to prefix\n \t * two with a few fake trees to match the prefix.\n \t */\n-\tmatch_trees(hash1, hash2, &add_score, &add_prefix, \"\", depth_limit);\n+\tmatch_trees(r, hash1, hash2, &add_score, &add_prefix, \"\", depth_limit);\n \n \t/*\n \t * See if two's subtree resembles one; if so we need to\n \t * pick only subtree of two.\n \t */\n-\tmatch_trees(hash2, hash1, &del_score, &del_prefix, \"\", depth_limit);\n+\tmatch_trees(r, hash2, hash1, &del_score, &del_prefix, \"\", depth_limit);\n \n \t/* Assume we do not have to do any shifting */\n \toidcpy(shifted, hash2);\n@@ -306,7 +310,7 @@ void shift_tree(struct repository *r,\n \tif (!*add_prefix)\n \t\tgoto out;\n \n-\tsplice_tree(hash1, add_prefix, hash2, shifted);\n+\tsplice_tree(r, hash1, add_prefix, hash2, shifted);\n \n out:\n \tfree(add_prefix);\n@@ -340,16 +344,16 @@ void shift_tree_by(struct repository *r,\n \n \tif (candidate == 3) {\n \t\t/* Both are plausible -- we need to evaluate the score */\n-\t\tint best_score = score_trees(hash1, hash2);\n+\t\tint best_score = score_trees(r, hash1, hash2);\n \t\tint score;\n \n \t\tcandidate = 0;\n-\t\tscore = score_trees(&sub1, hash2);\n+\t\tscore = score_trees(r, &sub1, hash2);\n \t\tif (score > best_score) {\n \t\t\tcandidate = 1;\n \t\t\tbest_score = score;\n \t\t}\n-\t\tscore = score_trees(&sub2, hash1);\n+\t\tscore = score_trees(r, &sub2, hash1);\n \t\tif (score > best_score)\n \t\t\tcandidate = 2;\n \t}\n@@ -365,7 +369,7 @@ void shift_tree_by(struct repository *r,\n \t\t * shift tree2 down by adding shift_prefix above it\n \t\t * to match tree1.\n \t\t */\n-\t\tsplice_tree(hash1, shift_prefix, hash2, shifted);\n+\t\tsplice_tree(r, hash1, shift_prefix, hash2, shifted);\n \telse\n \t\t/*\n \t\t * shift tree2 up by removing shift_prefix from it\n\n-- \n2.48.0.rc0.184.g0fc57dec57.dirty\n\n"},{"id":"509214","messageId":"Z2Fr90U9ujGFv2IT@ArchLinux","threadId":"62650","inReplyTo":"20241217-pks-use-the-repository-conversion-v1-2-0dba48bcc239@pks.im","subject":"Re: [PATCH 02/14] pager: stop using `the_repository`","fromName":"shejialuo","fromEmail":"shejialuo@gmail.com","sentAt":"2024-12-17T12:17:59Z","receivedAt":"2024-12-17T12:17:20Z","isPatch":true,"sender":{"key":"shejialuo@gmail.com","avatar":"https://avatars.githubusercontent.com/u/56911263?v=4"},"body":"On Tue, Dec 17, 2024 at 07:43:49AM +0100, Patrick Steinhardt wrote:\n> Stop using `the_repository` in the \"pager\" subsystem by passing in a\n> repository when setting up the pager and when configuring it.\n> \n> Adjust callers accordingly by using `the_repository`. While there may be\n> some callers that have a repository available in their context, this\n> trivial conversion allows for easier verification and bubbles up the use\n> of `the_repository` by one level.\n> \n> Signed-off-by: Patrick Steinhardt <ps@pks.im>\n> ---\n>  add-patch.c     |  2 +-\n>  builtin/am.c    |  4 ++--\n>  builtin/blame.c |  2 +-\n>  builtin/grep.c  |  4 ++--\n>  builtin/help.c  |  4 ++--\n>  builtin/log.c   |  4 ++--\n>  builtin/var.c   |  2 +-\n>  diff.c          |  4 ++--\n>  git.c           |  8 ++++----\n>  pager.c         | 14 ++++++--------\n>  pager.h         |  7 ++++---\n>  11 files changed, 27 insertions(+), 28 deletions(-)\n> \n> diff --git a/builtin/help.c b/builtin/help.c\n> index 05136279cf7b1007ab754f5630c34536a5f9461f..c257079cebc3c09fb91f258c3b0148e2f204c0e7 100644\n> --- a/builtin/help.c\n> +++ b/builtin/help.c\n> @@ -658,7 +658,7 @@ int cmd_help(int argc,\n>  \tcase HELP_ACTION_ALL:\n>  \t\topt_mode_usage(argc, \"--all\", help_format);\n>  \t\tif (verbose) {\n> -\t\t\tsetup_pager();\n> +\t\t\tsetup_pager(the_repository);\n\nIt's possible we run \"git help\" outside of the repository. Here we still\npass \"the_repository\" to the \"setup_pager\", it may be a little strange.\nBut later we will use the \"repo\" parameter instead of the global\nvariable \"the_repository\", so this is OK.\n\n>  \t\t\tlist_all_cmds_help(show_external_commands,\n>  \t\t\t\t\t   show_aliases);\n>  \t\t\treturn 0;\n\n"},{"id":"509215","messageId":"Z2FvCKYdRLZzHJVC@ArchLinux","threadId":"62650","inReplyTo":"20241217-pks-use-the-repository-conversion-v1-6-0dba48bcc239@pks.im","subject":"Re: [PATCH 06/14] server-info: stop using `the_repository`","fromName":"shejialuo","fromEmail":"shejialuo@gmail.com","sentAt":"2024-12-17T12:31:04Z","receivedAt":"2024-12-17T12:30:25Z","isPatch":true,"sender":{"key":"shejialuo@gmail.com","avatar":"https://avatars.githubusercontent.com/u/56911263?v=4"},"body":"On Tue, Dec 17, 2024 at 07:43:53AM +0100, Patrick Steinhardt wrote:\n> Stop using `the_repository` in the \"server-info\" subsystem by passing in\n> a repository when updating server info and storing the repository in the\n> `update_info_ctx` structure to make it accessible to other functions.\n> \n> Adjust callers accordingly by using `the_repository`. While there may be\n> some callers that have a repository available in their context, this\n> trivial conversion allows for easier verification and bubbles up the use\n> of `the_repository` by one level.\n> \n> Signed-off-by: Patrick Steinhardt <ps@pks.im>\n> ---\n>  builtin/receive-pack.c       |  2 +-\n>  builtin/repack.c             |  2 +-\n>  builtin/update-server-info.c |  2 +-\n>  server-info.c                | 40 ++++++++++++++++++++++------------------\n>  server-info.h                |  4 +++-\n>  5 files changed, 28 insertions(+), 22 deletions(-)\n> \n\n> -int update_server_info(int force)\n> +int update_server_info(struct repository *r, int force)\n>  {\n>  \t/* We would add more dumb-server support files later,\n>  \t * including index of available pack files and their\n>  \t * intended audiences.\n>  \t */\n>  \tint errs = 0;\n> +\tchar *path;\n>  \n> -\terrs = errs | update_info_refs(force);\n> -\terrs = errs | update_info_packs(force);\n> +\terrs = errs | update_info_refs(r, force);\n> +\terrs = errs | update_info_packs(r, force);\n>  \n>  \t/* remove leftover rev-cache file if there is any */\n> -\tunlink_or_warn(git_path(\"info/rev-cache\"));\n> +\tpath = repo_git_path(r, \"info/rev-cache\");\n> +\tunlink_or_warn(path);\n> +\tfree(path);\n>  \n\nThe original \"git_path\" will be returned from the static string buffers,\nso there is no need to free. But \"repo_git_path\" will return a allocated\nstring, the caller need to explicit free this. Make sense.\n\n>  \treturn errs;\n>  }\n"},{"id":"509217","messageId":"Z2Fygp-5pFQi1p41@ArchLinux","threadId":"62650","inReplyTo":"20241217-pks-use-the-repository-conversion-v1-0-0dba48bcc239@pks.im","subject":"Re: [PATCH 00/14] Stop using `the_repository` in some trivial cases","fromName":"shejialuo","fromEmail":"shejialuo@gmail.com","sentAt":"2024-12-17T12:45:54Z","receivedAt":"2024-12-17T12:45:14Z","isPatch":true,"sender":{"key":"shejialuo@gmail.com","avatar":"https://avatars.githubusercontent.com/u/56911263?v=4"},"body":"On Tue, Dec 17, 2024 at 07:43:47AM +0100, Patrick Steinhardt wrote:\n> Hi,\n> \n> this small patch series performs some refactorings to stop using\n> `the_repository` in several subsystems. There wasn't really any\n> criterium for which subsystems I picked, except that all of them have\n> been trivial to convert.\n> \n> In this patch series I'm merely bubbling up `the_repository` one more\n> layer even though some calling contexts already have a repository\n> available. For the sake of triviality I decided not to handle these\n> cases though and instead let a future patch series worry about them.\n> \n\nActually, I am excited to see that we remove the global variable\n\"the_repository\" in some subsystems because I have seen every patch with\n\"<subsystem>: stop using `the_repository`\".\n\nBy this, we make the problem smaller, which is good. I have read through\nall the patches, which looks to me.\n\nThanks,\nJialuo\n"},{"id":"509632","messageId":"Z265EvdDt0ynGC1M@pks.im","threadId":"62650","inReplyTo":"Z2Fygp-5pFQi1p41@ArchLinux","subject":"Re: [PATCH 00/14] Stop using `the_repository` in some trivial cases","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2024-12-27T14:26:26Z","receivedAt":"2024-12-27T14:26:48Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"On Tue, Dec 17, 2024 at 08:45:54PM +0800, shejialuo wrote:\n> On Tue, Dec 17, 2024 at 07:43:47AM +0100, Patrick Steinhardt wrote:\n> > Hi,\n> > \n> > this small patch series performs some refactorings to stop using\n> > `the_repository` in several subsystems. There wasn't really any\n> > criterium for which subsystems I picked, except that all of them have\n> > been trivial to convert.\n> > \n> > In this patch series I'm merely bubbling up `the_repository` one more\n> > layer even though some calling contexts already have a repository\n> > available. For the sake of triviality I decided not to handle these\n> > cases though and instead let a future patch series worry about them.\n> > \n> \n> Actually, I am excited to see that we remove the global variable\n> \"the_repository\" in some subsystems because I have seen every patch with\n> \"<subsystem>: stop using `the_repository`\".\n> \n> By this, we make the problem smaller, which is good. I have read through\n> all the patches, which looks to me.\n\nThanks for your review!\n\nPatrick\n"},{"id":"509759","messageId":"CAOLa=ZRgzD8SPpfKcF5Ztr1f4oVfjP7HumvSVTTLbdLWW7PmSQ@mail.gmail.com","threadId":"62650","inReplyTo":"20241217-pks-use-the-repository-conversion-v1-1-0dba48bcc239@pks.im","subject":"Re: [PATCH 01/14] progress: stop using `the_repository`","fromName":"Karthik Nayak","fromEmail":"karthik.188@gmail.com","sentAt":"2024-12-31T06:42:24Z","receivedAt":"2024-12-31T06:42:25Z","isPatch":true,"sender":{"key":"karthik.188@gmail.com","avatar":"https://avatars.githubusercontent.com/u/1786334?v=4"},"body":"Patrick Steinhardt <ps@pks.im> writes:\n\n> Stop using `the_repository` in the \"progress\" subsystem by passing in a\n> repository when initializing `struct progress`. Furthermore, store a\n> pointer to the repository in that struct so that we can pass it to the\n> trace2 API when logging information.\n>\n\nSo that's the only usage of `the_repository` in the progress subsystem\ncurrently. Makes sense.\n\n> Adjust callers accordingly by using `the_repository`. While there may be\n> some callers that have a repository available in their context, this\n> trivial conversion allows for easier verification and bubbles up the use\n> of `the_repository` by one level.\n>\n\nI think this is a good approach. I would be vary if we ended up\nintroducing more instances of the `USE_THE_REPOSITORY_VARIABLE`\ndefinition. But that's not the case here, we only do so in\n`t/helper/test-progress.c`, which is expected. The patch looks good!\n"},{"id":"509760","messageId":"CAOLa=ZTh2Nwwo7VKcXGC0zVivmPjxXr7R-cYC_A2JoeVvRsb1A@mail.gmail.com","threadId":"62650","inReplyTo":"Z2Fr90U9ujGFv2IT@ArchLinux","subject":"Re: [PATCH 02/14] pager: stop using `the_repository`","fromName":"Karthik Nayak","fromEmail":"karthik.188@gmail.com","sentAt":"2024-12-31T06:55:53Z","receivedAt":"2024-12-31T06:55:54Z","isPatch":true,"sender":{"key":"karthik.188@gmail.com","avatar":"https://avatars.githubusercontent.com/u/1786334?v=4"},"body":"shejialuo <shejialuo@gmail.com> writes:\n\n> On Tue, Dec 17, 2024 at 07:43:49AM +0100, Patrick Steinhardt wrote:\n>> Stop using `the_repository` in the \"pager\" subsystem by passing in a\n>> repository when setting up the pager and when configuring it.\n>>\n>> Adjust callers accordingly by using `the_repository`. While there may be\n>> some callers that have a repository available in their context, this\n>> trivial conversion allows for easier verification and bubbles up the use\n>> of `the_repository` by one level.\n>>\n>> Signed-off-by: Patrick Steinhardt <ps@pks.im>\n>> ---\n>>  add-patch.c     |  2 +-\n>>  builtin/am.c    |  4 ++--\n>>  builtin/blame.c |  2 +-\n>>  builtin/grep.c  |  4 ++--\n>>  builtin/help.c  |  4 ++--\n>>  builtin/log.c   |  4 ++--\n>>  builtin/var.c   |  2 +-\n>>  diff.c          |  4 ++--\n>>  git.c           |  8 ++++----\n>>  pager.c         | 14 ++++++--------\n>>  pager.h         |  7 ++++---\n>>  11 files changed, 27 insertions(+), 28 deletions(-)\n>>\n>> diff --git a/builtin/help.c b/builtin/help.c\n>> index 05136279cf7b1007ab754f5630c34536a5f9461f..c257079cebc3c09fb91f258c3b0148e2f204c0e7 100644\n>> --- a/builtin/help.c\n>> +++ b/builtin/help.c\n>> @@ -658,7 +658,7 @@ int cmd_help(int argc,\n>>  \tcase HELP_ACTION_ALL:\n>>  \t\topt_mode_usage(argc, \"--all\", help_format);\n>>  \t\tif (verbose) {\n>> -\t\t\tsetup_pager();\n>> +\t\t\tsetup_pager(the_repository);\n>\n> It's possible we run \"git help\" outside of the repository. Here we still\n> pass \"the_repository\" to the \"setup_pager\", it may be a little strange.\n> But later we will use the \"repo\" parameter instead of the global\n> variable \"the_repository\", so this is OK.\n>\n\nWell, the crux here is that the pager only requires the repository for\ncalling `read_early_config()` in `config.c`. And that function is used\nto read if there is pager config, since git allows you to setup the\npager via config. It also checks if the repo variable is set, so this\nwould work as expected outside of a git repository.\n\n>>  \t\t\tlist_all_cmds_help(show_external_commands,\n>>  \t\t\t\t\t   show_aliases);\n>>  \t\t\treturn 0;\n"},{"id":"510019","messageId":"87v7urk6dl.fsf@iotcl.com","threadId":"62650","inReplyTo":"20241217-pks-use-the-repository-conversion-v1-1-0dba48bcc239@pks.im","subject":"Re: [PATCH 01/14] progress: stop using `the_repository`","fromName":"Toon Claes","fromEmail":"toon@iotcl.com","sentAt":"2025-01-06T20:57:26Z","receivedAt":"2025-01-06T20:57:41Z","isPatch":true,"sender":{"key":"toon@iotcl.com","avatar":"https://avatars.githubusercontent.com/u/121621?v=4"},"body":"Patrick Steinhardt <ps@pks.im> writes:\n\n> Stop using `the_repository` in the \"progress\" subsystem by passing in a\n> repository when initializing `struct progress`. Furthermore, store a\n> pointer to the repository in that struct so that we can pass it to the\n> trace2 API when logging information.\n>\n> Adjust callers accordingly by using `the_repository`. While there may be\n> some callers that have a repository available in their context, this\n> trivial conversion allows for easier verification and bubbles up the use\n> of `the_repository` by one level.\n\nI'm not sure I agree here. Below I've marked all places where I think we\nare able to get the repo from somewhere else than `the_repository`. For\nexample, looking at diffcore-rename.c, the already present calls to\ntrace2_*() use `options->repo`, why shouldn't we do the same?\n\nI understand what your angle is, you want to bubble up `the_repository`\nand make the changes easier to reason about, but it feels to me we're\ncreating extra work. If most people disagree with me, I'm happy to take\nyour approach.\n\n>\n> Signed-off-by: Patrick Steinhardt <ps@pks.im>\n> ---\n>  builtin/blame.c          |  4 +++-\n>  builtin/commit-graph.c   |  1 +\n>  builtin/fsck.c           | 12 ++++++++----\n>  builtin/index-pack.c     |  7 +++++--\n>  builtin/log.c            |  3 ++-\n>  builtin/pack-objects.c   | 21 ++++++++++++++-------\n>  builtin/prune.c          |  3 ++-\n>  builtin/remote.c         |  3 ++-\n>  builtin/rev-list.c       |  3 ++-\n>  builtin/unpack-objects.c |  3 ++-\n>  commit-graph.c           | 20 +++++++++++++++++---\n>  delta-islands.c          |  3 ++-\n>  diffcore-rename.c        |  1 +\n>  entry.c                  |  4 +++-\n>  midx-write.c             | 11 ++++++++---\n>  midx.c                   | 13 +++++++++----\n>  pack-bitmap-write.c      |  6 ++++--\n>  pack-bitmap.c            |  4 +++-\n>  preload-index.c          |  4 +++-\n>  progress.c               | 34 ++++++++++++++++++++--------------\n>  progress.h               | 13 +++++++++----\n>  prune-packed.c           |  3 ++-\n>  pseudo-merge.c           |  3 ++-\n>  read-cache.c             |  3 ++-\n>  t/helper/test-progress.c |  6 +++++-\n>  unpack-trees.c           |  4 +++-\n>  walker.c                 |  3 ++-\n>  27 files changed, 136 insertions(+), 59 deletions(-)\n>\n> [snip]\n>\n> diff --git a/builtin/fsck.c b/builtin/fsck.c\n> index 0196c54eb68ee54c22de72d64b3f31602594e50b..7a4dcb0716052ff1b9236ea66b8901960fe1c55d 100644\n> --- a/builtin/fsck.c\n> +++ b/builtin/fsck.c\n> @@ -197,7 +197,8 @@ static int traverse_reachable(void)\n>  \tunsigned int nr = 0;\n>  \tint result = 0;\n>  \tif (show_progress)\n> -\t\tprogress = start_delayed_progress(_(\"Checking connectivity\"), 0);\n> +\t\tprogress = start_delayed_progress(the_repository,\n> +\t\t\t\t\t\t  _(\"Checking connectivity\"), 0);\n>  \twhile (pending.nr) {\n>  \t\tresult |= traverse_one_object(object_array_pop(&pending));\n>  \t\tdisplay_progress(progress, ++nr);\n> @@ -703,7 +704,8 @@ static void fsck_object_dir(const char *path)\n>  \t\tfprintf_ln(stderr, _(\"Checking object directory\"));\n>  \n>  \tif (show_progress)\n> -\t\tprogress = start_progress(_(\"Checking object directories\"), 256);\n> +\t\tprogress = start_progress(the_repository,\n> +\t\t\t\t\t  _(\"Checking object directories\"), 256);\n>  \n>  \tfor_each_loose_file_in_objdir(path, fsck_loose, fsck_cruft, fsck_subdir,\n>  \t\t\t\t      &cb_data);\n> @@ -879,7 +881,8 @@ static int check_pack_rev_indexes(struct repository *r, int show_progress)\n>  \tif (show_progress) {\n>  \t\tfor (struct packed_git *p = get_all_packs(r); p; p = p->next)\n>  \t\t\tpack_count++;\n> -\t\tprogress = start_delayed_progress(\"Verifying reverse pack-indexes\", pack_count);\n> +\t\tprogress = start_delayed_progress(the_repository,\n\nI think we should use `r` here.\n\n> +\t\t\t\t\t\t  \"Verifying reverse pack-indexes\", pack_count);\n>  \t\tpack_count = 0;\n>  \t}\n>\n> [snip]\n>\n> diff --git a/commit-graph.c b/commit-graph.c\n> index 0df66e5a243390bc1224b28e2b55c541f9d93fb1..2a2999a6b886905276a0c39dda6135f0c92aa361 100644\n> --- a/commit-graph.c\n> +++ b/commit-graph.c\n> @@ -1534,6 +1534,7 @@ static void close_reachable(struct write_commit_graph_context *ctx)\n>  \n>  \tif (ctx->report_progress)\n>  \t\tctx->progress = start_delayed_progress(\n\nShall we use `ctx->r` here? And same for all other changes in this file.\n\n> +\t\t\t\t\tthe_repository,\n>  \t\t\t\t\t_(\"Loading known commits in commit graph\"),\n>  \t\t\t\t\tctx->oids.nr);\n>  \tfor (i = 0; i < ctx->oids.nr; i++) {\n> @@ -1551,6 +1552,7 @@ static void close_reachable(struct write_commit_graph_context *ctx)\n>  \t */\n>  \tif (ctx->report_progress)\n>  \t\tctx->progress = start_delayed_progress(\n> +\t\t\t\t\tthe_repository,\n>  \t\t\t\t\t_(\"Expanding reachable commits in commit graph\"),\n>  \t\t\t\t\t0);\n>  \tfor (i = 0; i < ctx->oids.nr; i++) {\n> @@ -1571,6 +1573,7 @@ static void close_reachable(struct write_commit_graph_context *ctx)\n>  \n>  \tif (ctx->report_progress)\n>  \t\tctx->progress = start_delayed_progress(\n> +\t\t\t\t\tthe_repository,\n>  \t\t\t\t\t_(\"Clearing commit marks in commit graph\"),\n>  \t\t\t\t\tctx->oids.nr);\n>  \tfor (i = 0; i < ctx->oids.nr; i++) {\n> @@ -1688,6 +1691,7 @@ static void compute_topological_levels(struct write_commit_graph_context *ctx)\n>  \tif (ctx->report_progress)\n>  \t\tinfo.progress = ctx->progress\n>  \t\t\t      = start_delayed_progress(\n> +\t\t\t\t\tthe_repository,\n>  \t\t\t\t\t_(\"Computing commit graph topological levels\"),\n>  \t\t\t\t\tctx->commits.nr);\n>  \n> @@ -1722,6 +1726,7 @@ static void compute_generation_numbers(struct write_commit_graph_context *ctx)\n>  \tif (ctx->report_progress)\n>  \t\tinfo.progress = ctx->progress\n>  \t\t\t      = start_delayed_progress(\n> +\t\t\t\t\tthe_repository,\n>  \t\t\t\t\t_(\"Computing commit graph generation numbers\"),\n>  \t\t\t\t\tctx->commits.nr);\n>  \n> @@ -1798,6 +1803,7 @@ static void compute_bloom_filters(struct write_commit_graph_context *ctx)\n>  \n>  \tif (ctx->report_progress)\n>  \t\tprogress = start_delayed_progress(\n> +\t\t\tthe_repository,\n>  \t\t\t_(\"Computing commit changed paths Bloom filters\"),\n>  \t\t\tctx->commits.nr);\n>  \n> @@ -1877,6 +1883,7 @@ int write_commit_graph_reachable(struct object_directory *odb,\n>  \tdata.commits = &commits;\n>  \tif (flags & COMMIT_GRAPH_WRITE_PROGRESS)\n>  \t\tdata.progress = start_delayed_progress(\n> +\t\t\tthe_repository,\n>  \t\t\t_(\"Collecting referenced commits\"), 0);\n>  \n>  \trefs_for_each_ref(get_main_ref_store(the_repository), add_ref_to_set,\n> @@ -1908,7 +1915,8 @@ static int fill_oids_from_packs(struct write_commit_graph_context *ctx,\n>  \t\t\t       \"Finding commits for commit graph in %\"PRIuMAX\" packs\",\n>  \t\t\t       pack_indexes->nr),\n>  \t\t\t    (uintmax_t)pack_indexes->nr);\n> -\t\tctx->progress = start_delayed_progress(progress_title.buf, 0);\n> +\t\tctx->progress = start_delayed_progress(the_repository,\n> +\t\t\t\t\t\t       progress_title.buf, 0);\n>  \t\tctx->progress_done = 0;\n>  \t}\n>  \tfor (i = 0; i < pack_indexes->nr; i++) {\n> @@ -1959,6 +1967,7 @@ static void fill_oids_from_all_packs(struct write_commit_graph_context *ctx)\n>  {\n>  \tif (ctx->report_progress)\n>  \t\tctx->progress = start_delayed_progress(\n> +\t\t\tthe_repository,\n>  \t\t\t_(\"Finding commits for commit graph among packed objects\"),\n>  \t\t\tctx->approx_nr_objects);\n>  \tfor_each_packed_object(ctx->r, add_packed_commits, ctx,\n> @@ -1977,6 +1986,7 @@ static void copy_oids_to_commits(struct write_commit_graph_context *ctx)\n>  \tctx->num_extra_edges = 0;\n>  \tif (ctx->report_progress)\n>  \t\tctx->progress = start_delayed_progress(\n> +\t\t\tthe_repository,\n>  \t\t\t_(\"Finding extra edges in commit graph\"),\n>  \t\t\tctx->oids.nr);\n>  \toid_array_sort(&ctx->oids);\n> @@ -2136,6 +2146,7 @@ static int write_commit_graph_file(struct write_commit_graph_context *ctx)\n>  \t\t\t       get_num_chunks(cf)),\n>  \t\t\t    get_num_chunks(cf));\n>  \t\tctx->progress = start_delayed_progress(\n> +\t\t\tthe_repository,\n>  \t\t\tprogress_title.buf,\n>  \t\t\tst_mult(get_num_chunks(cf), ctx->commits.nr));\n>  \t}\n> @@ -2348,6 +2359,7 @@ static void sort_and_scan_merged_commits(struct write_commit_graph_context *ctx)\n>  \n>  \tif (ctx->report_progress)\n>  \t\tctx->progress = start_delayed_progress(\n> +\t\t\t\t\tthe_repository,\n>  \t\t\t\t\t_(\"Scanning merged commits\"),\n>  \t\t\t\t\tctx->commits.nr);\n>  \n> @@ -2392,7 +2404,8 @@ static void merge_commit_graphs(struct write_commit_graph_context *ctx)\n>  \t\tcurrent_graph_number--;\n>  \n>  \t\tif (ctx->report_progress)\n> -\t\t\tctx->progress = start_delayed_progress(_(\"Merging commit-graph\"), 0);\n> +\t\t\tctx->progress = start_delayed_progress(the_repository,\n> +\t\t\t\t\t\t\t       _(\"Merging commit-graph\"), 0);\n>  \n>  \t\tmerge_commit_graph(ctx, g);\n>  \t\tstop_progress(&ctx->progress);\n> @@ -2874,7 +2887,8 @@ int verify_commit_graph(struct repository *r, struct commit_graph *g, int flags)\n>  \t\tif (!(flags & COMMIT_GRAPH_VERIFY_SHALLOW))\n>  \t\t\ttotal += g->num_commits_in_base;\n>  \n> -\t\tprogress = start_progress(_(\"Verifying commits in commit graph\"),\n> +\t\tprogress = start_progress(the_repository,\n> +\t\t\t\t\t  _(\"Verifying commits in commit graph\"),\n>  \t\t\t\t\t  total);\n>  \t}\n>  \n> diff --git a/delta-islands.c b/delta-islands.c\n> index 1c465a6041914538bcb8be51c500653d8fa1a626..3aec43fada36f7052b825dcb2ac0e1ad79f028b7 100644\n> --- a/delta-islands.c\n> +++ b/delta-islands.c\n> @@ -267,7 +267,8 @@ void resolve_tree_islands(struct repository *r,\n>  \tQSORT(todo, nr, tree_depth_compare);\n>  \n>  \tif (progress)\n> -\t\tprogress_state = start_progress(_(\"Propagating island marks\"), nr);\n> +\t\tprogress_state = start_progress(the_repository,\n\nHere we can use `r`.\n\n> +\t\t\t\t\t\t_(\"Propagating island marks\"), nr);\n>  \n>  \tfor (i = 0; i < nr; i++) {\n>  \t\tstruct object_entry *ent = todo[i].entry;\n> diff --git a/diffcore-rename.c b/diffcore-rename.c\n> index 10bb0321b10d5896aaa6a26a624d2066598bf51f..91b77993c7827f9ddc7b444b42f480b8209fd821 100644\n> --- a/diffcore-rename.c\n> +++ b/diffcore-rename.c\n> @@ -1567,6 +1567,7 @@ void diffcore_rename_extended(struct diff_options *options,\n>  \ttrace2_region_enter(\"diff\", \"inexact renames\", options->repo);\n>  \tif (options->show_rename_progress) {\n>  \t\tprogress = start_delayed_progress(\n> +\t\t\t\tthe_repository,\n\nCan we use `options->repo` here?\n\nIf we do, we ideally should also replace occurrences of\n`the_repository->hash_algo` in this function, although I realize that's\noutside the scope of this commit.\n\n>  \t\t\t\t_(\"Performing inexact rename detection\"),\n>  \t\t\t\t(uint64_t)num_destinations * (uint64_t)num_sources);\n>  \t}\n> \n> [snip]\n>\n> diff --git a/pack-bitmap-write.c b/pack-bitmap-write.c\n> index 4f8be53c2bd75f83a0555e2a5510c2bbca07b36d..a06a1f35c619b3b01e63a506a6d4312e14cf181c 100644\n> --- a/pack-bitmap-write.c\n> +++ b/pack-bitmap-write.c\n> @@ -590,7 +590,8 @@ int bitmap_writer_build(struct bitmap_writer *writer)\n>  \tint closed = 1; /* until proven otherwise */\n>  \n>  \tif (writer->show_progress)\n> -\t\twriter->progress = start_progress(\"Building bitmaps\",\n> +\t\twriter->progress = start_progress(the_repository,\n\nUnsure, but can we use `writer->to_pack->repo`? Although I see some\ntrace2_* functions also use `the_repository`, so consistency in this\nfunction would be nice.\n\n> +\t\t\t\t\t\t  \"Building bitmaps\",\n>  \t\t\t\t\t\t  writer->selected_nr);\n>  \ttrace2_region_enter(\"pack-bitmap-write\", \"building_bitmaps_total\",\n>  \t\t\t    the_repository);\n> @@ -710,7 +711,8 @@ void bitmap_writer_select_commits(struct bitmap_writer *writer,\n>  \t}\n>  \n>  \tif (writer->show_progress)\n> -\t\twriter->progress = start_progress(\"Selecting bitmap commits\", 0);\n> +\t\twriter->progress = start_progress(the_repository,\n\nSame, can we use `writer->to_pack->repo`?\n\n> +\t\t\t\t\t\t  \"Selecting bitmap commits\", 0);\n>  \n>  \tfor (;;) {\n>  \t\tstruct commit *chosen = NULL;\n>\n> [snip]\n>\n> diff --git a/preload-index.c b/preload-index.c\n> index ab94d6f39967ea4358f51ff8384aa60927bfe259..40ab2abafb8de500a5f2ec678a584a5fd5e1bc16 100644\n> --- a/preload-index.c\n> +++ b/preload-index.c\n> @@ -132,7 +132,9 @@ void preload_index(struct index_state *index,\n>  \n>  \tmemset(&pd, 0, sizeof(pd));\n>  \tif (refresh_flags & REFRESH_PROGRESS && isatty(2)) {\n> -\t\tpd.progress = start_delayed_progress(_(\"Refreshing index\"), index->cache_nr);\n> +\t\tpd.progress = start_delayed_progress(the_repository,\n\nCan we use `index->repo` here?\n\n> [snip]\n>\n> diff --git a/pseudo-merge.c b/pseudo-merge.c\n> index 971f54cfe1a895aed00f6d0a65c62aafc83a0cc8..893b763fe45490875ea226eaffff0c7cb1dafb06 100644\n> --- a/pseudo-merge.c\n> +++ b/pseudo-merge.c\n> @@ -459,7 +459,8 @@ void select_pseudo_merges(struct bitmap_writer *writer)\n>  \t\treturn;\n>  \n>  \tif (writer->show_progress)\n> -\t\tprogress = start_progress(\"Selecting pseudo-merge commits\",\n> +\t\tprogress = start_progress(the_repository,\n\nAlso a candidate for `writer->to_pack->repo`?\n\n> +\t\t\t\t\t  \"Selecting pseudo-merge commits\",\n>  \t\t\t\t\t  writer->pseudo_merge_groups.nr);\n>  \n>  \trefs_for_each_ref(get_main_ref_store(the_repository),\n> diff --git a/read-cache.c b/read-cache.c\n> index 15d79839c205176f9161f537aa706dac44b3023c..38c36caa7fef4d44da74c29e059839d88426df15 100644\n> --- a/read-cache.c\n> +++ b/read-cache.c\n> @@ -1523,7 +1523,8 @@ int refresh_index(struct index_state *istate, unsigned int flags,\n>  \tint t2_sum_scan = 0;\n>  \n>  \tif (flags & REFRESH_PROGRESS && isatty(2))\n> -\t\tprogress = start_delayed_progress(_(\"Refresh index\"),\n> +\t\tprogress = start_delayed_progress(the_repository,\n\nI think also `istate->repo` would work here.\n\n> +\t\t\t\t\t\t  _(\"Refresh index\"),\n>  \t\t\t\t\t\t  istate->cache_nr);\n>  \n>  \ttrace_performance_enter();\n>\n> [snip]\n>\n> diff --git a/unpack-trees.c b/unpack-trees.c\n> index b3be5d542f5fc5a02b8838101f7334ff44b2c626..334cb84f6531b588688d5a43c538c8d1a5f7e768 100644\n> --- a/unpack-trees.c\n> +++ b/unpack-trees.c\n> @@ -372,7 +372,8 @@ static struct progress *get_progress(struct unpack_trees_options *o,\n>  \t\t\ttotal++;\n>  \t}\n>  \n> -\treturn start_delayed_progress(_(\"Updating files\"), total);\n> +\treturn start_delayed_progress(the_repository,\n\nMaybe also use `index->repo` here?\n\n> +\t\t\t\t      _(\"Updating files\"), total);\n>  }\n>  \n>  static void setup_collided_checkout_detection(struct checkout *state,\n> @@ -1773,6 +1774,7 @@ static int clear_ce_flags(struct index_state *istate,\n>  \tstrbuf_reset(&prefix);\n>  \tif (show_progress)\n>  \t\tistate->progress = start_delayed_progress(\n> +\t\t\t\t\tthe_repository,\n>  \t\t\t\t\t_(\"Updating index flags\"),\n>  \t\t\t\t\tistate->cache_nr);\n>  \n> diff --git a/walker.c b/walker.c\n> index 7cc9dbea46d64d6bd3336025d640f284a6202157..1cf3da02193531a17fd11dbd2e8aadf36f38b200 100644\n> --- a/walker.c\n> +++ b/walker.c\n> @@ -172,7 +172,8 @@ static int loop(struct walker *walker)\n>  \tuint64_t nr = 0;\n>  \n>  \tif (walker->get_progress)\n> -\t\tprogress = start_delayed_progress(_(\"Fetching objects\"), 0);\n> +\t\tprogress = start_delayed_progress(the_repository,\n> +\t\t\t\t\t\t  _(\"Fetching objects\"), 0);\n>  \n>  \twhile (process_queue) {\n>  \t\tstruct object *obj = process_queue->item;\n>\n> -- \n> 2.48.0.rc0.184.g0fc57dec57.dirty\n\n"},{"id":"510051","messageId":"Z3zVhZC437Kx60dm@pks.im","threadId":"62650","inReplyTo":"87v7urk6dl.fsf@iotcl.com","subject":"Re: [PATCH 01/14] progress: stop using `the_repository`","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2025-01-07T07:19:33Z","receivedAt":"2025-01-07T07:19:38Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"On Mon, Jan 06, 2025 at 09:57:26PM +0100, Toon Claes wrote:\n> Patrick Steinhardt <ps@pks.im> writes:\n> \n> > Stop using `the_repository` in the \"progress\" subsystem by passing in a\n> > repository when initializing `struct progress`. Furthermore, store a\n> > pointer to the repository in that struct so that we can pass it to the\n> > trace2 API when logging information.\n> >\n> > Adjust callers accordingly by using `the_repository`. While there may be\n> > some callers that have a repository available in their context, this\n> > trivial conversion allows for easier verification and bubbles up the use\n> > of `the_repository` by one level.\n> \n> I'm not sure I agree here. Below I've marked all places where I think we\n> are able to get the repo from somewhere else than `the_repository`. For\n> example, looking at diffcore-rename.c, the already present calls to\n> trace2_*() use `options->repo`, why shouldn't we do the same?\n> \n> I understand what your angle is, you want to bubble up `the_repository`\n> and make the changes easier to reason about, but it feels to me we're\n> creating extra work. If most people disagree with me, I'm happy to take\n> your approach.\n\nThe problem is that this could lead to a change in behaviour, as the repo\nwe have available may or may not be the same as `the_repository`. So\nwithout auditing every single callsite I have no way of knowing, and\nthat audit is quite involved when it touches a lot of subsystems at\nonce.\n\nThat's why I'm instead pushing it further down the road: we know that\ninjecting `the_repository` will yield the exact same behaviour as\nbefore, and we only need to audit a single subsystem, namely the one\nthat we're currently converting. So it's one more step overall, but by\nseparating mechanical from non-mechanical changes it makes the steps\nsimpler overall.\n\nPatrick\n"},{"id":"510062","messageId":"CAOLa=ZTn2vfmS480G2wnaMehoK6+Z7EZ3Wx=ctaaPjBetOkbcA@mail.gmail.com","threadId":"62650","inReplyTo":"20241217-pks-use-the-repository-conversion-v1-0-0dba48bcc239@pks.im","subject":"Re: [PATCH 00/14] Stop using `the_repository` in some trivial cases","fromName":"Karthik Nayak","fromEmail":"karthik.188@gmail.com","sentAt":"2025-01-07T11:41:33Z","receivedAt":"2025-01-07T11:41:34Z","isPatch":true,"sender":{"key":"karthik.188@gmail.com","avatar":"https://avatars.githubusercontent.com/u/1786334?v=4"},"body":"Patrick Steinhardt <ps@pks.im> writes:\n\n> Hi,\n>\n> this small patch series performs some refactorings to stop using\n> `the_repository` in several subsystems. There wasn't really any\n> criterium for which subsystems I picked, except that all of them have\n> been trivial to convert.\n>\n> In this patch series I'm merely bubbling up `the_repository` one more\n> layer even though some calling contexts already have a repository\n> available. For the sake of triviality I decided not to handle these\n> cases though and instead let a future patch series worry about them.\n>\n> This series is built on v2.48.0-rc0 with ps/build-sign-compare at\n> e03d2a9ccb (t/helper: don't depend on implicit wraparound, 2024-12-06)\n> merged into it. There's a single merge conflict with 'seen' that can be\n> solved like this:\n\nI went through half of the patches a week ago, but got back to reading\nthrough the series today.\n\nThe approach here is to simply bubble up the usage of `the_repository`\nto upper layers and use `the_repository` there. The alternative approach\nwould be to try and resolve the dependency on the upper layers and not\nuse `the_repository`. This approach seems much safer. The patches look\ngood to me.\n\nThanks!\n"},{"id":"510119","messageId":"87r05ejpl3.fsf@iotcl.com","threadId":"62650","inReplyTo":"CAOLa=ZTn2vfmS480G2wnaMehoK6+Z7EZ3Wx=ctaaPjBetOkbcA@mail.gmail.com","subject":"Re: [PATCH 00/14] Stop using `the_repository` in some trivial cases","fromName":"Toon Claes","fromEmail":"toon@iotcl.com","sentAt":"2025-01-07T21:12:24Z","receivedAt":"2025-01-07T21:12:38Z","isPatch":true,"sender":{"key":"toon@iotcl.com","avatar":"https://avatars.githubusercontent.com/u/121621?v=4"},"body":"Karthik Nayak <karthik.188@gmail.com> writes:\n\n> I went through half of the patches a week ago, but got back to reading\n> through the series today.\n\nI've also been reading through the whole series today, and the changes\nare trivial and look good to me.\n\n> The approach here is to simply bubble up the usage of `the_repository`\n> to upper layers and use `the_repository` there. The alternative approach\n> would be to try and resolve the dependency on the upper layers and not\n> use `the_repository`. This approach seems much safer. The patches look\n> good to me.\n\nI took me a while to get into the mindset of taking this approach, but\nafter chatting with Patrick I've changed my mind and agree with this\napproach. The goal of this series is to eliminate the use of\n`the_repository` in the mentioned subsystems. Simply bubbling up the use\nof that variable to the callers of those subsystems is very trivial and\nsafe to do.\n\n--\nToon\n"},{"id":"510121","messageId":"xmqqikqqqq9z.fsf@gitster.g","threadId":"62650","inReplyTo":"87r05ejpl3.fsf@iotcl.com","subject":"Re: [PATCH 00/14] Stop using `the_repository` in some trivial cases","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2025-01-07T21:15:36Z","receivedAt":"2025-01-07T21:15:38Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Toon Claes <toon@iotcl.com> writes:\n\n> Karthik Nayak <karthik.188@gmail.com> writes:\n>\n>> I went through half of the patches a week ago, but got back to reading\n>> through the series today.\n>\n> I've also been reading through the whole series today, and the changes\n> are trivial and look good to me.\n>\n>> The approach here is to simply bubble up the usage of `the_repository`\n>> to upper layers and use `the_repository` there. The alternative approach\n>> would be to try and resolve the dependency on the upper layers and not\n>> use `the_repository`. This approach seems much safer. The patches look\n>> good to me.\n>\n> I took me a while to get into the mindset of taking this approach, but\n> after chatting with Patrick I've changed my mind and agree with this\n> approach. The goal of this series is to eliminate the use of\n> `the_repository` in the mentioned subsystems. Simply bubbling up the use\n> of that variable to the callers of those subsystems is very trivial and\n> safe to do.\n\nYup.  That way, the conversion would be bug-to-bug compatible, which\nis much better than a rewrite that improves some parts while by\nmistake breaks the existing code.\n\nThanks, all.  Let's mark it for 'next'.\n"}]}