{"thread":{"id":"66686","subject":"[Outreachy PATCH] bundle-uri: use the passed repository for refs and tracing","startedAt":"2026-10-28T09:34:55Z","lastAt":"2026-10-29T13:37:10Z","messageCount":8,"participants":["Okhuomon Ajayi","Karthik Nayak","Junio C Hamano","Patrick Steinhardt"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"556625","messageId":"20261028093455.76247-1-okhuomonajayi54@gmail.com","threadId":"66686","inReplyTo":null,"subject":"[Outreachy PATCH] bundle-uri: use the passed repository for refs and tracing","fromName":"Okhuomon Ajayi","fromEmail":"okhuomonajayi54@gmail.com","sentAt":"2026-10-28T09:34:55Z","receivedAt":"2026-10-28T09:34:55Z","isPatch":true,"sender":{"key":"okhuomonajayi54@gmail.com","avatar":null},"body":"unbundle_from_file() receives r and unbundles the objects into\nit, but reads and writes the refs in the_repository.\nfetch_bundle_uri() also has r, but uses the_repository for its\ntrace2 region.\n\nUse r for both.\n\nSigned-off-by: Okhuomon Ajayi <okhuomonajayi54@gmail.com>\n---\nunbundle_from_file() still depends on the_repository through\nfetch_pack_fsck_objects(), which reads fetch.fsckObjects and\ntransfer.fsckObjects from the_repository's config. I left that out.\n\n bundle-uri.c | 8 ++++----\n 1 file changed, 4 insertions(+), 4 deletions(-)\n\ndiff --git a/bundle-uri.c b/bundle-uri.c\nindex 2bb2eb99e4..0d612d92fe 100644\n--- a/bundle-uri.c\n+++ b/bundle-uri.c\n@@ -448,9 +448,9 @@ static int unbundle_from_file(struct repository *r, const char *file)\n \t\tstrbuf_setlen(&bundle_ref, bundle_prefix_len);\n \t\tstrbuf_addstr(&bundle_ref, branch_name);\n \n-\t\thas_old = !refs_read_ref(get_main_ref_store(the_repository),\n+\t\thas_old = !refs_read_ref(get_main_ref_store(r),\n \t\t\t\t\t bundle_ref.buf, &old_oid);\n-\t\trefs_update_ref(get_main_ref_store(the_repository),\n+\t\trefs_update_ref(get_main_ref_store(r),\n \t\t\t\t\"fetched bundle\", bundle_ref.buf, oid,\n \t\t\t\thas_old ? &old_oid : NULL,\n \t\t\t\t0, UPDATE_REFS_MSG_ON_ERR);\n@@ -859,7 +859,7 @@ int fetch_bundle_uri(struct repository *r, const char *uri,\n \t\t.id = xstrdup(\"\"),\n \t};\n \n-\ttrace2_region_enter(\"fetch\", \"fetch-bundle-uri\", the_repository);\n+\ttrace2_region_enter(\"fetch\", \"fetch-bundle-uri\", r);\n \n \tinit_bundle_list(&list);\n \n@@ -886,7 +886,7 @@ int fetch_bundle_uri(struct repository *r, const char *uri,\n \tfor_all_bundles_in_list(&list, unlink_bundle, NULL);\n \tclear_bundle_list(&list);\n \tclear_remote_bundle_info(&bundle, NULL);\n-\ttrace2_region_leave(\"fetch\", \"fetch-bundle-uri\", the_repository);\n+\ttrace2_region_leave(\"fetch\", \"fetch-bundle-uri\", r);\n \treturn result;\n }\n \n\nbase-commit: 37b3475fb530c14109211faca33716a173db61ed\n-- \n2.56.0\n\n\n"},{"id":"556634","messageId":"CAOLa=ZQK_ZjCj5G+rk2Cz+-hQ054uJW6Eq4NEofQLHx0jnnfWQ@mail.gmail.com","threadId":"66686","inReplyTo":"20261028093455.76247-1-okhuomonajayi54@gmail.com","subject":"Re: [Outreachy PATCH] bundle-uri: use the passed repository for refs and tracing","fromName":"Karthik Nayak","fromEmail":"karthik.188@gmail.com","sentAt":"2026-10-28T11:05:04Z","receivedAt":"2026-10-28T11:05:04Z","isPatch":true,"sender":{"key":"karthik.188@gmail.com","avatar":"https://avatars.githubusercontent.com/u/1786334?v=4"},"body":"Okhuomon Ajayi <okhuomonajayi54@gmail.com> writes:\n\n> unbundle_from_file() receives r and unbundles the objects into\n> it, but reads and writes the refs in the_repository.\n> fetch_bundle_uri() also has r, but uses the_repository for its\n> trace2 region.\n>\n\nLooking at the callers of `unbundle_from_file()` I don't see there is a\nreason for divergence. i.e. both `r` and `the_repository` should point\nto the same repository. So this does make sense to me.\n\nThanks\n"},{"id":"556635","messageId":"CAFpMFfAD1O6WDbvz9oCkfHza8okMAMWs_imEfKFZwjaieHZQ0Q@mail.gmail.com","threadId":"66686","inReplyTo":"CAOLa=ZQK_ZjCj5G+rk2Cz+-hQ054uJW6Eq4NEofQLHx0jnnfWQ@mail.gmail.com","subject":"Re: [Outreachy PATCH] bundle-uri: use the passed repository for refs and tracing","fromName":"Okhuomon Ajayi","fromEmail":"okhuomonajayi54@gmail.com","sentAt":"2026-10-28T11:18:42Z","receivedAt":"2026-10-28T11:18:42Z","isPatch":true,"sender":{"key":"okhuomonajayi54@gmail.com","avatar":null},"body":"On Wed, Oct 28, 2026 at 12:05 PM Karthik Nayak <karthik.188@gmail.com> wrote:\n> Looking at the callers of `unbundle_from_file()` I don't see there is a\n> reason for divergence. i.e. both `r` and `the_repository` should point\n> to the same repository. So this does make sense to me.\n\n\nThanks for checking, Karthik!\n\n"},{"id":"556684","messageId":"xmqqcxstbx4v.fsf@gitster.g","threadId":"66686","inReplyTo":"CAOLa=ZQK_ZjCj5G+rk2Cz+-hQ054uJW6Eq4NEofQLHx0jnnfWQ@mail.gmail.com","subject":"Re: [Outreachy PATCH] bundle-uri: use the passed repository for refs and tracing","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2026-10-28T16:36:16Z","receivedAt":"2026-10-28T16:36:16Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Karthik Nayak <karthik.188@gmail.com> writes:\n\n> Okhuomon Ajayi <okhuomonajayi54@gmail.com> writes:\n>\n>> unbundle_from_file() receives r and unbundles the objects into\n>> it, but reads and writes the refs in the_repository.\n>> fetch_bundle_uri() also has r, but uses the_repository for its\n>> trace2 region.\n>>\n>\n> Looking at the callers of `unbundle_from_file()` I don't see there is a\n> reason for divergence. i.e. both `r` and `the_repository` should point\n> to the same repository. So this does make sense to me.\n>\n> Thanks\n\nThanks.  Will queue and mark it ready for 'next'.\n\n"},{"id":"556767","messageId":"auM3DGcWTL5OdRnD@pks.im","threadId":"66686","inReplyTo":"20261028093455.76247-1-okhuomonajayi54@gmail.com","subject":"Re: [Outreachy PATCH] bundle-uri: use the passed repository for refs and tracing","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2026-10-29T12:07:40Z","receivedAt":"2026-10-29T12:07:40Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"On Wed, Oct 28, 2026 at 10:34:55AM +0100, Okhuomon Ajayi wrote:\n> unbundle_from_file() receives r and unbundles the objects into\n> it, but reads and writes the refs in the_repository.\n> fetch_bundle_uri() also has r, but uses the_repository for its\n> trace2 region.\n> \n> Use r for both.\n\nOkay.\n\n> Signed-off-by: Okhuomon Ajayi <okhuomonajayi54@gmail.com>\n> ---\n> unbundle_from_file() still depends on the_repository through\n> fetch_pack_fsck_objects(), which reads fetch.fsckObjects and\n> transfer.fsckObjects from the_repository's config. I left that out.\n\nThat's fine, we know that subsystems may still implicitly depend on\nit even though they don't declare `USE_THE_REPOSITORY_VARIABLE` anymore.\n\nWhat I find curious though is why you didn't go the last mile so that we\ncould drop that define from this subsystem altogether. There's only two\nsites left that use `the_repository`, and both of them are trivial to\nconvert (see below patch).\n\nSo shouldn't we maybe also fix those cases while already at it and then\ndrop the define?\n\nPatrick\n\ndiff --git a/bundle-uri.c b/bundle-uri.c\nindex 1f1683b52e9..abdb99f4375 100644\n--- a/bundle-uri.c\n+++ b/bundle-uri.c\n@@ -285,7 +285,7 @@ int bundle_uri_parse_config_format(const char *uri,\n \treturn result;\n }\n \n-static char *find_temp_filename(void)\n+static char *find_temp_filename(struct repository *r)\n {\n \tint fd;\n \tstruct strbuf name = STRBUF_INIT;\n@@ -293,7 +293,7 @@ static char *find_temp_filename(void)\n \t * Find a temporary filename that is available. This is briefly\n \t * racy, but unlikely to collide.\n \t */\n-\tfd = odb_mkstemp(the_repository->objects, &name,\n+\tfd = odb_mkstemp(r->objects, &name,\n \t\t\t \"bundles/tmp_uri_XXXXXX\");\n \tif (fd < 0) {\n \t\twarning(_(\"failed to create temporary file\"));\n@@ -383,7 +383,7 @@ static int download_https_uri_to_file(const char *file, const char *uri)\n \treturn result;\n }\n \n-static int copy_uri_to_file(const char *filename, const char *uri)\n+static int copy_uri_to_file(struct repository *r, const char *filename, const char *uri)\n {\n \tconst char *out;\n \n@@ -395,7 +395,7 @@ static int copy_uri_to_file(const char *filename, const char *uri)\n \t\turi = out;\n \n \t/* Copy as a file */\n-\treturn copy_file(the_repository, filename, uri, 0);\n+\treturn copy_file(r, filename, uri, 0);\n }\n \n static int unbundle_from_file(struct repository *r, const char *file)\n@@ -773,12 +773,12 @@ static int fetch_bundle_uri_internal(struct repository *r,\n \t}\n \n \tif (!bundle->file &&\n-\t    !(bundle->file = find_temp_filename())) {\n+\t    !(bundle->file = find_temp_filename(r))) {\n \t\tresult = -1;\n \t\tgoto cleanup;\n \t}\n \n-\tif ((result = copy_uri_to_file(bundle->file, bundle->uri))) {\n+\tif ((result = copy_uri_to_file(r, bundle->file, bundle->uri))) {\n \t\twarning(_(\"failed to download bundle from URI '%s'\"), bundle->uri);\n \t\tgoto cleanup;\n \t}\n\n"},{"id":"556779","messageId":"CAFpMFfAB3_LioY5zwwfbnZMnX7Upkmrj=+Zi-ku2CTbmNUr98Q@mail.gmail.com","threadId":"66686","inReplyTo":"auM3DGcWTL5OdRnD@pks.im","subject":"Re: [Outreachy PATCH] bundle-uri: use the passed repository for refs and tracing","fromName":"Okhuomon Ajayi","fromEmail":"okhuomonajayi54@gmail.com","sentAt":"2026-10-29T12:47:05Z","receivedAt":"2026-10-29T12:47:05Z","isPatch":true,"sender":{"key":"okhuomonajayi54@gmail.com","avatar":null},"body":"On Thu, Oct 29, 2026 at 1:07 PM Patrick Steinhardt <ps@pks.im> wrote:\n> So shouldn't we maybe also fix those cases while already at it and then\n> drop the define?\n\n\nThanks, Patrick. Yes, that makes sense. I applied your diff and\nbundle-uri.c builds\nwithout USE_THE_REPOSITORY_VARIABLE. I'll send a v2 that converts\nfind_temp_filename() and copy_uri_to_file() too and drops the define.\n\nJunio, please hold v1 from 'next'; v2 will replace it.\n\n"},{"id":"556781","messageId":"20261029131325.79176-1-okhuomonajayi54@gmail.com","threadId":"66686","inReplyTo":"auM3DGcWTL5OdRnD@pks.im","subject":"[Outreachy PATCH v2] bundle-uri: stop using the_repository","fromName":"Okhuomon Ajayi","fromEmail":"okhuomonajayi54@gmail.com","sentAt":"2026-10-29T13:13:25Z","receivedAt":"2026-10-29T13:13:25Z","isPatch":true,"sender":{"key":"okhuomonajayi54@gmail.com","avatar":null},"body":"unbundle_from_file() receives r and unbundles the objects into\nit, but reads and writes the refs in the_repository.\nfetch_bundle_uri() also has r, but uses the_repository for its\ntrace2 region. find_temp_filename() and copy_uri_to_file() also\nuse the_repository, even though their only caller,\nfetch_bundle_uri_internal(), has r.\n\nUse r in all of these places, passing it to find_temp_filename()\nand copy_uri_to_file(). With that, bundle-uri.c no longer uses\nthe_repository, so drop USE_THE_REPOSITORY_VARIABLE.\n\nSigned-off-by: Okhuomon Ajayi <okhuomonajayi54@gmail.com>\n---\nChanges since v1:\n- Also pass the repository to find_temp_filename() and\n  copy_uri_to_file(), and drop USE_THE_REPOSITORY_VARIABLE,\n  as suggested by Patrick.\n\nThanks, Patrick, for the suggestion and the diff, and Karthik\nfor the review.\n\nunbundle_from_file() still depends on the_repository through\nfetch_pack_fsck_objects(), which reads fetch.fsckObjects and\ntransfer.fsckObjects from the_repository's config.\n\n bundle-uri.c | 22 +++++++++++-----------\n 1 file changed, 11 insertions(+), 11 deletions(-)\n\ndiff --git a/bundle-uri.c b/bundle-uri.c\nindex 2bb2eb99e4..9797eaed9a 100644\n--- a/bundle-uri.c\n+++ b/bundle-uri.c\n@@ -1,4 +1,3 @@\n-#define USE_THE_REPOSITORY_VARIABLE\n #define DISABLE_SIGN_COMPARE_WARNINGS\n \n #include \"git-compat-util.h\"\n@@ -286,7 +285,7 @@ int bundle_uri_parse_config_format(const char *uri,\n \treturn result;\n }\n \n-static char *find_temp_filename(void)\n+static char *find_temp_filename(struct repository *r)\n {\n \tint fd;\n \tstruct strbuf name = STRBUF_INIT;\n@@ -294,7 +293,7 @@ static char *find_temp_filename(void)\n \t * Find a temporary filename that is available. This is briefly\n \t * racy, but unlikely to collide.\n \t */\n-\tfd = odb_mkstemp(the_repository->objects, &name,\n+\tfd = odb_mkstemp(r->objects, &name,\n \t\t\t \"bundles/tmp_uri_XXXXXX\");\n \tif (fd < 0) {\n \t\twarning(_(\"failed to create temporary file\"));\n@@ -384,7 +383,8 @@ static int download_https_uri_to_file(const char *file, const char *uri)\n \treturn result;\n }\n \n-static int copy_uri_to_file(const char *filename, const char *uri)\n+static int copy_uri_to_file(struct repository *r,\n+\t\t\t    const char *filename, const char *uri)\n {\n \tconst char *out;\n \n@@ -396,7 +396,7 @@ static int copy_uri_to_file(const char *filename, const char *uri)\n \t\turi = out;\n \n \t/* Copy as a file */\n-\treturn copy_file(the_repository, filename, uri, 0);\n+\treturn copy_file(r, filename, uri, 0);\n }\n \n static int unbundle_from_file(struct repository *r, const char *file)\n@@ -448,9 +448,9 @@ static int unbundle_from_file(struct repository *r, const char *file)\n \t\tstrbuf_setlen(&bundle_ref, bundle_prefix_len);\n \t\tstrbuf_addstr(&bundle_ref, branch_name);\n \n-\t\thas_old = !refs_read_ref(get_main_ref_store(the_repository),\n+\t\thas_old = !refs_read_ref(get_main_ref_store(r),\n \t\t\t\t\t bundle_ref.buf, &old_oid);\n-\t\trefs_update_ref(get_main_ref_store(the_repository),\n+\t\trefs_update_ref(get_main_ref_store(r),\n \t\t\t\t\"fetched bundle\", bundle_ref.buf, oid,\n \t\t\t\thas_old ? &old_oid : NULL,\n \t\t\t\t0, UPDATE_REFS_MSG_ON_ERR);\n@@ -774,12 +774,12 @@ static int fetch_bundle_uri_internal(struct repository *r,\n \t}\n \n \tif (!bundle->file &&\n-\t    !(bundle->file = find_temp_filename())) {\n+\t    !(bundle->file = find_temp_filename(r))) {\n \t\tresult = -1;\n \t\tgoto cleanup;\n \t}\n \n-\tif ((result = copy_uri_to_file(bundle->file, bundle->uri))) {\n+\tif ((result = copy_uri_to_file(r, bundle->file, bundle->uri))) {\n \t\twarning(_(\"failed to download bundle from URI '%s'\"), bundle->uri);\n \t\tgoto cleanup;\n \t}\n@@ -859,7 +859,7 @@ int fetch_bundle_uri(struct repository *r, const char *uri,\n \t\t.id = xstrdup(\"\"),\n \t};\n \n-\ttrace2_region_enter(\"fetch\", \"fetch-bundle-uri\", the_repository);\n+\ttrace2_region_enter(\"fetch\", \"fetch-bundle-uri\", r);\n \n \tinit_bundle_list(&list);\n \n@@ -886,7 +886,7 @@ int fetch_bundle_uri(struct repository *r, const char *uri,\n \tfor_all_bundles_in_list(&list, unlink_bundle, NULL);\n \tclear_bundle_list(&list);\n \tclear_remote_bundle_info(&bundle, NULL);\n-\ttrace2_region_leave(\"fetch\", \"fetch-bundle-uri\", the_repository);\n+\ttrace2_region_leave(\"fetch\", \"fetch-bundle-uri\", r);\n \treturn result;\n }\n \n\nbase-commit: 37b3475fb530c14109211faca33716a173db61ed\n-- \n2.56.0\n\n\n"},{"id":"556782","messageId":"auNMBpm4WY1sGUIG@pks.im","threadId":"66686","inReplyTo":"20261029131325.79176-1-okhuomonajayi54@gmail.com","subject":"Re: [Outreachy PATCH v2] bundle-uri: stop using the_repository","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2026-10-29T13:37:10Z","receivedAt":"2026-10-29T13:37:10Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"On Thu, Oct 29, 2026 at 02:13:25PM +0100, Okhuomon Ajayi wrote:\n> Changes since v1:\n> - Also pass the repository to find_temp_filename() and\n>   copy_uri_to_file(), and drop USE_THE_REPOSITORY_VARIABLE,\n>   as suggested by Patrick.\n> \n> Thanks, Patrick, for the suggestion and the diff, and Karthik\n> for the review.\n\nThanks, the diff looks as expected.\n\nPatrick\n\n"}]}