{"thread":{"id":"65011","subject":"[PATCH 0/5] Avoid the_repository in merge-ort and replay","startedAt":"2026-02-18T09:15:18Z","lastAt":"2026-02-24T10:00:19Z","messageCount":34,"participants":["Elijah Newren via GitGitGadget","Kristoffer Haugsbakk","Patrick Steinhardt","Elijah Newren","Junio C Hamano","Derrick Stolee"],"isPatch":true,"patchVersion":1,"patchTotal":5},"messages":[{"id":"536260","messageId":"pull.2048.git.1771406115.gitgitgadget@gmail.com","threadId":"65011","inReplyTo":null,"subject":"[PATCH 0/5] Avoid the_repository in merge-ort and replay","fromName":"Elijah Newren via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2026-02-18T09:15:10Z","receivedAt":"2026-02-18T09:15:18Z","isPatch":true,"sender":{"key":"newren@gmail.com","avatar":"https://avatars.githubusercontent.com/u/5455730?v=4"},"body":"Remove explicit uses of the_repository and the_hash_algo from merge-ort, and\nsince this has now been done multiple times for both merge-ort and replay,\nimplement a small measure to prevent them from returning to either merge-ort\nor replay.\n\nSee\nhttps://lore.kernel.org/git/CABPp-BH7E1Bh2g0vR3T4NEsv34DvFQPzMuJSsqtOAaWY-fFCxg@mail.gmail.com/\nand\nhttps://lore.kernel.org/git/CABPp-BFuwvqiCTCCpoyT6em9_1-qrgPWHWhrufQ3UuZ+Kfkb6A@mail.gmail.com/\nfor recent discussions on these.\n\nSeries overview: Patches 1-3: Mostly mechanical removal of existing uses\nPatches 4-5: Simple hammer to prevent the problem from returning\n\nElijah Newren (5):\n  merge-ort: pass repository to write_tree()\n  merge-ort: replace the_repository with opt->repo\n  merge-ort: replace the_hash_algo with opt->repo->hash_algo\n  merge-ort: prevent the_repository from coming back\n  replay: prevent the_repository from coming back\n\n merge-ort.c | 92 ++++++++++++++++++++++++++++-------------------------\n replay.c    |  2 ++\n 2 files changed, 51 insertions(+), 43 deletions(-)\n\n\nbase-commit: 73fd77805fc6406f31c36212846d9e2541d19321\nPublished-As: https://github.com/gitgitgadget/git/releases/tag/pr-2048%2Fnewren%2Favoid_the_repository-v1\nFetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-2048/newren/avoid_the_repository-v1\nPull-Request: https://github.com/gitgitgadget/git/pull/2048\n-- \ngitgitgadget\n"},{"id":"536261","messageId":"620c4ea38bc539d87a07e4401f98fbf23be0df5c.1771406115.git.gitgitgadget@gmail.com","threadId":"65011","inReplyTo":"pull.2048.git.1771406115.gitgitgadget@gmail.com","subject":"[PATCH 1/5] merge-ort: pass repository to write_tree()","fromName":"Elijah Newren via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2026-02-18T09:15:11Z","receivedAt":"2026-02-18T09:15:20Z","isPatch":true,"sender":{"key":"newren@gmail.com","avatar":"https://avatars.githubusercontent.com/u/5455730?v=4"},"body":"From: Elijah Newren <newren@gmail.com>\n\nIn order to get rid of a usage of the_repository, we need to know the\nvalue of opt->repo; pass it along to write_tree().  Once we have the\nrepository, though, we no longer need to pass\nopt->repo->hash_algo->rawsz, we can have write_tree() look up that value\nitself.\n\nSigned-off-by: Elijah Newren <newren@gmail.com>\n---\n merge-ort.c | 16 ++++++++--------\n 1 file changed, 8 insertions(+), 8 deletions(-)\n\ndiff --git a/merge-ort.c b/merge-ort.c\nindex 0a59d1e596..42499f7b43 100644\n--- a/merge-ort.c\n+++ b/merge-ort.c\n@@ -3822,15 +3822,16 @@ static int tree_entry_order(const void *a_, const void *b_)\n \t\t\t\t b->string, strlen(b->string), bmi->result.mode);\n }\n \n-static int write_tree(struct object_id *result_oid,\n+static int write_tree(struct repository *repo,\n+\t\t      struct object_id *result_oid,\n \t\t      struct string_list *versions,\n-\t\t      unsigned int offset,\n-\t\t      size_t hash_size)\n+\t\t      unsigned int offset)\n {\n \tsize_t maxlen = 0, extra;\n \tunsigned int nr;\n \tstruct strbuf buf = STRBUF_INIT;\n \tint i, ret = 0;\n+\tsize_t hash_size = repo->hash_algo->rawsz;\n \n \tassert(offset <= versions->nr);\n \tnr = versions->nr - offset;\n@@ -3856,7 +3857,7 @@ static int write_tree(struct object_id *result_oid,\n \t}\n \n \t/* Write this object file out, and record in result_oid */\n-\tif (odb_write_object(the_repository->objects, buf.buf,\n+\tif (odb_write_object(repo->objects, buf.buf,\n \t\t\t     buf.len, OBJ_TREE, result_oid))\n \t\tret = -1;\n \tstrbuf_release(&buf);\n@@ -4026,8 +4027,8 @@ static int write_completed_directory(struct merge_options *opt,\n \t\tdir_info->is_null = 0;\n \t\tdir_info->result.mode = S_IFDIR;\n \t\tif (record_tree &&\n-\t\t    write_tree(&dir_info->result.oid, &info->versions, offset,\n-\t\t\t       opt->repo->hash_algo->rawsz) < 0)\n+\t\t    write_tree(opt->repo, &dir_info->result.oid, &info->versions,\n+\t\t\t       offset) < 0)\n \t\t\tret = -1;\n \t}\n \n@@ -4573,8 +4574,7 @@ static int process_entries(struct merge_options *opt,\n \t\tBUG(\"dir_metadata accounting completely off; shouldn't happen\");\n \t}\n \tif (record_tree &&\n-\t    write_tree(result_oid, &dir_metadata.versions, 0,\n-\t\t       opt->repo->hash_algo->rawsz) < 0)\n+\t    write_tree(opt->repo, result_oid, &dir_metadata.versions, 0) < 0)\n \t\tret = -1;\n cleanup:\n \tstring_list_clear(&plist, 0);\n-- \ngitgitgadget\n\n"},{"id":"536262","messageId":"abba4bd76233d7efb5d876bc14753359944b2d76.1771406115.git.gitgitgadget@gmail.com","threadId":"65011","inReplyTo":"pull.2048.git.1771406115.gitgitgadget@gmail.com","subject":"[PATCH 2/5] merge-ort: replace the_repository with opt->repo","fromName":"Elijah Newren via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2026-02-18T09:15:12Z","receivedAt":"2026-02-18T09:15:21Z","isPatch":true,"sender":{"key":"newren@gmail.com","avatar":"https://avatars.githubusercontent.com/u/5455730?v=4"},"body":"From: Elijah Newren <newren@gmail.com>\n\nWe have a perfectly valid repository available and do not need to use\nthe_repository, except for one location in\nprefetch_for_content_merges().\n\nSigned-off-by: Elijah Newren <newren@gmail.com>\n---\n merge-ort.c | 44 ++++++++++++++++++++++----------------------\n 1 file changed, 22 insertions(+), 22 deletions(-)\n\ndiff --git a/merge-ort.c b/merge-ort.c\nindex 42499f7b43..2106c5f632 100644\n--- a/merge-ort.c\n+++ b/merge-ort.c\n@@ -1732,9 +1732,9 @@ static int collect_merge_info(struct merge_options *opt,\n \tinfo.data = opt;\n \tinfo.show_all_errors = 1;\n \n-\tif (repo_parse_tree(the_repository, merge_base) < 0 ||\n-\t    repo_parse_tree(the_repository, side1) < 0 ||\n-\t    repo_parse_tree(the_repository, side2) < 0)\n+\tif (repo_parse_tree(opt->repo, merge_base) < 0 ||\n+\t    repo_parse_tree(opt->repo, side1) < 0 ||\n+\t    repo_parse_tree(opt->repo, side2) < 0)\n \t\treturn -1;\n \tinit_tree_desc(t + 0, &merge_base->object.oid,\n \t\t       merge_base->buffer, merge_base->size);\n@@ -2136,9 +2136,9 @@ static int merge_3way(struct merge_options *opt,\n \t\tname2 = mkpathdup(\"%s:%s\", opt->branch2,  pathnames[2]);\n \t}\n \n-\tread_mmblob(&orig, the_repository->objects, o);\n-\tread_mmblob(&src1, the_repository->objects, a);\n-\tread_mmblob(&src2, the_repository->objects, b);\n+\tread_mmblob(&orig, opt->repo->objects, o);\n+\tread_mmblob(&src1, opt->repo->objects, a);\n+\tread_mmblob(&src2, opt->repo->objects, b);\n \n \tmerge_status = ll_merge(result_buf, path, &orig, base,\n \t\t\t\t&src1, name1, &src2, name2,\n@@ -2254,7 +2254,7 @@ static int handle_content_merge(struct merge_options *opt,\n \t\t}\n \n \t\tif (!ret && record_object &&\n-\t\t    odb_write_object(the_repository->objects, result_buf.ptr, result_buf.size,\n+\t\t    odb_write_object(opt->repo->objects, result_buf.ptr, result_buf.size,\n \t\t\t\t     OBJ_BLOB, &result->oid)) {\n \t\t\tpath_msg(opt, ERROR_OBJECT_WRITE_FAILED, 0,\n \t\t\t\t pathnames[0], pathnames[1], pathnames[2], NULL,\n@@ -3713,7 +3713,7 @@ static int read_oid_strbuf(struct merge_options *opt,\n \tvoid *buf;\n \tenum object_type type;\n \tunsigned long size;\n-\tbuf = odb_read_object(the_repository->objects, oid, &type, &size);\n+\tbuf = odb_read_object(opt->repo->objects, oid, &type, &size);\n \tif (!buf) {\n \t\tpath_msg(opt, ERROR_OBJECT_READ_FAILED, 0,\n \t\t\t path, NULL, NULL, NULL,\n@@ -4439,7 +4439,7 @@ static void prefetch_for_content_merges(struct merge_options *opt,\n \tstruct string_list_item *e;\n \tstruct oid_array to_fetch = OID_ARRAY_INIT;\n \n-\tif (opt->repo != the_repository || !repo_has_promisor_remote(the_repository))\n+\tif (opt->repo != the_repository || !repo_has_promisor_remote(opt->repo))\n \t\treturn;\n \n \tfor (e = &plist->items[plist->nr-1]; e >= plist->items; --e) {\n@@ -4619,10 +4619,10 @@ static int checkout(struct merge_options *opt,\n \tunpack_opts.verbose_update = (opt->verbosity > 2);\n \tunpack_opts.fn = twoway_merge;\n \tunpack_opts.preserve_ignored = 0; /* FIXME: !opts->overwrite_ignore */\n-\tif (repo_parse_tree(the_repository, prev) < 0)\n+\tif (repo_parse_tree(opt->repo, prev) < 0)\n \t\treturn -1;\n \tinit_tree_desc(&trees[0], &prev->object.oid, prev->buffer, prev->size);\n-\tif (repo_parse_tree(the_repository, next) < 0)\n+\tif (repo_parse_tree(opt->repo, next) < 0)\n \t\treturn -1;\n \tinit_tree_desc(&trees[1], &next->object.oid, next->buffer, next->size);\n \n@@ -5280,7 +5280,7 @@ redo:\n \n \tif (result->clean >= 0) {\n \t\tif (!opt->mergeability_only) {\n-\t\t\tresult->tree = repo_parse_tree_indirect(the_repository,\n+\t\t\tresult->tree = repo_parse_tree_indirect(opt->repo,\n \t\t\t\t\t\t\t\t&working_tree_oid);\n \t\t\tif (!result->tree)\n \t\t\t\tdie(_(\"unable to read tree (%s)\"),\n@@ -5309,7 +5309,7 @@ static void merge_ort_internal(struct merge_options *opt,\n \tstruct strbuf merge_base_abbrev = STRBUF_INIT;\n \n \tif (!merge_bases) {\n-\t\tif (repo_get_merge_bases(the_repository, h1, h2,\n+\t\tif (repo_get_merge_bases(opt->repo, h1, h2,\n \t\t\t\t\t &merge_bases) < 0) {\n \t\t\tresult->clean = -1;\n \t\t\tgoto out;\n@@ -5440,20 +5440,20 @@ static void merge_recursive_config(struct merge_options *opt, int ui)\n {\n \tchar *value = NULL;\n \tint renormalize = 0;\n-\trepo_config_get_int(the_repository, \"merge.verbosity\", &opt->verbosity);\n-\trepo_config_get_int(the_repository, \"diff.renamelimit\", &opt->rename_limit);\n-\trepo_config_get_int(the_repository, \"merge.renamelimit\", &opt->rename_limit);\n-\trepo_config_get_bool(the_repository, \"merge.renormalize\", &renormalize);\n+\trepo_config_get_int(opt->repo, \"merge.verbosity\", &opt->verbosity);\n+\trepo_config_get_int(opt->repo, \"diff.renamelimit\", &opt->rename_limit);\n+\trepo_config_get_int(opt->repo, \"merge.renamelimit\", &opt->rename_limit);\n+\trepo_config_get_bool(opt->repo, \"merge.renormalize\", &renormalize);\n \topt->renormalize = renormalize;\n-\tif (!repo_config_get_string(the_repository, \"diff.renames\", &value)) {\n+\tif (!repo_config_get_string(opt->repo, \"diff.renames\", &value)) {\n \t\topt->detect_renames = git_config_rename(\"diff.renames\", value);\n \t\tfree(value);\n \t}\n-\tif (!repo_config_get_string(the_repository, \"merge.renames\", &value)) {\n+\tif (!repo_config_get_string(opt->repo, \"merge.renames\", &value)) {\n \t\topt->detect_renames = git_config_rename(\"merge.renames\", value);\n \t\tfree(value);\n \t}\n-\tif (!repo_config_get_string(the_repository, \"merge.directoryrenames\", &value)) {\n+\tif (!repo_config_get_string(opt->repo, \"merge.directoryrenames\", &value)) {\n \t\tint boolval = git_parse_maybe_bool(value);\n \t\tif (0 <= boolval) {\n \t\t\topt->detect_directory_renames = boolval ?\n@@ -5466,7 +5466,7 @@ static void merge_recursive_config(struct merge_options *opt, int ui)\n \t\tfree(value);\n \t}\n \tif (ui) {\n-\t\tif (!repo_config_get_string(the_repository, \"diff.algorithm\", &value)) {\n+\t\tif (!repo_config_get_string(opt->repo, \"diff.algorithm\", &value)) {\n \t\t\tlong diff_algorithm = parse_algorithm_value(value);\n \t\t\tif (diff_algorithm < 0)\n \t\t\t\tdie(_(\"unknown value for config '%s': %s\"), \"diff.algorithm\", value);\n@@ -5474,7 +5474,7 @@ static void merge_recursive_config(struct merge_options *opt, int ui)\n \t\t\tfree(value);\n \t\t}\n \t}\n-\trepo_config(the_repository, git_xmerge_config, NULL);\n+\trepo_config(opt->repo, git_xmerge_config, NULL);\n }\n \n static void init_merge_options(struct merge_options *opt,\n-- \ngitgitgadget\n\n"},{"id":"536263","messageId":"36c2713ceb305f17295c4e8b38dbf252dc641128.1771406115.git.gitgitgadget@gmail.com","threadId":"65011","inReplyTo":"pull.2048.git.1771406115.gitgitgadget@gmail.com","subject":"[PATCH 3/5] merge-ort: replace the_hash_algo with opt->repo->hash_algo","fromName":"Elijah Newren via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2026-02-18T09:15:13Z","receivedAt":"2026-02-18T09:15:22Z","isPatch":true,"sender":{"key":"newren@gmail.com","avatar":"https://avatars.githubusercontent.com/u/5455730?v=4"},"body":"From: Elijah Newren <newren@gmail.com>\n\nSigned-off-by: Elijah Newren <newren@gmail.com>\n---\n merge-ort.c | 26 +++++++++++++-------------\n 1 file changed, 13 insertions(+), 13 deletions(-)\n\ndiff --git a/merge-ort.c b/merge-ort.c\nindex 2106c5f632..40a11dca73 100644\n--- a/merge-ort.c\n+++ b/merge-ort.c\n@@ -1857,7 +1857,7 @@ static int merge_submodule(struct merge_options *opt,\n \t\tBUG(\"submodule deleted on one side; this should be handled outside of merge_submodule()\");\n \n \tif ((sub_not_initialized = repo_submodule_init(&subrepo,\n-\t\topt->repo, path, null_oid(the_hash_algo)))) {\n+\t\topt->repo, path, null_oid(opt->repo->hash_algo)))) {\n \t\tpath_msg(opt, CONFLICT_SUBMODULE_NOT_INITIALIZED, 0,\n \t\t\t path, NULL, NULL, NULL,\n \t\t\t _(\"Failed to merge submodule %s (not checked out)\"),\n@@ -2240,7 +2240,7 @@ static int handle_content_merge(struct merge_options *opt,\n \t\ttwo_way = ((S_IFMT & o->mode) != (S_IFMT & a->mode));\n \n \t\tmerge_status = merge_3way(opt, path,\n-\t\t\t\t\t  two_way ? null_oid(the_hash_algo) : &o->oid,\n+\t\t\t\t\t  two_way ? null_oid(opt->repo->hash_algo) : &o->oid,\n \t\t\t\t\t  &a->oid, &b->oid,\n \t\t\t\t\t  pathnames, extra_marker_size,\n \t\t\t\t\t  &result_buf);\n@@ -2272,7 +2272,7 @@ static int handle_content_merge(struct merge_options *opt,\n \t} else if (S_ISGITLINK(a->mode)) {\n \t\tint two_way = ((S_IFMT & o->mode) != (S_IFMT & a->mode));\n \t\tclean = merge_submodule(opt, pathnames[0],\n-\t\t\t\t\ttwo_way ? null_oid(the_hash_algo) : &o->oid,\n+\t\t\t\t\ttwo_way ? null_oid(opt->repo->hash_algo) : &o->oid,\n \t\t\t\t\t&a->oid, &b->oid, &result->oid);\n \t\tif (clean < 0)\n \t\t\treturn -1;\n@@ -2786,7 +2786,7 @@ static void apply_directory_rename_modifications(struct merge_options *opt,\n \t\tassert(!new_ci->match_mask);\n \t\tnew_ci->dirmask = 0;\n \t\tnew_ci->stages[1].mode = 0;\n-\t\toidcpy(&new_ci->stages[1].oid, null_oid(the_hash_algo));\n+\t\toidcpy(&new_ci->stages[1].oid, null_oid(opt->repo->hash_algo));\n \n \t\t/*\n \t\t * Now that we have the file information in new_ci, make sure\n@@ -2799,7 +2799,7 @@ static void apply_directory_rename_modifications(struct merge_options *opt,\n \t\t\t\tcontinue;\n \t\t\t/* zero out any entries related to files */\n \t\t\tci->stages[i].mode = 0;\n-\t\t\toidcpy(&ci->stages[i].oid, null_oid(the_hash_algo));\n+\t\t\toidcpy(&ci->stages[i].oid, null_oid(opt->repo->hash_algo));\n \t\t}\n \n \t\t/* Now we want to focus on new_ci, so reassign ci to it. */\n@@ -3214,7 +3214,7 @@ static int process_renames(struct merge_options *opt,\n \t\t\tif (type_changed) {\n \t\t\t\t/* rename vs. typechange */\n \t\t\t\t/* Mark the original as resolved by removal */\n-\t\t\t\tmemcpy(&oldinfo->stages[0].oid, null_oid(the_hash_algo),\n+\t\t\t\tmemcpy(&oldinfo->stages[0].oid, null_oid(opt->repo->hash_algo),\n \t\t\t\t       sizeof(oldinfo->stages[0].oid));\n \t\t\t\toldinfo->stages[0].mode = 0;\n \t\t\t\toldinfo->filemask &= 0x06;\n@@ -4102,7 +4102,7 @@ static int process_entry(struct merge_options *opt,\n \t\t\tif (ci->filemask & (1 << i))\n \t\t\t\tcontinue;\n \t\t\tci->stages[i].mode = 0;\n-\t\t\toidcpy(&ci->stages[i].oid, null_oid(the_hash_algo));\n+\t\t\toidcpy(&ci->stages[i].oid, null_oid(opt->repo->hash_algo));\n \t\t}\n \t} else if (ci->df_conflict && ci->merged.result.mode != 0) {\n \t\t/*\n@@ -4149,7 +4149,7 @@ static int process_entry(struct merge_options *opt,\n \t\t\t\tcontinue;\n \t\t\t/* zero out any entries related to directories */\n \t\t\tnew_ci->stages[i].mode = 0;\n-\t\t\toidcpy(&new_ci->stages[i].oid, null_oid(the_hash_algo));\n+\t\t\toidcpy(&new_ci->stages[i].oid, null_oid(opt->repo->hash_algo));\n \t\t}\n \n \t\t/*\n@@ -4271,11 +4271,11 @@ static int process_entry(struct merge_options *opt,\n \t\t\tnew_ci->merged.result.mode = ci->stages[2].mode;\n \t\t\toidcpy(&new_ci->merged.result.oid, &ci->stages[2].oid);\n \t\t\tnew_ci->stages[1].mode = 0;\n-\t\t\toidcpy(&new_ci->stages[1].oid, null_oid(the_hash_algo));\n+\t\t\toidcpy(&new_ci->stages[1].oid, null_oid(opt->repo->hash_algo));\n \t\t\tnew_ci->filemask = 5;\n \t\t\tif ((S_IFMT & b_mode) != (S_IFMT & o_mode)) {\n \t\t\t\tnew_ci->stages[0].mode = 0;\n-\t\t\t\toidcpy(&new_ci->stages[0].oid, null_oid(the_hash_algo));\n+\t\t\t\toidcpy(&new_ci->stages[0].oid, null_oid(opt->repo->hash_algo));\n \t\t\t\tnew_ci->filemask = 4;\n \t\t\t}\n \n@@ -4283,11 +4283,11 @@ static int process_entry(struct merge_options *opt,\n \t\t\tci->merged.result.mode = ci->stages[1].mode;\n \t\t\toidcpy(&ci->merged.result.oid, &ci->stages[1].oid);\n \t\t\tci->stages[2].mode = 0;\n-\t\t\toidcpy(&ci->stages[2].oid, null_oid(the_hash_algo));\n+\t\t\toidcpy(&ci->stages[2].oid, null_oid(opt->repo->hash_algo));\n \t\t\tci->filemask = 3;\n \t\t\tif ((S_IFMT & a_mode) != (S_IFMT & o_mode)) {\n \t\t\t\tci->stages[0].mode = 0;\n-\t\t\t\toidcpy(&ci->stages[0].oid, null_oid(the_hash_algo));\n+\t\t\t\toidcpy(&ci->stages[0].oid, null_oid(opt->repo->hash_algo));\n \t\t\t\tci->filemask = 2;\n \t\t\t}\n \n@@ -4415,7 +4415,7 @@ static int process_entry(struct merge_options *opt,\n \t\t/* Deleted on both sides */\n \t\tci->merged.is_null = 1;\n \t\tci->merged.result.mode = 0;\n-\t\toidcpy(&ci->merged.result.oid, null_oid(the_hash_algo));\n+\t\toidcpy(&ci->merged.result.oid, null_oid(opt->repo->hash_algo));\n \t\tassert(!ci->df_conflict);\n \t\tci->merged.clean = !ci->path_conflict;\n \t}\n-- \ngitgitgadget\n\n"},{"id":"536264","messageId":"46c24e0d05a91f830e400914a7e446afab320859.1771406115.git.gitgitgadget@gmail.com","threadId":"65011","inReplyTo":"pull.2048.git.1771406115.gitgitgadget@gmail.com","subject":"[PATCH 4/5] merge-ort: prevent the_repository from coming back","fromName":"Elijah Newren via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2026-02-18T09:15:14Z","receivedAt":"2026-02-18T09:15:24Z","isPatch":true,"sender":{"key":"newren@gmail.com","avatar":"https://avatars.githubusercontent.com/u/5455730?v=4"},"body":"From: Elijah Newren <newren@gmail.com>\n\nThere are two things preventing us from removing our usage of\nUSE_THE_REPOSITORY_VARIABLE: one necessary use of the_repository in\nprefetch_for_content_merges(), and the use of DEFAULT_ABBREV.  We have\nremoved all other uses of the_repository in merge-ort before (multiple\ntimes), but without removing that definition, they keep coming back.\n\nDefine the_repository to make it a compilation error so that they don't\ncome back any more, with a special carve-out for\nprefetch_for_content_merges().\n\nSigned-off-by: Elijah Newren <newren@gmail.com>\n---\n merge-ort.c | 6 ++++++\n 1 file changed, 6 insertions(+)\n\ndiff --git a/merge-ort.c b/merge-ort.c\nindex 40a11dca73..ae19118550 100644\n--- a/merge-ort.c\n+++ b/merge-ort.c\n@@ -53,6 +53,8 @@\n #include \"unpack-trees.h\"\n #include \"xdiff-interface.h\"\n \n+#define the_repository DO_NOT_USE_THE_REPOSITORY\n+\n /*\n  * We have many arrays of size 3.  Whenever we have such an array, the\n  * indices refer to one of the sides of the three-way merge.  This is so\n@@ -4433,6 +4435,8 @@ static int process_entry(struct merge_options *opt,\n \treturn 0;\n }\n \n+#undef the_repository\n+\n static void prefetch_for_content_merges(struct merge_options *opt,\n \t\t\t\t\tstruct string_list *plist)\n {\n@@ -4481,6 +4485,8 @@ static void prefetch_for_content_merges(struct merge_options *opt,\n \toid_array_clear(&to_fetch);\n }\n \n+#define the_repository DO_NOT_USE_the_repository\n+\n static int process_entries(struct merge_options *opt,\n \t\t\t   struct object_id *result_oid)\n {\n-- \ngitgitgadget\n\n"},{"id":"536265","messageId":"d75a71aef97701e476dc8e9c662620e20cc5b17b.1771406115.git.gitgitgadget@gmail.com","threadId":"65011","inReplyTo":"pull.2048.git.1771406115.gitgitgadget@gmail.com","subject":"[PATCH 5/5] replay: prevent the_repository from coming back","fromName":"Elijah Newren via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2026-02-18T09:15:15Z","receivedAt":"2026-02-18T09:15:26Z","isPatch":true,"sender":{"key":"newren@gmail.com","avatar":"https://avatars.githubusercontent.com/u/5455730?v=4"},"body":"From: Elijah Newren <newren@gmail.com>\n\nDue to the use of DEFAULT_ABBREV, we cannot get rid of our usage of\nUSE_THE_REPOSITORY_VARIABLE.  We have removed all other uses of\nthe_repository before, but without removing that definition, they keep\ncoming back.\n\nDefine the_repository to make it a compilation error so that they don't\ncome back any more.\n\nSigned-off-by: Elijah Newren <newren@gmail.com>\n---\n replay.c | 2 ++\n 1 file changed, 2 insertions(+)\n\ndiff --git a/replay.c b/replay.c\nindex f97d652f33..a962f53d03 100644\n--- a/replay.c\n+++ b/replay.c\n@@ -11,6 +11,8 @@\n #include \"strmap.h\"\n #include \"tree.h\"\n \n+#define the_repository DO_NOT_USE_THE_REPOSITORY\n+\n static const char *short_commit_name(struct repository *repo,\n \t\t\t\t     struct commit *commit)\n {\n-- \ngitgitgadget\n"},{"id":"536392","messageId":"8ac118b7-2d39-4a0c-9a61-d0c7b045b231@app.fastmail.com","threadId":"65011","inReplyTo":"46c24e0d05a91f830e400914a7e446afab320859.1771406115.git.gitgitgadget@gmail.com","subject":"Re: [PATCH 4/5] merge-ort: prevent the_repository from coming back","fromName":"Kristoffer Haugsbakk","fromEmail":"kristofferhaugsbakk@fastmail.com","sentAt":"2026-02-19T09:48:06Z","receivedAt":"2026-02-19T09:48:28Z","isPatch":true,"sender":{"key":"kristofferhaugsbakk@fastmail.com","avatar":null},"body":"On Wed, Feb 18, 2026, at 10:15, Elijah Newren via GitGitGadget wrote:\n> From: Elijah Newren <newren@gmail.com>\n>\n> There are two things preventing us from removing our usage of\n> USE_THE_REPOSITORY_VARIABLE: one necessary use of the_repository in\n> prefetch_for_content_merges(), and the use of DEFAULT_ABBREV.  We have\n> removed all other uses of the_repository in merge-ort before (multiple\n> times), but without removing that definition, they keep coming back.\n>\n> Define the_repository to make it a compilation error so that they don't\n> come back any more, with a special carve-out for\n> prefetch_for_content_merges().\n>\n> Signed-off-by: Elijah Newren <newren@gmail.com>\n> ---\n>[snip]\n> +#define the_repository DO_NOT_USE_THE_REPOSITORY\n> +\n>[snip]\n> +#define the_repository DO_NOT_USE_the_repository\n\nHere the casing is different?\n\n> +\n>  static int process_entries(struct merge_options *opt,\n>  \t\t\t   struct object_id *result_oid)\n>  {\n"},{"id":"536415","messageId":"aZcr58Dd5JPngow9@pks.im","threadId":"65011","inReplyTo":"36c2713ceb305f17295c4e8b38dbf252dc641128.1771406115.git.gitgitgadget@gmail.com","subject":"Re: [PATCH 3/5] merge-ort: replace the_hash_algo with opt->repo->hash_algo","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2026-02-19T15:27:35Z","receivedAt":"2026-02-19T15:27:42Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"On Wed, Feb 18, 2026 at 09:15:13AM +0000, Elijah Newren via GitGitGadget wrote:\n> From: Elijah Newren <newren@gmail.com>\n\nNit: might make sense to have at least a oneliner here to explain what\nwe're doing, even if the subject already says it all.\n\nPatrick\n"},{"id":"536416","messageId":"aZcr7DiIteTS9udR@pks.im","threadId":"65011","inReplyTo":"46c24e0d05a91f830e400914a7e446afab320859.1771406115.git.gitgitgadget@gmail.com","subject":"Re: [PATCH 4/5] merge-ort: prevent the_repository from coming back","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2026-02-19T15:27:40Z","receivedAt":"2026-02-19T15:27:45Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"On Wed, Feb 18, 2026 at 09:15:14AM +0000, Elijah Newren via GitGitGadget wrote:\n> From: Elijah Newren <newren@gmail.com>\n> \n> There are two things preventing us from removing our usage of\n> USE_THE_REPOSITORY_VARIABLE: one necessary use of the_repository in\n> prefetch_for_content_merges(), and the use of DEFAULT_ABBREV.  We have\n> removed all other uses of the_repository in merge-ort before (multiple\n> times), but without removing that definition, they keep coming back.\n\nUnfortunate, but I think it's okay to be pragmatic here.\n\n> diff --git a/merge-ort.c b/merge-ort.c\n> index 40a11dca73..ae19118550 100644\n> --- a/merge-ort.c\n> +++ b/merge-ort.c\n> @@ -53,6 +53,8 @@\n>  #include \"unpack-trees.h\"\n>  #include \"xdiff-interface.h\"\n>  \n> +#define the_repository DO_NOT_USE_THE_REPOSITORY\n\nDo we want to have a comment here that explains why we do this dance?\n\nPatrick\n"},{"id":"536417","messageId":"aZcr89rBhJZ4F8XN@pks.im","threadId":"65011","inReplyTo":"d75a71aef97701e476dc8e9c662620e20cc5b17b.1771406115.git.gitgitgadget@gmail.com","subject":"Re: [PATCH 5/5] replay: prevent the_repository from coming back","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2026-02-19T15:27:47Z","receivedAt":"2026-02-19T15:27:52Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"On Wed, Feb 18, 2026 at 09:15:15AM +0000, Elijah Newren via GitGitGadget wrote:\n> diff --git a/replay.c b/replay.c\n> index f97d652f33..a962f53d03 100644\n> --- a/replay.c\n> +++ b/replay.c\n> @@ -11,6 +11,8 @@\n>  #include \"strmap.h\"\n>  #include \"tree.h\"\n>  \n> +#define the_repository DO_NOT_USE_THE_REPOSITORY\n\nSame remark here: might make sense to add a comment here to explain\nwhat's going on.\n\nOther than that the series is a welcome cleanup, thanks!\n\nPatrick\n"},{"id":"536419","messageId":"CABPp-BHiLxeH1Aw0Ag9voQfYghSW5B80R21TZURAX5eP+mj2AQ@mail.gmail.com","threadId":"65011","inReplyTo":"8ac118b7-2d39-4a0c-9a61-d0c7b045b231@app.fastmail.com","subject":"Re: [PATCH 4/5] merge-ort: prevent the_repository from coming back","fromName":"Elijah Newren","fromEmail":"newren@gmail.com","sentAt":"2026-02-19T16:00:00Z","receivedAt":"2026-02-19T16:00:40Z","isPatch":true,"sender":{"key":"newren@gmail.com","avatar":"https://avatars.githubusercontent.com/u/5455730?v=4"},"body":"On Thu, Feb 19, 2026 at 1:48 AM Kristoffer Haugsbakk\n<kristofferhaugsbakk@fastmail.com> wrote:\n>\n> On Wed, Feb 18, 2026, at 10:15, Elijah Newren via GitGitGadget wrote:\n> > From: Elijah Newren <newren@gmail.com>\n> >\n> > There are two things preventing us from removing our usage of\n> > USE_THE_REPOSITORY_VARIABLE: one necessary use of the_repository in\n> > prefetch_for_content_merges(), and the use of DEFAULT_ABBREV.  We have\n> > removed all other uses of the_repository in merge-ort before (multiple\n> > times), but without removing that definition, they keep coming back.\n> >\n> > Define the_repository to make it a compilation error so that they don't\n> > come back any more, with a special carve-out for\n> > prefetch_for_content_merges().\n> >\n> > Signed-off-by: Elijah Newren <newren@gmail.com>\n> > ---\n> >[snip]\n> > +#define the_repository DO_NOT_USE_THE_REPOSITORY\n> > +\n> >[snip]\n> > +#define the_repository DO_NOT_USE_the_repository\n>\n> Here the casing is different?\n\nOops.  Will fix; thanks for taking a look.\n"},{"id":"536423","messageId":"CABPp-BFto4512vNeVs=OWpaqV4AH4NQ+_TAdSF3vDiuWMSGqQg@mail.gmail.com","threadId":"65011","inReplyTo":"aZcr58Dd5JPngow9@pks.im","subject":"Re: [PATCH 3/5] merge-ort: replace the_hash_algo with opt->repo->hash_algo","fromName":"Elijah Newren","fromEmail":"newren@gmail.com","sentAt":"2026-02-19T17:54:52Z","receivedAt":"2026-02-19T17:55:05Z","isPatch":true,"sender":{"key":"newren@gmail.com","avatar":"https://avatars.githubusercontent.com/u/5455730?v=4"},"body":"On Thu, Feb 19, 2026 at 7:27 AM Patrick Steinhardt <ps@pks.im> wrote:\n>\n> On Wed, Feb 18, 2026 at 09:15:13AM +0000, Elijah Newren via GitGitGadget wrote:\n> > From: Elijah Newren <newren@gmail.com>\n>\n> Nit: might make sense to have at least a oneliner here to explain what\n> we're doing, even if the subject already says it all.\n\nFair enough; will do.\n"},{"id":"536430","messageId":"CABPp-BF5jLfsndbinaPO_18fxvdUuVOYC8j31==jMXwK6iP0QA@mail.gmail.com","threadId":"65011","inReplyTo":"aZcr7DiIteTS9udR@pks.im","subject":"Re: [PATCH 4/5] merge-ort: prevent the_repository from coming back","fromName":"Elijah Newren","fromEmail":"newren@gmail.com","sentAt":"2026-02-19T18:42:28Z","receivedAt":"2026-02-19T18:42:41Z","isPatch":true,"sender":{"key":"newren@gmail.com","avatar":"https://avatars.githubusercontent.com/u/5455730?v=4"},"body":"On Thu, Feb 19, 2026 at 7:27 AM Patrick Steinhardt <ps@pks.im> wrote:\n>\n> On Wed, Feb 18, 2026 at 09:15:14AM +0000, Elijah Newren via GitGitGadget wrote:\n> > From: Elijah Newren <newren@gmail.com>\n> >\n> > There are two things preventing us from removing our usage of\n> > USE_THE_REPOSITORY_VARIABLE: one necessary use of the_repository in\n> > prefetch_for_content_merges(), and the use of DEFAULT_ABBREV.  We have\n> > removed all other uses of the_repository in merge-ort before (multiple\n> > times), but without removing that definition, they keep coming back.\n>\n> Unfortunate, but I think it's okay to be pragmatic here.\n\nYeah, also full disclosure: I do not know why\nprefetch_for_content_merges() needs to use the_repository.  When I\nintroduced it back in 2bff554b23e8 (merge-ort: add prefetching for\ncontent merges, 2021-06-22), I was just looking at diffcore_std() and\ntrying to mimic how it did the prefetch.  I don't actually understand\nwhy the comparison against the_repository is there for either of these\nfunctions.  Maybe someone else knows and could shed some light?  (cc:\nJonathan Tan for the diffcore_std() case I was copying from...)\n\n> > diff --git a/merge-ort.c b/merge-ort.c\n> > index 40a11dca73..ae19118550 100644\n> > --- a/merge-ort.c\n> > +++ b/merge-ort.c\n> > @@ -53,6 +53,8 @@\n> >  #include \"unpack-trees.h\"\n> >  #include \"xdiff-interface.h\"\n> >\n> > +#define the_repository DO_NOT_USE_THE_REPOSITORY\n>\n> Do we want to have a comment here that explains why we do this dance?\n\nSure, will do.\n"},{"id":"536438","messageId":"xmqq8qco4gsv.fsf@gitster.g","threadId":"65011","inReplyTo":"CABPp-BF5jLfsndbinaPO_18fxvdUuVOYC8j31==jMXwK6iP0QA@mail.gmail.com","subject":"Re: [PATCH 4/5] merge-ort: prevent the_repository from coming back","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2026-02-19T20:30:40Z","receivedAt":"2026-02-19T20:30:43Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Elijah Newren <newren@gmail.com> writes:\n\n> Yeah, also full disclosure: I do not know why\n> prefetch_for_content_merges() needs to use the_repository.  When I\n> introduced it back in 2bff554b23e8 (merge-ort: add prefetching for\n> content merges, 2021-06-22), I was just looking at diffcore_std() and\n> trying to mimic how it did the prefetch.  I don't actually understand\n> why the comparison against the_repository is there for either of these\n> functions.  Maybe someone else knows and could shed some light?  (cc:\n> Jonathan Tan for the diffcore_std() case I was copying from...)\n\nI did a bit of digging for you ;-)\n\nThe comparison with the_repository is from 7fbbcb21 (diff: batch\nfetching of missing blobs, 2019-04-05), whose original version did\nnot have it, but was later amended with\n\n  https://lore.kernel.org/git/20190405170934.20441-1-jonathantanmy@google.com/\n\nAnd after that it survived across evolutions like b14ed5ad (Use\npromisor_remote_get_direct() and has_promisor_remote(), 2019-06-25),\n95acf11a (diff: restrict when prefetching occurs, 2020-04-07), and\nfinally a5183d76 (cocci: apply the \"promisor-remote.h\" part of\n\"the_repository.pending\", 2023-03-28).\n"},{"id":"536441","messageId":"CABPp-BG94fTEhQbUy==OYiGrbQH+Tqt+GPiP6TynUCNPMP2y6g@mail.gmail.com","threadId":"65011","inReplyTo":"xmqq8qco4gsv.fsf@gitster.g","subject":"Re: [PATCH 4/5] merge-ort: prevent the_repository from coming back","fromName":"Elijah Newren","fromEmail":"newren@gmail.com","sentAt":"2026-02-19T20:53:29Z","receivedAt":"2026-02-19T20:53:42Z","isPatch":true,"sender":{"key":"newren@gmail.com","avatar":"https://avatars.githubusercontent.com/u/5455730?v=4"},"body":"On Thu, Feb 19, 2026 at 12:30 PM Junio C Hamano <gitster@pobox.com> wrote:\n>\n> Elijah Newren <newren@gmail.com> writes:\n>\n> > Yeah, also full disclosure: I do not know why\n> > prefetch_for_content_merges() needs to use the_repository.  When I\n> > introduced it back in 2bff554b23e8 (merge-ort: add prefetching for\n> > content merges, 2021-06-22), I was just looking at diffcore_std() and\n> > trying to mimic how it did the prefetch.  I don't actually understand\n> > why the comparison against the_repository is there for either of these\n> > functions.  Maybe someone else knows and could shed some light?  (cc:\n> > Jonathan Tan for the diffcore_std() case I was copying from...)\n>\n> I did a bit of digging for you ;-)\n\nThanks!\n\n> The comparison with the_repository is from 7fbbcb21 (diff: batch\n> fetching of missing blobs, 2019-04-05), whose original version did\n> not have it, but was later amended with\n>\n>   https://lore.kernel.org/git/20190405170934.20441-1-jonathantanmy@google.com/\n\nAh, the explanation in that email doesn't exist inside the commit\nhistory, since the diff was squashed in and the relevant part of the\nexplanation wasn't added to the commit message.  I should have thought\nto check the mail archives too.  Anyway, the important bit is:\n\n> Also, prefetch only if the repository being diffed\n> is the_repository (because we do not support lazy fetching for any other\n> repository anyway).\n\nThis comment came from mid-2019.  I then copied the logic from\ndiffcore_std() in 2020 (though didn't get the relevant patch upstream\nuntil 2021), and as of 2021 we have ef830cc43412 (promisor-remote:\nteach lazy-fetch in any repo, 2021-06-17), which means that this check\nhas been obsoleted by events.  And it looks like the check in\ndiffcore_std() was left in place as an oversight as well.\n\nSo, we don't need that check anymore.  I'll add a commit that simply\nremoves these checks from both merge-ort.c and diff.c and reduces two\nmore uses of the_repository.\n"},{"id":"536450","messageId":"pull.2048.v2.git.1771552788.gitgitgadget@gmail.com","threadId":"65011","inReplyTo":"pull.2048.git.1771406115.gitgitgadget@gmail.com","subject":"[PATCH v2 0/6] Avoid the_repository in merge-ort and replay","fromName":"Elijah Newren via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2026-02-20T01:59:42Z","receivedAt":"2026-02-20T01:59:51Z","isPatch":true,"sender":{"key":"newren@gmail.com","avatar":"https://avatars.githubusercontent.com/u/5455730?v=4"},"body":"Changes since v1:\n\n * Add a preparatory patch removing the_repository check from blob\n   prefetching in both merge-ort and diff*; it's no longer necessary\n * Fix casing mismatch\n * Simplify the hammer a bit based on the new first patch, but add some\n   simple comments explaining it\n\nRemove explicit uses of the_repository and the_hash_algo from merge-ort, and\nsince this has now been done multiple times for both merge-ort and replay,\nimplement a small measure to prevent them from returning to either merge-ort\nor replay.\n\nSee\nhttps://lore.kernel.org/git/CABPp-BH7E1Bh2g0vR3T4NEsv34DvFQPzMuJSsqtOAaWY-fFCxg@mail.gmail.com/\nand\nhttps://lore.kernel.org/git/CABPp-BFuwvqiCTCCpoyT6em9_1-qrgPWHWhrufQ3UuZ+Kfkb6A@mail.gmail.com/\nfor recent discussions on these.\n\nAs noted in the comments on v1, I actually do not know why\nprefetch_for_content_merges() needs to use the_repository. When I introduced\nit back in 2bff554b23e8 (merge-ort: add prefetching for content merges,\n2021-06-22), I was just looking at diffcore_std() and trying to mimic how it\ndid the prefetch, and it has such a comparison. If anyone knows why\ndiffcore_std() needs to compare against the_repository, I'd love to hear...\n\nSeries overview: Patches 1-3: Mostly mechanical removal of existing uses\nPatches 4-5: Simple hammer to prevent the problem from returning\n\nElijah Newren (6):\n  merge,diff: remove the_repository check before prefetching blobs\n  merge-ort: pass repository to write_tree()\n  merge-ort: replace the_repository with opt->repo\n  merge-ort: replace the_hash_algo with opt->repo->hash_algo\n  merge-ort: prevent the_repository from coming back\n  replay: prevent the_repository from coming back\n\n diff.c            |  2 +-\n diffcore-break.c  |  2 +-\n diffcore-rename.c |  4 +-\n merge-ort.c       | 94 +++++++++++++++++++++++++----------------------\n replay.c          |  6 +++\n 5 files changed, 61 insertions(+), 47 deletions(-)\n\n\nbase-commit: 73fd77805fc6406f31c36212846d9e2541d19321\nPublished-As: https://github.com/gitgitgadget/git/releases/tag/pr-2048%2Fnewren%2Favoid_the_repository-v2\nFetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-2048/newren/avoid_the_repository-v2\nPull-Request: https://github.com/gitgitgadget/git/pull/2048\n\nRange-diff vs v1:\n\n -:  ---------- > 1:  7155a0da6f merge,diff: remove the_repository check before prefetching blobs\n 1:  620c4ea38b = 2:  911cba991b merge-ort: pass repository to write_tree()\n 2:  abba4bd762 ! 3:  68af47ed18 merge-ort: replace the_repository with opt->repo\n     @@ merge-ort.c: static void prefetch_for_content_merges(struct merge_options *opt,\n       \tstruct string_list_item *e;\n       \tstruct oid_array to_fetch = OID_ARRAY_INIT;\n       \n     --\tif (opt->repo != the_repository || !repo_has_promisor_remote(the_repository))\n     -+\tif (opt->repo != the_repository || !repo_has_promisor_remote(opt->repo))\n     +-\tif (!repo_has_promisor_remote(the_repository))\n     ++\tif (!repo_has_promisor_remote(opt->repo))\n       \t\treturn;\n       \n       \tfor (e = &plist->items[plist->nr-1]; e >= plist->items; --e) {\n 3:  36c2713ceb ! 4:  bfa68716af merge-ort: replace the_hash_algo with opt->repo->hash_algo\n     @@ Metadata\n       ## Commit message ##\n          merge-ort: replace the_hash_algo with opt->repo->hash_algo\n      \n     +    We have a perfectly valid repository available and do not need to use\n     +    the_hash_algo (a shorthand for the_repository->hash_algo), so use the\n     +    known repository instead.\n     +\n          Signed-off-by: Elijah Newren <newren@gmail.com>\n      \n       ## merge-ort.c ##\n 4:  46c24e0d05 ! 5:  932d945c9b merge-ort: prevent the_repository from coming back\n     @@ Metadata\n       ## Commit message ##\n          merge-ort: prevent the_repository from coming back\n      \n     -    There are two things preventing us from removing our usage of\n     -    USE_THE_REPOSITORY_VARIABLE: one necessary use of the_repository in\n     -    prefetch_for_content_merges(), and the use of DEFAULT_ABBREV.  We have\n     -    removed all other uses of the_repository in merge-ort before (multiple\n     -    times), but without removing that definition, they keep coming back.\n     +    Due to the use of DEFAULT_ABBREV, we cannot get rid of our usage of\n     +    USE_THE_REPOSITORY_VARIABLE.  However, we have removed all other uses of\n     +    the_repository in merge-ort a few times.  But they keep coming back.\n      \n          Define the_repository to make it a compilation error so that they don't\n     -    come back any more, with a special carve-out for\n     -    prefetch_for_content_merges().\n     +    come back any more.\n      \n          Signed-off-by: Elijah Newren <newren@gmail.com>\n      \n     @@ merge-ort.c\n       #include \"unpack-trees.h\"\n       #include \"xdiff-interface.h\"\n       \n     ++/*\n     ++ * We technically need USE_THE_REPOSITORY_VARIABLE above for DEFAULT_ABBREV,\n     ++ * but do not want more uses of the_repository.  Prevent them.\n     ++ *\n     ++ * opt->repo is available; use it instead.\n     ++ */\n      +#define the_repository DO_NOT_USE_THE_REPOSITORY\n      +\n       /*\n        * We have many arrays of size 3.  Whenever we have such an array, the\n        * indices refer to one of the sides of the three-way merge.  This is so\n     -@@ merge-ort.c: static int process_entry(struct merge_options *opt,\n     - \treturn 0;\n     - }\n     - \n     -+#undef the_repository\n     -+\n     - static void prefetch_for_content_merges(struct merge_options *opt,\n     - \t\t\t\t\tstruct string_list *plist)\n     - {\n     -@@ merge-ort.c: static void prefetch_for_content_merges(struct merge_options *opt,\n     - \toid_array_clear(&to_fetch);\n     - }\n     - \n     -+#define the_repository DO_NOT_USE_the_repository\n     -+\n     - static int process_entries(struct merge_options *opt,\n     - \t\t\t   struct object_id *result_oid)\n     - {\n 5:  d75a71aef9 ! 6:  67db46f34f replay: prevent the_repository from coming back\n     @@ replay.c\n       #include \"strmap.h\"\n       #include \"tree.h\"\n       \n     ++/*\n     ++ * We technically need USE_THE_REPOSITORY_VARIABLE for DEFAULT_ABBREV, but\n     ++ * do not want to use the_repository.\n     ++ */\n      +#define the_repository DO_NOT_USE_THE_REPOSITORY\n      +\n       static const char *short_commit_name(struct repository *repo,\n\n-- \ngitgitgadget\n"},{"id":"536451","messageId":"7155a0da6f8bcdac90cf1ed085622f2c8b68675e.1771552788.git.gitgitgadget@gmail.com","threadId":"65011","inReplyTo":"pull.2048.v2.git.1771552788.gitgitgadget@gmail.com","subject":"[PATCH v2 1/6] merge,diff: remove the_repository check before prefetching blobs","fromName":"Elijah Newren via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2026-02-20T01:59:43Z","receivedAt":"2026-02-20T01:59:52Z","isPatch":true,"sender":{"key":"newren@gmail.com","avatar":"https://avatars.githubusercontent.com/u/5455730?v=4"},"body":"From: Elijah Newren <newren@gmail.com>\n\nPrefetching of blobs from promisor remotes was added to diff in\n7fbbcb21b162 (diff: batch fetching of missing blobs, 2019-04-05).  In\nthat commit,\n\n  https://lore.kernel.org/git/20190405170934.20441-1-jonathantanmy@google.com/\n\nwas squashed into\n\n  https://lore.kernel.org/git/44de02e584f449481e6fb00cf35d74adf0192e9d.1553895166.git.jonathantanmy@google.com/\n\nwithout the extra explanation about the squashed changes being added to\nthe commit message; in particular, this explanation from that first link\nis absent:\n\n> Also, prefetch only if the repository being diffed is the_repository\n> (because we do not support lazy fetching for any other repository\n>  anyway).\n\nThen, later, this checking was spread from diff.c to diffcore-rename.c\nand diffcore-break.c by 95acf11a3dc3 (diff: restrict when prefetching\noccurs, 2020-04-07) and then further split in d331dd3b0c82\n(diffcore-rename: allow different missing_object_cb functions,\n2021-06-22).  I also copied the logic from prefetching blobs from\ndiff.c to merge-ort.c in 2bff554b23e8 (merge-ort: add prefetching for\ncontent merges, 2021-06-22).\n\nThe reason for all these checks was noted above -- we only supported\nlazy fetching for the_repository.  However, that changed with\nef830cc43412 (promisor-remote: teach lazy-fetch in any repo,\n2021-06-17), so these checks are now unnecessary.  Remove them.\n\nSigned-off-by: Elijah Newren <newren@gmail.com>\n---\n diff.c            | 2 +-\n diffcore-break.c  | 2 +-\n diffcore-rename.c | 4 ++--\n merge-ort.c       | 2 +-\n 4 files changed, 5 insertions(+), 5 deletions(-)\n\ndiff --git a/diff.c b/diff.c\nindex 35b903a9a0..91d81f66ad 100644\n--- a/diff.c\n+++ b/diff.c\n@@ -7176,7 +7176,7 @@ void diffcore_std(struct diff_options *options)\n \t * If no prefetching occurs, diffcore_rename() will prefetch if it\n \t * decides that it needs inexact rename detection.\n \t */\n-\tif (options->repo == the_repository && repo_has_promisor_remote(the_repository) &&\n+\tif (repo_has_promisor_remote(the_repository) &&\n \t    (options->output_format & output_formats_to_prefetch ||\n \t     options->pickaxe_opts & DIFF_PICKAXE_KINDS_MASK))\n \t\tdiff_queued_diff_prefetch(options->repo);\ndiff --git a/diffcore-break.c b/diffcore-break.c\nindex c4c2173f30..5ce227ba22 100644\n--- a/diffcore-break.c\n+++ b/diffcore-break.c\n@@ -69,7 +69,7 @@ static int should_break(struct repository *r,\n \t    oideq(&src->oid, &dst->oid))\n \t\treturn 0; /* they are the same */\n \n-\tif (r == the_repository && repo_has_promisor_remote(the_repository)) {\n+\tif (repo_has_promisor_remote(the_repository)) {\n \t\toptions.missing_object_cb = diff_queued_diff_prefetch;\n \t\toptions.missing_object_data = r;\n \t}\ndiff --git a/diffcore-rename.c b/diffcore-rename.c\nindex d9476db35a..072752954e 100644\n--- a/diffcore-rename.c\n+++ b/diffcore-rename.c\n@@ -987,7 +987,7 @@ static int find_basename_matches(struct diff_options *options,\n \t\t\tstrintmap_set(&dests, base, i);\n \t}\n \n-\tif (options->repo == the_repository && repo_has_promisor_remote(the_repository)) {\n+\tif (repo_has_promisor_remote(the_repository)) {\n \t\tdpf_options.missing_object_cb = basename_prefetch;\n \t\tdpf_options.missing_object_data = &prefetch_options;\n \t}\n@@ -1574,7 +1574,7 @@ void diffcore_rename_extended(struct diff_options *options,\n \n \t/* Finish setting up dpf_options */\n \tprefetch_options.skip_unmodified = skip_unmodified;\n-\tif (options->repo == the_repository && repo_has_promisor_remote(the_repository)) {\n+\tif (repo_has_promisor_remote(the_repository)) {\n \t\tdpf_options.missing_object_cb = inexact_prefetch;\n \t\tdpf_options.missing_object_data = &prefetch_options;\n \t}\ndiff --git a/merge-ort.c b/merge-ort.c\nindex 0a59d1e596..593e3a2087 100644\n--- a/merge-ort.c\n+++ b/merge-ort.c\n@@ -4438,7 +4438,7 @@ static void prefetch_for_content_merges(struct merge_options *opt,\n \tstruct string_list_item *e;\n \tstruct oid_array to_fetch = OID_ARRAY_INIT;\n \n-\tif (opt->repo != the_repository || !repo_has_promisor_remote(the_repository))\n+\tif (!repo_has_promisor_remote(the_repository))\n \t\treturn;\n \n \tfor (e = &plist->items[plist->nr-1]; e >= plist->items; --e) {\n-- \ngitgitgadget\n\n"},{"id":"536452","messageId":"911cba991b0017aa3723961c7db73fafd6031b15.1771552788.git.gitgitgadget@gmail.com","threadId":"65011","inReplyTo":"pull.2048.v2.git.1771552788.gitgitgadget@gmail.com","subject":"[PATCH v2 2/6] merge-ort: pass repository to write_tree()","fromName":"Elijah Newren via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2026-02-20T01:59:44Z","receivedAt":"2026-02-20T01:59:53Z","isPatch":true,"sender":{"key":"newren@gmail.com","avatar":"https://avatars.githubusercontent.com/u/5455730?v=4"},"body":"From: Elijah Newren <newren@gmail.com>\n\nIn order to get rid of a usage of the_repository, we need to know the\nvalue of opt->repo; pass it along to write_tree().  Once we have the\nrepository, though, we no longer need to pass\nopt->repo->hash_algo->rawsz, we can have write_tree() look up that value\nitself.\n\nSigned-off-by: Elijah Newren <newren@gmail.com>\n---\n merge-ort.c | 16 ++++++++--------\n 1 file changed, 8 insertions(+), 8 deletions(-)\n\ndiff --git a/merge-ort.c b/merge-ort.c\nindex 593e3a2087..3535fc676f 100644\n--- a/merge-ort.c\n+++ b/merge-ort.c\n@@ -3822,15 +3822,16 @@ static int tree_entry_order(const void *a_, const void *b_)\n \t\t\t\t b->string, strlen(b->string), bmi->result.mode);\n }\n \n-static int write_tree(struct object_id *result_oid,\n+static int write_tree(struct repository *repo,\n+\t\t      struct object_id *result_oid,\n \t\t      struct string_list *versions,\n-\t\t      unsigned int offset,\n-\t\t      size_t hash_size)\n+\t\t      unsigned int offset)\n {\n \tsize_t maxlen = 0, extra;\n \tunsigned int nr;\n \tstruct strbuf buf = STRBUF_INIT;\n \tint i, ret = 0;\n+\tsize_t hash_size = repo->hash_algo->rawsz;\n \n \tassert(offset <= versions->nr);\n \tnr = versions->nr - offset;\n@@ -3856,7 +3857,7 @@ static int write_tree(struct object_id *result_oid,\n \t}\n \n \t/* Write this object file out, and record in result_oid */\n-\tif (odb_write_object(the_repository->objects, buf.buf,\n+\tif (odb_write_object(repo->objects, buf.buf,\n \t\t\t     buf.len, OBJ_TREE, result_oid))\n \t\tret = -1;\n \tstrbuf_release(&buf);\n@@ -4026,8 +4027,8 @@ static int write_completed_directory(struct merge_options *opt,\n \t\tdir_info->is_null = 0;\n \t\tdir_info->result.mode = S_IFDIR;\n \t\tif (record_tree &&\n-\t\t    write_tree(&dir_info->result.oid, &info->versions, offset,\n-\t\t\t       opt->repo->hash_algo->rawsz) < 0)\n+\t\t    write_tree(opt->repo, &dir_info->result.oid, &info->versions,\n+\t\t\t       offset) < 0)\n \t\t\tret = -1;\n \t}\n \n@@ -4573,8 +4574,7 @@ static int process_entries(struct merge_options *opt,\n \t\tBUG(\"dir_metadata accounting completely off; shouldn't happen\");\n \t}\n \tif (record_tree &&\n-\t    write_tree(result_oid, &dir_metadata.versions, 0,\n-\t\t       opt->repo->hash_algo->rawsz) < 0)\n+\t    write_tree(opt->repo, result_oid, &dir_metadata.versions, 0) < 0)\n \t\tret = -1;\n cleanup:\n \tstring_list_clear(&plist, 0);\n-- \ngitgitgadget\n\n"},{"id":"536453","messageId":"68af47ed187ea1bdd1b83ad8aae8d7be60a469c8.1771552788.git.gitgitgadget@gmail.com","threadId":"65011","inReplyTo":"pull.2048.v2.git.1771552788.gitgitgadget@gmail.com","subject":"[PATCH v2 3/6] merge-ort: replace the_repository with opt->repo","fromName":"Elijah Newren via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2026-02-20T01:59:45Z","receivedAt":"2026-02-20T01:59:55Z","isPatch":true,"sender":{"key":"newren@gmail.com","avatar":"https://avatars.githubusercontent.com/u/5455730?v=4"},"body":"From: Elijah Newren <newren@gmail.com>\n\nWe have a perfectly valid repository available and do not need to use\nthe_repository, except for one location in\nprefetch_for_content_merges().\n\nSigned-off-by: Elijah Newren <newren@gmail.com>\n---\n merge-ort.c | 44 ++++++++++++++++++++++----------------------\n 1 file changed, 22 insertions(+), 22 deletions(-)\n\ndiff --git a/merge-ort.c b/merge-ort.c\nindex 3535fc676f..9b6a4c312e 100644\n--- a/merge-ort.c\n+++ b/merge-ort.c\n@@ -1732,9 +1732,9 @@ static int collect_merge_info(struct merge_options *opt,\n \tinfo.data = opt;\n \tinfo.show_all_errors = 1;\n \n-\tif (repo_parse_tree(the_repository, merge_base) < 0 ||\n-\t    repo_parse_tree(the_repository, side1) < 0 ||\n-\t    repo_parse_tree(the_repository, side2) < 0)\n+\tif (repo_parse_tree(opt->repo, merge_base) < 0 ||\n+\t    repo_parse_tree(opt->repo, side1) < 0 ||\n+\t    repo_parse_tree(opt->repo, side2) < 0)\n \t\treturn -1;\n \tinit_tree_desc(t + 0, &merge_base->object.oid,\n \t\t       merge_base->buffer, merge_base->size);\n@@ -2136,9 +2136,9 @@ static int merge_3way(struct merge_options *opt,\n \t\tname2 = mkpathdup(\"%s:%s\", opt->branch2,  pathnames[2]);\n \t}\n \n-\tread_mmblob(&orig, the_repository->objects, o);\n-\tread_mmblob(&src1, the_repository->objects, a);\n-\tread_mmblob(&src2, the_repository->objects, b);\n+\tread_mmblob(&orig, opt->repo->objects, o);\n+\tread_mmblob(&src1, opt->repo->objects, a);\n+\tread_mmblob(&src2, opt->repo->objects, b);\n \n \tmerge_status = ll_merge(result_buf, path, &orig, base,\n \t\t\t\t&src1, name1, &src2, name2,\n@@ -2254,7 +2254,7 @@ static int handle_content_merge(struct merge_options *opt,\n \t\t}\n \n \t\tif (!ret && record_object &&\n-\t\t    odb_write_object(the_repository->objects, result_buf.ptr, result_buf.size,\n+\t\t    odb_write_object(opt->repo->objects, result_buf.ptr, result_buf.size,\n \t\t\t\t     OBJ_BLOB, &result->oid)) {\n \t\t\tpath_msg(opt, ERROR_OBJECT_WRITE_FAILED, 0,\n \t\t\t\t pathnames[0], pathnames[1], pathnames[2], NULL,\n@@ -3713,7 +3713,7 @@ static int read_oid_strbuf(struct merge_options *opt,\n \tvoid *buf;\n \tenum object_type type;\n \tunsigned long size;\n-\tbuf = odb_read_object(the_repository->objects, oid, &type, &size);\n+\tbuf = odb_read_object(opt->repo->objects, oid, &type, &size);\n \tif (!buf) {\n \t\tpath_msg(opt, ERROR_OBJECT_READ_FAILED, 0,\n \t\t\t path, NULL, NULL, NULL,\n@@ -4439,7 +4439,7 @@ static void prefetch_for_content_merges(struct merge_options *opt,\n \tstruct string_list_item *e;\n \tstruct oid_array to_fetch = OID_ARRAY_INIT;\n \n-\tif (!repo_has_promisor_remote(the_repository))\n+\tif (!repo_has_promisor_remote(opt->repo))\n \t\treturn;\n \n \tfor (e = &plist->items[plist->nr-1]; e >= plist->items; --e) {\n@@ -4619,10 +4619,10 @@ static int checkout(struct merge_options *opt,\n \tunpack_opts.verbose_update = (opt->verbosity > 2);\n \tunpack_opts.fn = twoway_merge;\n \tunpack_opts.preserve_ignored = 0; /* FIXME: !opts->overwrite_ignore */\n-\tif (repo_parse_tree(the_repository, prev) < 0)\n+\tif (repo_parse_tree(opt->repo, prev) < 0)\n \t\treturn -1;\n \tinit_tree_desc(&trees[0], &prev->object.oid, prev->buffer, prev->size);\n-\tif (repo_parse_tree(the_repository, next) < 0)\n+\tif (repo_parse_tree(opt->repo, next) < 0)\n \t\treturn -1;\n \tinit_tree_desc(&trees[1], &next->object.oid, next->buffer, next->size);\n \n@@ -5280,7 +5280,7 @@ redo:\n \n \tif (result->clean >= 0) {\n \t\tif (!opt->mergeability_only) {\n-\t\t\tresult->tree = repo_parse_tree_indirect(the_repository,\n+\t\t\tresult->tree = repo_parse_tree_indirect(opt->repo,\n \t\t\t\t\t\t\t\t&working_tree_oid);\n \t\t\tif (!result->tree)\n \t\t\t\tdie(_(\"unable to read tree (%s)\"),\n@@ -5309,7 +5309,7 @@ static void merge_ort_internal(struct merge_options *opt,\n \tstruct strbuf merge_base_abbrev = STRBUF_INIT;\n \n \tif (!merge_bases) {\n-\t\tif (repo_get_merge_bases(the_repository, h1, h2,\n+\t\tif (repo_get_merge_bases(opt->repo, h1, h2,\n \t\t\t\t\t &merge_bases) < 0) {\n \t\t\tresult->clean = -1;\n \t\t\tgoto out;\n@@ -5440,20 +5440,20 @@ static void merge_recursive_config(struct merge_options *opt, int ui)\n {\n \tchar *value = NULL;\n \tint renormalize = 0;\n-\trepo_config_get_int(the_repository, \"merge.verbosity\", &opt->verbosity);\n-\trepo_config_get_int(the_repository, \"diff.renamelimit\", &opt->rename_limit);\n-\trepo_config_get_int(the_repository, \"merge.renamelimit\", &opt->rename_limit);\n-\trepo_config_get_bool(the_repository, \"merge.renormalize\", &renormalize);\n+\trepo_config_get_int(opt->repo, \"merge.verbosity\", &opt->verbosity);\n+\trepo_config_get_int(opt->repo, \"diff.renamelimit\", &opt->rename_limit);\n+\trepo_config_get_int(opt->repo, \"merge.renamelimit\", &opt->rename_limit);\n+\trepo_config_get_bool(opt->repo, \"merge.renormalize\", &renormalize);\n \topt->renormalize = renormalize;\n-\tif (!repo_config_get_string(the_repository, \"diff.renames\", &value)) {\n+\tif (!repo_config_get_string(opt->repo, \"diff.renames\", &value)) {\n \t\topt->detect_renames = git_config_rename(\"diff.renames\", value);\n \t\tfree(value);\n \t}\n-\tif (!repo_config_get_string(the_repository, \"merge.renames\", &value)) {\n+\tif (!repo_config_get_string(opt->repo, \"merge.renames\", &value)) {\n \t\topt->detect_renames = git_config_rename(\"merge.renames\", value);\n \t\tfree(value);\n \t}\n-\tif (!repo_config_get_string(the_repository, \"merge.directoryrenames\", &value)) {\n+\tif (!repo_config_get_string(opt->repo, \"merge.directoryrenames\", &value)) {\n \t\tint boolval = git_parse_maybe_bool(value);\n \t\tif (0 <= boolval) {\n \t\t\topt->detect_directory_renames = boolval ?\n@@ -5466,7 +5466,7 @@ static void merge_recursive_config(struct merge_options *opt, int ui)\n \t\tfree(value);\n \t}\n \tif (ui) {\n-\t\tif (!repo_config_get_string(the_repository, \"diff.algorithm\", &value)) {\n+\t\tif (!repo_config_get_string(opt->repo, \"diff.algorithm\", &value)) {\n \t\t\tlong diff_algorithm = parse_algorithm_value(value);\n \t\t\tif (diff_algorithm < 0)\n \t\t\t\tdie(_(\"unknown value for config '%s': %s\"), \"diff.algorithm\", value);\n@@ -5474,7 +5474,7 @@ static void merge_recursive_config(struct merge_options *opt, int ui)\n \t\t\tfree(value);\n \t\t}\n \t}\n-\trepo_config(the_repository, git_xmerge_config, NULL);\n+\trepo_config(opt->repo, git_xmerge_config, NULL);\n }\n \n static void init_merge_options(struct merge_options *opt,\n-- \ngitgitgadget\n\n"},{"id":"536454","messageId":"bfa68716af2c931817761a812d8ad825a56cec5a.1771552788.git.gitgitgadget@gmail.com","threadId":"65011","inReplyTo":"pull.2048.v2.git.1771552788.gitgitgadget@gmail.com","subject":"[PATCH v2 4/6] merge-ort: replace the_hash_algo with opt->repo->hash_algo","fromName":"Elijah Newren via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2026-02-20T01:59:46Z","receivedAt":"2026-02-20T01:59:56Z","isPatch":true,"sender":{"key":"newren@gmail.com","avatar":"https://avatars.githubusercontent.com/u/5455730?v=4"},"body":"From: Elijah Newren <newren@gmail.com>\n\nWe have a perfectly valid repository available and do not need to use\nthe_hash_algo (a shorthand for the_repository->hash_algo), so use the\nknown repository instead.\n\nSigned-off-by: Elijah Newren <newren@gmail.com>\n---\n merge-ort.c | 26 +++++++++++++-------------\n 1 file changed, 13 insertions(+), 13 deletions(-)\n\ndiff --git a/merge-ort.c b/merge-ort.c\nindex 9b6a4c312e..60b4675f39 100644\n--- a/merge-ort.c\n+++ b/merge-ort.c\n@@ -1857,7 +1857,7 @@ static int merge_submodule(struct merge_options *opt,\n \t\tBUG(\"submodule deleted on one side; this should be handled outside of merge_submodule()\");\n \n \tif ((sub_not_initialized = repo_submodule_init(&subrepo,\n-\t\topt->repo, path, null_oid(the_hash_algo)))) {\n+\t\topt->repo, path, null_oid(opt->repo->hash_algo)))) {\n \t\tpath_msg(opt, CONFLICT_SUBMODULE_NOT_INITIALIZED, 0,\n \t\t\t path, NULL, NULL, NULL,\n \t\t\t _(\"Failed to merge submodule %s (not checked out)\"),\n@@ -2240,7 +2240,7 @@ static int handle_content_merge(struct merge_options *opt,\n \t\ttwo_way = ((S_IFMT & o->mode) != (S_IFMT & a->mode));\n \n \t\tmerge_status = merge_3way(opt, path,\n-\t\t\t\t\t  two_way ? null_oid(the_hash_algo) : &o->oid,\n+\t\t\t\t\t  two_way ? null_oid(opt->repo->hash_algo) : &o->oid,\n \t\t\t\t\t  &a->oid, &b->oid,\n \t\t\t\t\t  pathnames, extra_marker_size,\n \t\t\t\t\t  &result_buf);\n@@ -2272,7 +2272,7 @@ static int handle_content_merge(struct merge_options *opt,\n \t} else if (S_ISGITLINK(a->mode)) {\n \t\tint two_way = ((S_IFMT & o->mode) != (S_IFMT & a->mode));\n \t\tclean = merge_submodule(opt, pathnames[0],\n-\t\t\t\t\ttwo_way ? null_oid(the_hash_algo) : &o->oid,\n+\t\t\t\t\ttwo_way ? null_oid(opt->repo->hash_algo) : &o->oid,\n \t\t\t\t\t&a->oid, &b->oid, &result->oid);\n \t\tif (clean < 0)\n \t\t\treturn -1;\n@@ -2786,7 +2786,7 @@ static void apply_directory_rename_modifications(struct merge_options *opt,\n \t\tassert(!new_ci->match_mask);\n \t\tnew_ci->dirmask = 0;\n \t\tnew_ci->stages[1].mode = 0;\n-\t\toidcpy(&new_ci->stages[1].oid, null_oid(the_hash_algo));\n+\t\toidcpy(&new_ci->stages[1].oid, null_oid(opt->repo->hash_algo));\n \n \t\t/*\n \t\t * Now that we have the file information in new_ci, make sure\n@@ -2799,7 +2799,7 @@ static void apply_directory_rename_modifications(struct merge_options *opt,\n \t\t\t\tcontinue;\n \t\t\t/* zero out any entries related to files */\n \t\t\tci->stages[i].mode = 0;\n-\t\t\toidcpy(&ci->stages[i].oid, null_oid(the_hash_algo));\n+\t\t\toidcpy(&ci->stages[i].oid, null_oid(opt->repo->hash_algo));\n \t\t}\n \n \t\t/* Now we want to focus on new_ci, so reassign ci to it. */\n@@ -3214,7 +3214,7 @@ static int process_renames(struct merge_options *opt,\n \t\t\tif (type_changed) {\n \t\t\t\t/* rename vs. typechange */\n \t\t\t\t/* Mark the original as resolved by removal */\n-\t\t\t\tmemcpy(&oldinfo->stages[0].oid, null_oid(the_hash_algo),\n+\t\t\t\tmemcpy(&oldinfo->stages[0].oid, null_oid(opt->repo->hash_algo),\n \t\t\t\t       sizeof(oldinfo->stages[0].oid));\n \t\t\t\toldinfo->stages[0].mode = 0;\n \t\t\t\toldinfo->filemask &= 0x06;\n@@ -4102,7 +4102,7 @@ static int process_entry(struct merge_options *opt,\n \t\t\tif (ci->filemask & (1 << i))\n \t\t\t\tcontinue;\n \t\t\tci->stages[i].mode = 0;\n-\t\t\toidcpy(&ci->stages[i].oid, null_oid(the_hash_algo));\n+\t\t\toidcpy(&ci->stages[i].oid, null_oid(opt->repo->hash_algo));\n \t\t}\n \t} else if (ci->df_conflict && ci->merged.result.mode != 0) {\n \t\t/*\n@@ -4149,7 +4149,7 @@ static int process_entry(struct merge_options *opt,\n \t\t\t\tcontinue;\n \t\t\t/* zero out any entries related to directories */\n \t\t\tnew_ci->stages[i].mode = 0;\n-\t\t\toidcpy(&new_ci->stages[i].oid, null_oid(the_hash_algo));\n+\t\t\toidcpy(&new_ci->stages[i].oid, null_oid(opt->repo->hash_algo));\n \t\t}\n \n \t\t/*\n@@ -4271,11 +4271,11 @@ static int process_entry(struct merge_options *opt,\n \t\t\tnew_ci->merged.result.mode = ci->stages[2].mode;\n \t\t\toidcpy(&new_ci->merged.result.oid, &ci->stages[2].oid);\n \t\t\tnew_ci->stages[1].mode = 0;\n-\t\t\toidcpy(&new_ci->stages[1].oid, null_oid(the_hash_algo));\n+\t\t\toidcpy(&new_ci->stages[1].oid, null_oid(opt->repo->hash_algo));\n \t\t\tnew_ci->filemask = 5;\n \t\t\tif ((S_IFMT & b_mode) != (S_IFMT & o_mode)) {\n \t\t\t\tnew_ci->stages[0].mode = 0;\n-\t\t\t\toidcpy(&new_ci->stages[0].oid, null_oid(the_hash_algo));\n+\t\t\t\toidcpy(&new_ci->stages[0].oid, null_oid(opt->repo->hash_algo));\n \t\t\t\tnew_ci->filemask = 4;\n \t\t\t}\n \n@@ -4283,11 +4283,11 @@ static int process_entry(struct merge_options *opt,\n \t\t\tci->merged.result.mode = ci->stages[1].mode;\n \t\t\toidcpy(&ci->merged.result.oid, &ci->stages[1].oid);\n \t\t\tci->stages[2].mode = 0;\n-\t\t\toidcpy(&ci->stages[2].oid, null_oid(the_hash_algo));\n+\t\t\toidcpy(&ci->stages[2].oid, null_oid(opt->repo->hash_algo));\n \t\t\tci->filemask = 3;\n \t\t\tif ((S_IFMT & a_mode) != (S_IFMT & o_mode)) {\n \t\t\t\tci->stages[0].mode = 0;\n-\t\t\t\toidcpy(&ci->stages[0].oid, null_oid(the_hash_algo));\n+\t\t\t\toidcpy(&ci->stages[0].oid, null_oid(opt->repo->hash_algo));\n \t\t\t\tci->filemask = 2;\n \t\t\t}\n \n@@ -4415,7 +4415,7 @@ static int process_entry(struct merge_options *opt,\n \t\t/* Deleted on both sides */\n \t\tci->merged.is_null = 1;\n \t\tci->merged.result.mode = 0;\n-\t\toidcpy(&ci->merged.result.oid, null_oid(the_hash_algo));\n+\t\toidcpy(&ci->merged.result.oid, null_oid(opt->repo->hash_algo));\n \t\tassert(!ci->df_conflict);\n \t\tci->merged.clean = !ci->path_conflict;\n \t}\n-- \ngitgitgadget\n\n"},{"id":"536455","messageId":"932d945c9bd15ae570198fb489173b4461034622.1771552788.git.gitgitgadget@gmail.com","threadId":"65011","inReplyTo":"pull.2048.v2.git.1771552788.gitgitgadget@gmail.com","subject":"[PATCH v2 5/6] merge-ort: prevent the_repository from coming back","fromName":"Elijah Newren via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2026-02-20T01:59:47Z","receivedAt":"2026-02-20T01:59:57Z","isPatch":true,"sender":{"key":"newren@gmail.com","avatar":"https://avatars.githubusercontent.com/u/5455730?v=4"},"body":"From: Elijah Newren <newren@gmail.com>\n\nDue to the use of DEFAULT_ABBREV, we cannot get rid of our usage of\nUSE_THE_REPOSITORY_VARIABLE.  However, we have removed all other uses of\nthe_repository in merge-ort a few times.  But they keep coming back.\n\nDefine the_repository to make it a compilation error so that they don't\ncome back any more.\n\nSigned-off-by: Elijah Newren <newren@gmail.com>\n---\n merge-ort.c | 8 ++++++++\n 1 file changed, 8 insertions(+)\n\ndiff --git a/merge-ort.c b/merge-ort.c\nindex 60b4675f39..00923ce3cd 100644\n--- a/merge-ort.c\n+++ b/merge-ort.c\n@@ -53,6 +53,14 @@\n #include \"unpack-trees.h\"\n #include \"xdiff-interface.h\"\n \n+/*\n+ * We technically need USE_THE_REPOSITORY_VARIABLE above for DEFAULT_ABBREV,\n+ * but do not want more uses of the_repository.  Prevent them.\n+ *\n+ * opt->repo is available; use it instead.\n+ */\n+#define the_repository DO_NOT_USE_THE_REPOSITORY\n+\n /*\n  * We have many arrays of size 3.  Whenever we have such an array, the\n  * indices refer to one of the sides of the three-way merge.  This is so\n-- \ngitgitgadget\n\n"},{"id":"536456","messageId":"67db46f34f5a0a4a791479899b9dd954aaf5e9d9.1771552788.git.gitgitgadget@gmail.com","threadId":"65011","inReplyTo":"pull.2048.v2.git.1771552788.gitgitgadget@gmail.com","subject":"[PATCH v2 6/6] replay: prevent the_repository from coming back","fromName":"Elijah Newren via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2026-02-20T01:59:48Z","receivedAt":"2026-02-20T01:59:58Z","isPatch":true,"sender":{"key":"newren@gmail.com","avatar":"https://avatars.githubusercontent.com/u/5455730?v=4"},"body":"From: Elijah Newren <newren@gmail.com>\n\nDue to the use of DEFAULT_ABBREV, we cannot get rid of our usage of\nUSE_THE_REPOSITORY_VARIABLE.  We have removed all other uses of\nthe_repository before, but without removing that definition, they keep\ncoming back.\n\nDefine the_repository to make it a compilation error so that they don't\ncome back any more.\n\nSigned-off-by: Elijah Newren <newren@gmail.com>\n---\n replay.c | 6 ++++++\n 1 file changed, 6 insertions(+)\n\ndiff --git a/replay.c b/replay.c\nindex f97d652f33..a63f6714c4 100644\n--- a/replay.c\n+++ b/replay.c\n@@ -11,6 +11,12 @@\n #include \"strmap.h\"\n #include \"tree.h\"\n \n+/*\n+ * We technically need USE_THE_REPOSITORY_VARIABLE for DEFAULT_ABBREV, but\n+ * do not want to use the_repository.\n+ */\n+#define the_repository DO_NOT_USE_THE_REPOSITORY\n+\n static const char *short_commit_name(struct repository *repo,\n \t\t\t\t     struct commit *commit)\n {\n-- \ngitgitgadget\n"},{"id":"536469","messageId":"aZgZAuIlCujcoEIt@pks.im","threadId":"65011","inReplyTo":"7155a0da6f8bcdac90cf1ed085622f2c8b68675e.1771552788.git.gitgitgadget@gmail.com","subject":"Re: [PATCH v2 1/6] merge,diff: remove the_repository check before prefetching blobs","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2026-02-20T08:19:14Z","receivedAt":"2026-02-20T08:19:22Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"On Fri, Feb 20, 2026 at 01:59:43AM +0000, Elijah Newren via GitGitGadget wrote:\n> diff --git a/diff.c b/diff.c\n> index 35b903a9a0..91d81f66ad 100644\n> --- a/diff.c\n> +++ b/diff.c\n> @@ -7176,7 +7176,7 @@ void diffcore_std(struct diff_options *options)\n>  \t * If no prefetching occurs, diffcore_rename() will prefetch if it\n>  \t * decides that it needs inexact rename detection.\n>  \t */\n> -\tif (options->repo == the_repository && repo_has_promisor_remote(the_repository) &&\n> +\tif (repo_has_promisor_remote(the_repository) &&\n\nI wonder though -- shouldn't we also pass `options->repo` to\n`repo_has_promisor_remote()` now? Otherwise we may support backfill\nfetches from arbitrary repositories, but we'll only do them in case the\nmain repository has a promisor remote.\n\nPatrick\n"},{"id":"536548","messageId":"CABPp-BGR5Mrm30sSb9Y96VkFC5-XFTYkoAp60LMAf6gCgW3QEg@mail.gmail.com","threadId":"65011","inReplyTo":"aZgZAuIlCujcoEIt@pks.im","subject":"Re: [PATCH v2 1/6] merge,diff: remove the_repository check before prefetching blobs","fromName":"Elijah Newren","fromEmail":"newren@gmail.com","sentAt":"2026-02-20T18:51:52Z","receivedAt":"2026-02-20T18:52:05Z","isPatch":true,"sender":{"key":"newren@gmail.com","avatar":"https://avatars.githubusercontent.com/u/5455730?v=4"},"body":"On Fri, Feb 20, 2026 at 12:19 AM Patrick Steinhardt <ps@pks.im> wrote:\n>\n> On Fri, Feb 20, 2026 at 01:59:43AM +0000, Elijah Newren via GitGitGadget wrote:\n> > diff --git a/diff.c b/diff.c\n> > index 35b903a9a0..91d81f66ad 100644\n> > --- a/diff.c\n> > +++ b/diff.c\n> > @@ -7176,7 +7176,7 @@ void diffcore_std(struct diff_options *options)\n> >        * If no prefetching occurs, diffcore_rename() will prefetch if it\n> >        * decides that it needs inexact rename detection.\n> >        */\n> > -     if (options->repo == the_repository && repo_has_promisor_remote(the_repository) &&\n> > +     if (repo_has_promisor_remote(the_repository) &&\n>\n> I wonder though -- shouldn't we also pass `options->repo` to\n> `repo_has_promisor_remote()` now? Otherwise we may support backfill\n> fetches from arbitrary repositories, but we'll only do them in case the\n> main repository has a promisor remote.\n\nDoh.  Definitely yes.  Amid having this patch originally be last and\nrebasing and whatnot, I didn't look closely enough and missed that.\nWill fix all the callsites and resubmit.\n"},{"id":"536606","messageId":"pull.2048.v3.git.1771718393.gitgitgadget@gmail.com","threadId":"65011","inReplyTo":"pull.2048.v2.git.1771552788.gitgitgadget@gmail.com","subject":"[PATCH v3 0/6] Avoid the_repository in merge-ort and replay","fromName":"Elijah Newren via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2026-02-21T23:59:47Z","receivedAt":"2026-02-21T23:59:56Z","isPatch":true,"sender":{"key":"newren@gmail.com","avatar":"https://avatars.githubusercontent.com/u/5455730?v=4"},"body":"Changes since v2:\n\n * In first patch, actually avoid the_repository when attempting to remove\n   check against the_repository\n * Fix commit message of patch 3 due to the new patch 1.\n * Slight tweak to commit message of patch 6.\n\nChanges since v1:\n\n * Add a preparatory patch removing the_repository check from blob\n   prefetching in both merge-ort and diff*; it's no longer necessary\n * Fix casing mismatch\n * Simplify the hammer a bit based on the new first patch, but add some\n   simple comments explaining it\n\nRemove explicit uses of the_repository and the_hash_algo from merge-ort, and\nsince this has now been done multiple times for both merge-ort and replay,\nimplement a small measure to prevent them from returning to either merge-ort\nor replay.\n\nSee\nhttps://lore.kernel.org/git/CABPp-BH7E1Bh2g0vR3T4NEsv34DvFQPzMuJSsqtOAaWY-fFCxg@mail.gmail.com/\nand\nhttps://lore.kernel.org/git/CABPp-BFuwvqiCTCCpoyT6em9_1-qrgPWHWhrufQ3UuZ+Kfkb6A@mail.gmail.com/\nfor recent discussions on these.\n\nAs noted in the comments on v1, I actually do not know why\nprefetch_for_content_merges() needs to use the_repository. When I introduced\nit back in 2bff554b23e8 (merge-ort: add prefetching for content merges,\n2021-06-22), I was just looking at diffcore_std() and trying to mimic how it\ndid the prefetch, and it has such a comparison. If anyone knows why\ndiffcore_std() needs to compare against the_repository, I'd love to hear...\n\nSeries overview: Patches 1-3: Mostly mechanical removal of existing uses\nPatches 4-5: Simple hammer to prevent the problem from returning\n\nElijah Newren (6):\n  merge,diff: remove the_repository check before prefetching blobs\n  merge-ort: pass repository to write_tree()\n  merge-ort: replace the_repository with opt->repo\n  merge-ort: replace the_hash_algo with opt->repo->hash_algo\n  merge-ort: prevent the_repository from coming back\n  replay: prevent the_repository from coming back\n\n diff.c            |  2 +-\n diffcore-break.c  |  2 +-\n diffcore-rename.c |  4 +-\n merge-ort.c       | 94 +++++++++++++++++++++++++----------------------\n replay.c          |  6 +++\n 5 files changed, 61 insertions(+), 47 deletions(-)\n\n\nbase-commit: 73fd77805fc6406f31c36212846d9e2541d19321\nPublished-As: https://github.com/gitgitgadget/git/releases/tag/pr-2048%2Fnewren%2Favoid_the_repository-v3\nFetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-2048/newren/avoid_the_repository-v3\nPull-Request: https://github.com/gitgitgadget/git/pull/2048\n\nRange-diff vs v2:\n\n 1:  7155a0da6f ! 1:  e75334a5cf merge,diff: remove the_repository check before prefetching blobs\n     @@ diff.c: void diffcore_std(struct diff_options *options)\n       \t * decides that it needs inexact rename detection.\n       \t */\n      -\tif (options->repo == the_repository && repo_has_promisor_remote(the_repository) &&\n     -+\tif (repo_has_promisor_remote(the_repository) &&\n     ++\tif (repo_has_promisor_remote(options->repo) &&\n       \t    (options->output_format & output_formats_to_prefetch ||\n       \t     options->pickaxe_opts & DIFF_PICKAXE_KINDS_MASK))\n       \t\tdiff_queued_diff_prefetch(options->repo);\n     @@ diffcore-break.c: static int should_break(struct repository *r,\n       \t\treturn 0; /* they are the same */\n       \n      -\tif (r == the_repository && repo_has_promisor_remote(the_repository)) {\n     -+\tif (repo_has_promisor_remote(the_repository)) {\n     ++\tif (repo_has_promisor_remote(r)) {\n       \t\toptions.missing_object_cb = diff_queued_diff_prefetch;\n       \t\toptions.missing_object_data = r;\n       \t}\n     @@ diffcore-rename.c: static int find_basename_matches(struct diff_options *options\n       \t}\n       \n      -\tif (options->repo == the_repository && repo_has_promisor_remote(the_repository)) {\n     -+\tif (repo_has_promisor_remote(the_repository)) {\n     ++\tif (repo_has_promisor_remote(options->repo)) {\n       \t\tdpf_options.missing_object_cb = basename_prefetch;\n       \t\tdpf_options.missing_object_data = &prefetch_options;\n       \t}\n     @@ diffcore-rename.c: void diffcore_rename_extended(struct diff_options *options,\n       \t/* Finish setting up dpf_options */\n       \tprefetch_options.skip_unmodified = skip_unmodified;\n      -\tif (options->repo == the_repository && repo_has_promisor_remote(the_repository)) {\n     -+\tif (repo_has_promisor_remote(the_repository)) {\n     ++\tif (repo_has_promisor_remote(options->repo)) {\n       \t\tdpf_options.missing_object_cb = inexact_prefetch;\n       \t\tdpf_options.missing_object_data = &prefetch_options;\n       \t}\n     @@ merge-ort.c: static void prefetch_for_content_merges(struct merge_options *opt,\n       \tstruct oid_array to_fetch = OID_ARRAY_INIT;\n       \n      -\tif (opt->repo != the_repository || !repo_has_promisor_remote(the_repository))\n     -+\tif (!repo_has_promisor_remote(the_repository))\n     ++\tif (!repo_has_promisor_remote(opt->repo))\n       \t\treturn;\n       \n       \tfor (e = &plist->items[plist->nr-1]; e >= plist->items; --e) {\n 2:  911cba991b = 2:  a9a9d422a3 merge-ort: pass repository to write_tree()\n 3:  68af47ed18 ! 3:  4ebfcb08a5 merge-ort: replace the_repository with opt->repo\n     @@ Commit message\n          merge-ort: replace the_repository with opt->repo\n      \n          We have a perfectly valid repository available and do not need to use\n     -    the_repository, except for one location in\n     -    prefetch_for_content_merges().\n     +    the_repository.\n      \n          Signed-off-by: Elijah Newren <newren@gmail.com>\n      \n     @@ merge-ort.c: static int read_oid_strbuf(struct merge_options *opt,\n       \tif (!buf) {\n       \t\tpath_msg(opt, ERROR_OBJECT_READ_FAILED, 0,\n       \t\t\t path, NULL, NULL, NULL,\n     -@@ merge-ort.c: static void prefetch_for_content_merges(struct merge_options *opt,\n     - \tstruct string_list_item *e;\n     - \tstruct oid_array to_fetch = OID_ARRAY_INIT;\n     - \n     --\tif (!repo_has_promisor_remote(the_repository))\n     -+\tif (!repo_has_promisor_remote(opt->repo))\n     - \t\treturn;\n     - \n     - \tfor (e = &plist->items[plist->nr-1]; e >= plist->items; --e) {\n      @@ merge-ort.c: static int checkout(struct merge_options *opt,\n       \tunpack_opts.verbose_update = (opt->verbosity > 2);\n       \tunpack_opts.fn = twoway_merge;\n 4:  bfa68716af = 4:  09076d81b6 merge-ort: replace the_hash_algo with opt->repo->hash_algo\n 5:  932d945c9b = 5:  42a2576878 merge-ort: prevent the_repository from coming back\n 6:  67db46f34f ! 6:  0654d04584 replay: prevent the_repository from coming back\n     @@ Commit message\n          coming back.\n      \n          Define the_repository to make it a compilation error so that they don't\n     -    come back any more.\n     +    come back any more; the repo parameter plumbed through the various\n     +    functions can be used instead.\n      \n          Signed-off-by: Elijah Newren <newren@gmail.com>\n      \n\n-- \ngitgitgadget\n"},{"id":"536607","messageId":"e75334a5cf04264250c63f9bf5ee745456aecf0d.1771718393.git.gitgitgadget@gmail.com","threadId":"65011","inReplyTo":"pull.2048.v3.git.1771718393.gitgitgadget@gmail.com","subject":"[PATCH v3 1/6] merge,diff: remove the_repository check before prefetching blobs","fromName":"Elijah Newren via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2026-02-21T23:59:48Z","receivedAt":"2026-02-21T23:59:57Z","isPatch":true,"sender":{"key":"newren@gmail.com","avatar":"https://avatars.githubusercontent.com/u/5455730?v=4"},"body":"From: Elijah Newren <newren@gmail.com>\n\nPrefetching of blobs from promisor remotes was added to diff in\n7fbbcb21b162 (diff: batch fetching of missing blobs, 2019-04-05).  In\nthat commit,\n\n  https://lore.kernel.org/git/20190405170934.20441-1-jonathantanmy@google.com/\n\nwas squashed into\n\n  https://lore.kernel.org/git/44de02e584f449481e6fb00cf35d74adf0192e9d.1553895166.git.jonathantanmy@google.com/\n\nwithout the extra explanation about the squashed changes being added to\nthe commit message; in particular, this explanation from that first link\nis absent:\n\n> Also, prefetch only if the repository being diffed is the_repository\n> (because we do not support lazy fetching for any other repository\n>  anyway).\n\nThen, later, this checking was spread from diff.c to diffcore-rename.c\nand diffcore-break.c by 95acf11a3dc3 (diff: restrict when prefetching\noccurs, 2020-04-07) and then further split in d331dd3b0c82\n(diffcore-rename: allow different missing_object_cb functions,\n2021-06-22).  I also copied the logic from prefetching blobs from\ndiff.c to merge-ort.c in 2bff554b23e8 (merge-ort: add prefetching for\ncontent merges, 2021-06-22).\n\nThe reason for all these checks was noted above -- we only supported\nlazy fetching for the_repository.  However, that changed with\nef830cc43412 (promisor-remote: teach lazy-fetch in any repo,\n2021-06-17), so these checks are now unnecessary.  Remove them.\n\nSigned-off-by: Elijah Newren <newren@gmail.com>\n---\n diff.c            | 2 +-\n diffcore-break.c  | 2 +-\n diffcore-rename.c | 4 ++--\n merge-ort.c       | 2 +-\n 4 files changed, 5 insertions(+), 5 deletions(-)\n\ndiff --git a/diff.c b/diff.c\nindex 35b903a9a0..9091e041b7 100644\n--- a/diff.c\n+++ b/diff.c\n@@ -7176,7 +7176,7 @@ void diffcore_std(struct diff_options *options)\n \t * If no prefetching occurs, diffcore_rename() will prefetch if it\n \t * decides that it needs inexact rename detection.\n \t */\n-\tif (options->repo == the_repository && repo_has_promisor_remote(the_repository) &&\n+\tif (repo_has_promisor_remote(options->repo) &&\n \t    (options->output_format & output_formats_to_prefetch ||\n \t     options->pickaxe_opts & DIFF_PICKAXE_KINDS_MASK))\n \t\tdiff_queued_diff_prefetch(options->repo);\ndiff --git a/diffcore-break.c b/diffcore-break.c\nindex c4c2173f30..91ae5e8dbb 100644\n--- a/diffcore-break.c\n+++ b/diffcore-break.c\n@@ -69,7 +69,7 @@ static int should_break(struct repository *r,\n \t    oideq(&src->oid, &dst->oid))\n \t\treturn 0; /* they are the same */\n \n-\tif (r == the_repository && repo_has_promisor_remote(the_repository)) {\n+\tif (repo_has_promisor_remote(r)) {\n \t\toptions.missing_object_cb = diff_queued_diff_prefetch;\n \t\toptions.missing_object_data = r;\n \t}\ndiff --git a/diffcore-rename.c b/diffcore-rename.c\nindex d9476db35a..c797d8ed2f 100644\n--- a/diffcore-rename.c\n+++ b/diffcore-rename.c\n@@ -987,7 +987,7 @@ static int find_basename_matches(struct diff_options *options,\n \t\t\tstrintmap_set(&dests, base, i);\n \t}\n \n-\tif (options->repo == the_repository && repo_has_promisor_remote(the_repository)) {\n+\tif (repo_has_promisor_remote(options->repo)) {\n \t\tdpf_options.missing_object_cb = basename_prefetch;\n \t\tdpf_options.missing_object_data = &prefetch_options;\n \t}\n@@ -1574,7 +1574,7 @@ void diffcore_rename_extended(struct diff_options *options,\n \n \t/* Finish setting up dpf_options */\n \tprefetch_options.skip_unmodified = skip_unmodified;\n-\tif (options->repo == the_repository && repo_has_promisor_remote(the_repository)) {\n+\tif (repo_has_promisor_remote(options->repo)) {\n \t\tdpf_options.missing_object_cb = inexact_prefetch;\n \t\tdpf_options.missing_object_data = &prefetch_options;\n \t}\ndiff --git a/merge-ort.c b/merge-ort.c\nindex 0a59d1e596..27a58a735d 100644\n--- a/merge-ort.c\n+++ b/merge-ort.c\n@@ -4438,7 +4438,7 @@ static void prefetch_for_content_merges(struct merge_options *opt,\n \tstruct string_list_item *e;\n \tstruct oid_array to_fetch = OID_ARRAY_INIT;\n \n-\tif (opt->repo != the_repository || !repo_has_promisor_remote(the_repository))\n+\tif (!repo_has_promisor_remote(opt->repo))\n \t\treturn;\n \n \tfor (e = &plist->items[plist->nr-1]; e >= plist->items; --e) {\n-- \ngitgitgadget\n\n"},{"id":"536608","messageId":"a9a9d422a35de63916c8529545a22870b3a1d508.1771718393.git.gitgitgadget@gmail.com","threadId":"65011","inReplyTo":"pull.2048.v3.git.1771718393.gitgitgadget@gmail.com","subject":"[PATCH v3 2/6] merge-ort: pass repository to write_tree()","fromName":"Elijah Newren via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2026-02-21T23:59:49Z","receivedAt":"2026-02-22T00:00:00Z","isPatch":true,"sender":{"key":"newren@gmail.com","avatar":"https://avatars.githubusercontent.com/u/5455730?v=4"},"body":"From: Elijah Newren <newren@gmail.com>\n\nIn order to get rid of a usage of the_repository, we need to know the\nvalue of opt->repo; pass it along to write_tree().  Once we have the\nrepository, though, we no longer need to pass\nopt->repo->hash_algo->rawsz, we can have write_tree() look up that value\nitself.\n\nSigned-off-by: Elijah Newren <newren@gmail.com>\n---\n merge-ort.c | 16 ++++++++--------\n 1 file changed, 8 insertions(+), 8 deletions(-)\n\ndiff --git a/merge-ort.c b/merge-ort.c\nindex 27a58a735d..289a61822f 100644\n--- a/merge-ort.c\n+++ b/merge-ort.c\n@@ -3822,15 +3822,16 @@ static int tree_entry_order(const void *a_, const void *b_)\n \t\t\t\t b->string, strlen(b->string), bmi->result.mode);\n }\n \n-static int write_tree(struct object_id *result_oid,\n+static int write_tree(struct repository *repo,\n+\t\t      struct object_id *result_oid,\n \t\t      struct string_list *versions,\n-\t\t      unsigned int offset,\n-\t\t      size_t hash_size)\n+\t\t      unsigned int offset)\n {\n \tsize_t maxlen = 0, extra;\n \tunsigned int nr;\n \tstruct strbuf buf = STRBUF_INIT;\n \tint i, ret = 0;\n+\tsize_t hash_size = repo->hash_algo->rawsz;\n \n \tassert(offset <= versions->nr);\n \tnr = versions->nr - offset;\n@@ -3856,7 +3857,7 @@ static int write_tree(struct object_id *result_oid,\n \t}\n \n \t/* Write this object file out, and record in result_oid */\n-\tif (odb_write_object(the_repository->objects, buf.buf,\n+\tif (odb_write_object(repo->objects, buf.buf,\n \t\t\t     buf.len, OBJ_TREE, result_oid))\n \t\tret = -1;\n \tstrbuf_release(&buf);\n@@ -4026,8 +4027,8 @@ static int write_completed_directory(struct merge_options *opt,\n \t\tdir_info->is_null = 0;\n \t\tdir_info->result.mode = S_IFDIR;\n \t\tif (record_tree &&\n-\t\t    write_tree(&dir_info->result.oid, &info->versions, offset,\n-\t\t\t       opt->repo->hash_algo->rawsz) < 0)\n+\t\t    write_tree(opt->repo, &dir_info->result.oid, &info->versions,\n+\t\t\t       offset) < 0)\n \t\t\tret = -1;\n \t}\n \n@@ -4573,8 +4574,7 @@ static int process_entries(struct merge_options *opt,\n \t\tBUG(\"dir_metadata accounting completely off; shouldn't happen\");\n \t}\n \tif (record_tree &&\n-\t    write_tree(result_oid, &dir_metadata.versions, 0,\n-\t\t       opt->repo->hash_algo->rawsz) < 0)\n+\t    write_tree(opt->repo, result_oid, &dir_metadata.versions, 0) < 0)\n \t\tret = -1;\n cleanup:\n \tstring_list_clear(&plist, 0);\n-- \ngitgitgadget\n\n"},{"id":"536609","messageId":"4ebfcb08a5b79c519340ea5c13d3dd44b5060639.1771718393.git.gitgitgadget@gmail.com","threadId":"65011","inReplyTo":"pull.2048.v3.git.1771718393.gitgitgadget@gmail.com","subject":"[PATCH v3 3/6] merge-ort: replace the_repository with opt->repo","fromName":"Elijah Newren via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2026-02-21T23:59:50Z","receivedAt":"2026-02-22T00:00:01Z","isPatch":true,"sender":{"key":"newren@gmail.com","avatar":"https://avatars.githubusercontent.com/u/5455730?v=4"},"body":"From: Elijah Newren <newren@gmail.com>\n\nWe have a perfectly valid repository available and do not need to use\nthe_repository.\n\nSigned-off-by: Elijah Newren <newren@gmail.com>\n---\n merge-ort.c | 42 +++++++++++++++++++++---------------------\n 1 file changed, 21 insertions(+), 21 deletions(-)\n\ndiff --git a/merge-ort.c b/merge-ort.c\nindex 289a61822f..9b6a4c312e 100644\n--- a/merge-ort.c\n+++ b/merge-ort.c\n@@ -1732,9 +1732,9 @@ static int collect_merge_info(struct merge_options *opt,\n \tinfo.data = opt;\n \tinfo.show_all_errors = 1;\n \n-\tif (repo_parse_tree(the_repository, merge_base) < 0 ||\n-\t    repo_parse_tree(the_repository, side1) < 0 ||\n-\t    repo_parse_tree(the_repository, side2) < 0)\n+\tif (repo_parse_tree(opt->repo, merge_base) < 0 ||\n+\t    repo_parse_tree(opt->repo, side1) < 0 ||\n+\t    repo_parse_tree(opt->repo, side2) < 0)\n \t\treturn -1;\n \tinit_tree_desc(t + 0, &merge_base->object.oid,\n \t\t       merge_base->buffer, merge_base->size);\n@@ -2136,9 +2136,9 @@ static int merge_3way(struct merge_options *opt,\n \t\tname2 = mkpathdup(\"%s:%s\", opt->branch2,  pathnames[2]);\n \t}\n \n-\tread_mmblob(&orig, the_repository->objects, o);\n-\tread_mmblob(&src1, the_repository->objects, a);\n-\tread_mmblob(&src2, the_repository->objects, b);\n+\tread_mmblob(&orig, opt->repo->objects, o);\n+\tread_mmblob(&src1, opt->repo->objects, a);\n+\tread_mmblob(&src2, opt->repo->objects, b);\n \n \tmerge_status = ll_merge(result_buf, path, &orig, base,\n \t\t\t\t&src1, name1, &src2, name2,\n@@ -2254,7 +2254,7 @@ static int handle_content_merge(struct merge_options *opt,\n \t\t}\n \n \t\tif (!ret && record_object &&\n-\t\t    odb_write_object(the_repository->objects, result_buf.ptr, result_buf.size,\n+\t\t    odb_write_object(opt->repo->objects, result_buf.ptr, result_buf.size,\n \t\t\t\t     OBJ_BLOB, &result->oid)) {\n \t\t\tpath_msg(opt, ERROR_OBJECT_WRITE_FAILED, 0,\n \t\t\t\t pathnames[0], pathnames[1], pathnames[2], NULL,\n@@ -3713,7 +3713,7 @@ static int read_oid_strbuf(struct merge_options *opt,\n \tvoid *buf;\n \tenum object_type type;\n \tunsigned long size;\n-\tbuf = odb_read_object(the_repository->objects, oid, &type, &size);\n+\tbuf = odb_read_object(opt->repo->objects, oid, &type, &size);\n \tif (!buf) {\n \t\tpath_msg(opt, ERROR_OBJECT_READ_FAILED, 0,\n \t\t\t path, NULL, NULL, NULL,\n@@ -4619,10 +4619,10 @@ static int checkout(struct merge_options *opt,\n \tunpack_opts.verbose_update = (opt->verbosity > 2);\n \tunpack_opts.fn = twoway_merge;\n \tunpack_opts.preserve_ignored = 0; /* FIXME: !opts->overwrite_ignore */\n-\tif (repo_parse_tree(the_repository, prev) < 0)\n+\tif (repo_parse_tree(opt->repo, prev) < 0)\n \t\treturn -1;\n \tinit_tree_desc(&trees[0], &prev->object.oid, prev->buffer, prev->size);\n-\tif (repo_parse_tree(the_repository, next) < 0)\n+\tif (repo_parse_tree(opt->repo, next) < 0)\n \t\treturn -1;\n \tinit_tree_desc(&trees[1], &next->object.oid, next->buffer, next->size);\n \n@@ -5280,7 +5280,7 @@ redo:\n \n \tif (result->clean >= 0) {\n \t\tif (!opt->mergeability_only) {\n-\t\t\tresult->tree = repo_parse_tree_indirect(the_repository,\n+\t\t\tresult->tree = repo_parse_tree_indirect(opt->repo,\n \t\t\t\t\t\t\t\t&working_tree_oid);\n \t\t\tif (!result->tree)\n \t\t\t\tdie(_(\"unable to read tree (%s)\"),\n@@ -5309,7 +5309,7 @@ static void merge_ort_internal(struct merge_options *opt,\n \tstruct strbuf merge_base_abbrev = STRBUF_INIT;\n \n \tif (!merge_bases) {\n-\t\tif (repo_get_merge_bases(the_repository, h1, h2,\n+\t\tif (repo_get_merge_bases(opt->repo, h1, h2,\n \t\t\t\t\t &merge_bases) < 0) {\n \t\t\tresult->clean = -1;\n \t\t\tgoto out;\n@@ -5440,20 +5440,20 @@ static void merge_recursive_config(struct merge_options *opt, int ui)\n {\n \tchar *value = NULL;\n \tint renormalize = 0;\n-\trepo_config_get_int(the_repository, \"merge.verbosity\", &opt->verbosity);\n-\trepo_config_get_int(the_repository, \"diff.renamelimit\", &opt->rename_limit);\n-\trepo_config_get_int(the_repository, \"merge.renamelimit\", &opt->rename_limit);\n-\trepo_config_get_bool(the_repository, \"merge.renormalize\", &renormalize);\n+\trepo_config_get_int(opt->repo, \"merge.verbosity\", &opt->verbosity);\n+\trepo_config_get_int(opt->repo, \"diff.renamelimit\", &opt->rename_limit);\n+\trepo_config_get_int(opt->repo, \"merge.renamelimit\", &opt->rename_limit);\n+\trepo_config_get_bool(opt->repo, \"merge.renormalize\", &renormalize);\n \topt->renormalize = renormalize;\n-\tif (!repo_config_get_string(the_repository, \"diff.renames\", &value)) {\n+\tif (!repo_config_get_string(opt->repo, \"diff.renames\", &value)) {\n \t\topt->detect_renames = git_config_rename(\"diff.renames\", value);\n \t\tfree(value);\n \t}\n-\tif (!repo_config_get_string(the_repository, \"merge.renames\", &value)) {\n+\tif (!repo_config_get_string(opt->repo, \"merge.renames\", &value)) {\n \t\topt->detect_renames = git_config_rename(\"merge.renames\", value);\n \t\tfree(value);\n \t}\n-\tif (!repo_config_get_string(the_repository, \"merge.directoryrenames\", &value)) {\n+\tif (!repo_config_get_string(opt->repo, \"merge.directoryrenames\", &value)) {\n \t\tint boolval = git_parse_maybe_bool(value);\n \t\tif (0 <= boolval) {\n \t\t\topt->detect_directory_renames = boolval ?\n@@ -5466,7 +5466,7 @@ static void merge_recursive_config(struct merge_options *opt, int ui)\n \t\tfree(value);\n \t}\n \tif (ui) {\n-\t\tif (!repo_config_get_string(the_repository, \"diff.algorithm\", &value)) {\n+\t\tif (!repo_config_get_string(opt->repo, \"diff.algorithm\", &value)) {\n \t\t\tlong diff_algorithm = parse_algorithm_value(value);\n \t\t\tif (diff_algorithm < 0)\n \t\t\t\tdie(_(\"unknown value for config '%s': %s\"), \"diff.algorithm\", value);\n@@ -5474,7 +5474,7 @@ static void merge_recursive_config(struct merge_options *opt, int ui)\n \t\t\tfree(value);\n \t\t}\n \t}\n-\trepo_config(the_repository, git_xmerge_config, NULL);\n+\trepo_config(opt->repo, git_xmerge_config, NULL);\n }\n \n static void init_merge_options(struct merge_options *opt,\n-- \ngitgitgadget\n\n"},{"id":"536611","messageId":"09076d81b671c4c5a7582ff23163c4edba912cb6.1771718393.git.gitgitgadget@gmail.com","threadId":"65011","inReplyTo":"pull.2048.v3.git.1771718393.gitgitgadget@gmail.com","subject":"[PATCH v3 4/6] merge-ort: replace the_hash_algo with opt->repo->hash_algo","fromName":"Elijah Newren via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2026-02-21T23:59:51Z","receivedAt":"2026-02-22T00:00:02Z","isPatch":true,"sender":{"key":"newren@gmail.com","avatar":"https://avatars.githubusercontent.com/u/5455730?v=4"},"body":"From: Elijah Newren <newren@gmail.com>\n\nWe have a perfectly valid repository available and do not need to use\nthe_hash_algo (a shorthand for the_repository->hash_algo), so use the\nknown repository instead.\n\nSigned-off-by: Elijah Newren <newren@gmail.com>\n---\n merge-ort.c | 26 +++++++++++++-------------\n 1 file changed, 13 insertions(+), 13 deletions(-)\n\ndiff --git a/merge-ort.c b/merge-ort.c\nindex 9b6a4c312e..60b4675f39 100644\n--- a/merge-ort.c\n+++ b/merge-ort.c\n@@ -1857,7 +1857,7 @@ static int merge_submodule(struct merge_options *opt,\n \t\tBUG(\"submodule deleted on one side; this should be handled outside of merge_submodule()\");\n \n \tif ((sub_not_initialized = repo_submodule_init(&subrepo,\n-\t\topt->repo, path, null_oid(the_hash_algo)))) {\n+\t\topt->repo, path, null_oid(opt->repo->hash_algo)))) {\n \t\tpath_msg(opt, CONFLICT_SUBMODULE_NOT_INITIALIZED, 0,\n \t\t\t path, NULL, NULL, NULL,\n \t\t\t _(\"Failed to merge submodule %s (not checked out)\"),\n@@ -2240,7 +2240,7 @@ static int handle_content_merge(struct merge_options *opt,\n \t\ttwo_way = ((S_IFMT & o->mode) != (S_IFMT & a->mode));\n \n \t\tmerge_status = merge_3way(opt, path,\n-\t\t\t\t\t  two_way ? null_oid(the_hash_algo) : &o->oid,\n+\t\t\t\t\t  two_way ? null_oid(opt->repo->hash_algo) : &o->oid,\n \t\t\t\t\t  &a->oid, &b->oid,\n \t\t\t\t\t  pathnames, extra_marker_size,\n \t\t\t\t\t  &result_buf);\n@@ -2272,7 +2272,7 @@ static int handle_content_merge(struct merge_options *opt,\n \t} else if (S_ISGITLINK(a->mode)) {\n \t\tint two_way = ((S_IFMT & o->mode) != (S_IFMT & a->mode));\n \t\tclean = merge_submodule(opt, pathnames[0],\n-\t\t\t\t\ttwo_way ? null_oid(the_hash_algo) : &o->oid,\n+\t\t\t\t\ttwo_way ? null_oid(opt->repo->hash_algo) : &o->oid,\n \t\t\t\t\t&a->oid, &b->oid, &result->oid);\n \t\tif (clean < 0)\n \t\t\treturn -1;\n@@ -2786,7 +2786,7 @@ static void apply_directory_rename_modifications(struct merge_options *opt,\n \t\tassert(!new_ci->match_mask);\n \t\tnew_ci->dirmask = 0;\n \t\tnew_ci->stages[1].mode = 0;\n-\t\toidcpy(&new_ci->stages[1].oid, null_oid(the_hash_algo));\n+\t\toidcpy(&new_ci->stages[1].oid, null_oid(opt->repo->hash_algo));\n \n \t\t/*\n \t\t * Now that we have the file information in new_ci, make sure\n@@ -2799,7 +2799,7 @@ static void apply_directory_rename_modifications(struct merge_options *opt,\n \t\t\t\tcontinue;\n \t\t\t/* zero out any entries related to files */\n \t\t\tci->stages[i].mode = 0;\n-\t\t\toidcpy(&ci->stages[i].oid, null_oid(the_hash_algo));\n+\t\t\toidcpy(&ci->stages[i].oid, null_oid(opt->repo->hash_algo));\n \t\t}\n \n \t\t/* Now we want to focus on new_ci, so reassign ci to it. */\n@@ -3214,7 +3214,7 @@ static int process_renames(struct merge_options *opt,\n \t\t\tif (type_changed) {\n \t\t\t\t/* rename vs. typechange */\n \t\t\t\t/* Mark the original as resolved by removal */\n-\t\t\t\tmemcpy(&oldinfo->stages[0].oid, null_oid(the_hash_algo),\n+\t\t\t\tmemcpy(&oldinfo->stages[0].oid, null_oid(opt->repo->hash_algo),\n \t\t\t\t       sizeof(oldinfo->stages[0].oid));\n \t\t\t\toldinfo->stages[0].mode = 0;\n \t\t\t\toldinfo->filemask &= 0x06;\n@@ -4102,7 +4102,7 @@ static int process_entry(struct merge_options *opt,\n \t\t\tif (ci->filemask & (1 << i))\n \t\t\t\tcontinue;\n \t\t\tci->stages[i].mode = 0;\n-\t\t\toidcpy(&ci->stages[i].oid, null_oid(the_hash_algo));\n+\t\t\toidcpy(&ci->stages[i].oid, null_oid(opt->repo->hash_algo));\n \t\t}\n \t} else if (ci->df_conflict && ci->merged.result.mode != 0) {\n \t\t/*\n@@ -4149,7 +4149,7 @@ static int process_entry(struct merge_options *opt,\n \t\t\t\tcontinue;\n \t\t\t/* zero out any entries related to directories */\n \t\t\tnew_ci->stages[i].mode = 0;\n-\t\t\toidcpy(&new_ci->stages[i].oid, null_oid(the_hash_algo));\n+\t\t\toidcpy(&new_ci->stages[i].oid, null_oid(opt->repo->hash_algo));\n \t\t}\n \n \t\t/*\n@@ -4271,11 +4271,11 @@ static int process_entry(struct merge_options *opt,\n \t\t\tnew_ci->merged.result.mode = ci->stages[2].mode;\n \t\t\toidcpy(&new_ci->merged.result.oid, &ci->stages[2].oid);\n \t\t\tnew_ci->stages[1].mode = 0;\n-\t\t\toidcpy(&new_ci->stages[1].oid, null_oid(the_hash_algo));\n+\t\t\toidcpy(&new_ci->stages[1].oid, null_oid(opt->repo->hash_algo));\n \t\t\tnew_ci->filemask = 5;\n \t\t\tif ((S_IFMT & b_mode) != (S_IFMT & o_mode)) {\n \t\t\t\tnew_ci->stages[0].mode = 0;\n-\t\t\t\toidcpy(&new_ci->stages[0].oid, null_oid(the_hash_algo));\n+\t\t\t\toidcpy(&new_ci->stages[0].oid, null_oid(opt->repo->hash_algo));\n \t\t\t\tnew_ci->filemask = 4;\n \t\t\t}\n \n@@ -4283,11 +4283,11 @@ static int process_entry(struct merge_options *opt,\n \t\t\tci->merged.result.mode = ci->stages[1].mode;\n \t\t\toidcpy(&ci->merged.result.oid, &ci->stages[1].oid);\n \t\t\tci->stages[2].mode = 0;\n-\t\t\toidcpy(&ci->stages[2].oid, null_oid(the_hash_algo));\n+\t\t\toidcpy(&ci->stages[2].oid, null_oid(opt->repo->hash_algo));\n \t\t\tci->filemask = 3;\n \t\t\tif ((S_IFMT & a_mode) != (S_IFMT & o_mode)) {\n \t\t\t\tci->stages[0].mode = 0;\n-\t\t\t\toidcpy(&ci->stages[0].oid, null_oid(the_hash_algo));\n+\t\t\t\toidcpy(&ci->stages[0].oid, null_oid(opt->repo->hash_algo));\n \t\t\t\tci->filemask = 2;\n \t\t\t}\n \n@@ -4415,7 +4415,7 @@ static int process_entry(struct merge_options *opt,\n \t\t/* Deleted on both sides */\n \t\tci->merged.is_null = 1;\n \t\tci->merged.result.mode = 0;\n-\t\toidcpy(&ci->merged.result.oid, null_oid(the_hash_algo));\n+\t\toidcpy(&ci->merged.result.oid, null_oid(opt->repo->hash_algo));\n \t\tassert(!ci->df_conflict);\n \t\tci->merged.clean = !ci->path_conflict;\n \t}\n-- \ngitgitgadget\n\n"},{"id":"536610","messageId":"42a25768784492a4e8187bad0b070ccb27e980f7.1771718393.git.gitgitgadget@gmail.com","threadId":"65011","inReplyTo":"pull.2048.v3.git.1771718393.gitgitgadget@gmail.com","subject":"[PATCH v3 5/6] merge-ort: prevent the_repository from coming back","fromName":"Elijah Newren via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2026-02-21T23:59:52Z","receivedAt":"2026-02-22T00:00:03Z","isPatch":true,"sender":{"key":"newren@gmail.com","avatar":"https://avatars.githubusercontent.com/u/5455730?v=4"},"body":"From: Elijah Newren <newren@gmail.com>\n\nDue to the use of DEFAULT_ABBREV, we cannot get rid of our usage of\nUSE_THE_REPOSITORY_VARIABLE.  However, we have removed all other uses of\nthe_repository in merge-ort a few times.  But they keep coming back.\n\nDefine the_repository to make it a compilation error so that they don't\ncome back any more.\n\nSigned-off-by: Elijah Newren <newren@gmail.com>\n---\n merge-ort.c | 8 ++++++++\n 1 file changed, 8 insertions(+)\n\ndiff --git a/merge-ort.c b/merge-ort.c\nindex 60b4675f39..00923ce3cd 100644\n--- a/merge-ort.c\n+++ b/merge-ort.c\n@@ -53,6 +53,14 @@\n #include \"unpack-trees.h\"\n #include \"xdiff-interface.h\"\n \n+/*\n+ * We technically need USE_THE_REPOSITORY_VARIABLE above for DEFAULT_ABBREV,\n+ * but do not want more uses of the_repository.  Prevent them.\n+ *\n+ * opt->repo is available; use it instead.\n+ */\n+#define the_repository DO_NOT_USE_THE_REPOSITORY\n+\n /*\n  * We have many arrays of size 3.  Whenever we have such an array, the\n  * indices refer to one of the sides of the three-way merge.  This is so\n-- \ngitgitgadget\n\n"},{"id":"536625","messageId":"xmqqcy1xsds1.fsf@gitster.g","threadId":"65011","inReplyTo":"pull.2048.v3.git.1771718393.gitgitgadget@gmail.com","subject":"Re: [PATCH v3 0/6] Avoid the_repository in merge-ort and replay","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2026-02-22T02:38:54Z","receivedAt":"2026-02-22T02:38:57Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"Elijah Newren via GitGitGadget\" <gitgitgadget@gmail.com> writes:\n\n> Changes since v2:\n>\n>  * In first patch, actually avoid the_repository when attempting to remove\n>    check against the_repository\n>  * Fix commit message of patch 3 due to the new patch 1.\n>  * Slight tweak to commit message of patch 6.\n> ...\n> As noted in the comments on v1, I actually do not know why\n> prefetch_for_content_merges() needs to use the_repository. When I introduced\n> it back in 2bff554b23e8 (merge-ort: add prefetching for content merges,\n> 2021-06-22), I was just looking at diffcore_std() and trying to mimic how it\n> did the prefetch, and it has such a comparison. If anyone knows why\n> diffcore_std() needs to compare against the_repository, I'd love to hear...\n\nIs this comment still current?\n\n> Elijah Newren (6):\n>   merge,diff: remove the_repository check before prefetching blobs\n>   merge-ort: pass repository to write_tree()\n>   merge-ort: replace the_repository with opt->repo\n>   merge-ort: replace the_hash_algo with opt->repo->hash_algo\n>   merge-ort: prevent the_repository from coming back\n>   replay: prevent the_repository from coming back\n\nI do not seem to see the last step on the list archive.\n\nhttps://lore.kernel.org/git/pull.2048.v3.git.1771718393.gitgitgadget@gmail.com/\n\nI'll resurrect it using the previous one and ...\n\n>  6:  67db46f34f ! 6:  0654d04584 replay: prevent the_repository from coming back\n>      @@ Commit message\n>           coming back.\n>       \n>           Define the_repository to make it a compilation error so that they don't\n>      -    come back any more.\n>      +    come back any more; the repo parameter plumbed through the various\n>      +    functions can be used instead.\n>       \n>           Signed-off-by: Elijah Newren <newren@gmail.com>\n\n... this piece of information.\n\n"},{"id":"536628","messageId":"CABPp-BE_FZJ_=-pMPbt_6QxiraLQwSs8DCAgbDwBFkOgczGgUw@mail.gmail.com","threadId":"65011","inReplyTo":"xmqqcy1xsds1.fsf@gitster.g","subject":"Re: [PATCH v3 0/6] Avoid the_repository in merge-ort and replay","fromName":"Elijah Newren","fromEmail":"newren@gmail.com","sentAt":"2026-02-22T05:03:06Z","receivedAt":"2026-02-22T05:03:19Z","isPatch":true,"sender":{"key":"newren@gmail.com","avatar":"https://avatars.githubusercontent.com/u/5455730?v=4"},"body":"On Sat, Feb 21, 2026 at 6:38 PM Junio C Hamano <gitster@pobox.com> wrote:\n>\n> \"Elijah Newren via GitGitGadget\" <gitgitgadget@gmail.com> writes:\n>\n> > Changes since v2:\n> >\n> >  * In first patch, actually avoid the_repository when attempting to remove\n> >    check against the_repository\n> >  * Fix commit message of patch 3 due to the new patch 1.\n> >  * Slight tweak to commit message of patch 6.\n> > ...\n> > As noted in the comments on v1, I actually do not know why\n> > prefetch_for_content_merges() needs to use the_repository. When I introduced\n> > it back in 2bff554b23e8 (merge-ort: add prefetching for content merges,\n> > 2021-06-22), I was just looking at diffcore_std() and trying to mimic how it\n> > did the prefetch, and it has such a comparison. If anyone knows why\n> > diffcore_std() needs to compare against the_repository, I'd love to hear...\n>\n> Is this comment still current?\n\nNo, I should have pulled it out of the cover letter since the commit\nmessage of patch #1 answers this; sorry for the oversight.\n\n> > Elijah Newren (6):\n> >   merge,diff: remove the_repository check before prefetching blobs\n> >   merge-ort: pass repository to write_tree()\n> >   merge-ort: replace the_repository with opt->repo\n> >   merge-ort: replace the_hash_algo with opt->repo->hash_algo\n> >   merge-ort: prevent the_repository from coming back\n> >   replay: prevent the_repository from coming back\n>\n> I do not seem to see the last step on the list archive.\n\nWeird.\n\n> https://lore.kernel.org/git/pull.2048.v3.git.1771718393.gitgitgadget@gmail.com/\n>\n> I'll resurrect it using the previous one and ...\n>\n> >  6:  67db46f34f ! 6:  0654d04584 replay: prevent the_repository from coming back\n> >      @@ Commit message\n> >           coming back.\n> >\n> >           Define the_repository to make it a compilation error so that they don't\n> >      -    come back any more.\n> >      +    come back any more; the repo parameter plumbed through the various\n> >      +    functions can be used instead.\n> >\n> >           Signed-off-by: Elijah Newren <newren@gmail.com>\n>\n> ... this piece of information.\n\nThanks.\n"},{"id":"536677","messageId":"143ab1c8-9f07-4df7-8200-69b5a78a0351@gmail.com","threadId":"65011","inReplyTo":"pull.2048.v3.git.1771718393.gitgitgadget@gmail.com","subject":"Re: [PATCH v3 0/6] Avoid the_repository in merge-ort and replay","fromName":"Derrick Stolee","fromEmail":"stolee@gmail.com","sentAt":"2026-02-23T00:42:33Z","receivedAt":"2026-02-23T00:42:36Z","isPatch":true,"sender":{"key":"stolee@gmail.com","avatar":"https://avatars.githubusercontent.com/u/570044?v=4"},"body":"On 2/21/26 6:59 PM, Elijah Newren via GitGitGadget wrote:\n> Changes since v2:\n> \n>   * In first patch, actually avoid the_repository when attempting to remove\n>     check against the_repository\n>   * Fix commit message of patch 3 due to the new patch 1.\n>   * Slight tweak to commit message of patch 6.\n> \n> Changes since v1:\n> \n>   * Add a preparatory patch removing the_repository check from blob\n>     prefetching in both merge-ort and diff*; it's no longer necessary\n>   * Fix casing mismatch\n>   * Simplify the hammer a bit based on the new first patch, but add some\n>     simple comments explaining it\n> \n> Remove explicit uses of the_repository and the_hash_algo from merge-ort, and\n> since this has now been done multiple times for both merge-ort and replay,\n> implement a small measure to prevent them from returning to either merge-ort\n> or replay.\n> \n\nI reviewed this version (plus patch 6 from v2) and think it is good to go\nas-is. I went back to check the v1 feedback and thought it all valuable and\nresolved by this version.\n\nThanks,\n-Stolee\n\n"},{"id":"536959","messageId":"aZ12rYYwbh1fvrnE@pks.im","threadId":"65011","inReplyTo":"143ab1c8-9f07-4df7-8200-69b5a78a0351@gmail.com","subject":"Re: [PATCH v3 0/6] Avoid the_repository in merge-ort and replay","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2026-02-24T10:00:13Z","receivedAt":"2026-02-24T10:00:19Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"On Sun, Feb 22, 2026 at 07:42:33PM -0500, Derrick Stolee wrote:\n> On 2/21/26 6:59 PM, Elijah Newren via GitGitGadget wrote:\n> > Changes since v2:\n> > \n> >   * In first patch, actually avoid the_repository when attempting to remove\n> >     check against the_repository\n> >   * Fix commit message of patch 3 due to the new patch 1.\n> >   * Slight tweak to commit message of patch 6.\n> > \n> > Changes since v1:\n> > \n> >   * Add a preparatory patch removing the_repository check from blob\n> >     prefetching in both merge-ort and diff*; it's no longer necessary\n> >   * Fix casing mismatch\n> >   * Simplify the hammer a bit based on the new first patch, but add some\n> >     simple comments explaining it\n> > \n> > Remove explicit uses of the_repository and the_hash_algo from merge-ort, and\n> > since this has now been done multiple times for both merge-ort and replay,\n> > implement a small measure to prevent them from returning to either merge-ort\n> > or replay.\n> > \n> \n> I reviewed this version (plus patch 6 from v2) and think it is good to go\n> as-is. I went back to check the v1 feedback and thought it all valuable and\n> resolved by this version.\n\nLikewise. I only had a single comment on v2 that was addressed now.\nThanks!\n\nPatrick\n"}]}