{"thread":{"id":"66658","subject":"[Outreachy PATCH] list-objects-filter-options: pass repository to partial clone helpers","startedAt":"2026-10-25T19:02:53Z","lastAt":"2026-10-30T16:59:23Z","messageCount":3,"participants":["Dorine Tipo","Okhuomon Ajayi"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"556222","messageId":"20261025190253.2207856-1-dorine.a.tipo@gmail.com","threadId":"66658","inReplyTo":null,"subject":"[Outreachy PATCH] list-objects-filter-options: pass repository to partial clone helpers","fromName":"Dorine Tipo","fromEmail":"dorine.a.tipo@gmail.com","sentAt":"2026-10-25T19:02:53Z","receivedAt":"2026-10-25T19:02:53Z","isPatch":true,"sender":{"key":"dorine.a.tipo@gmail.com","avatar":null},"body":"partial_clone_register() and partial_clone_get_default_filter_spec()\nuse `the_repository` to look up promisor remotes and to update the\nrepository's configuration, which ties them to the main repository of\nthe process.\n\nAccept the repository as a parameter instead, and have the callers in\nbuiltin/clone.c and builtin/fetch.c pass `the_repository` explicitly.\nThis moves the dependency on the global one level up, without changing\nbehavior.\n\nSigned-off-by: Dorine Tipo <dorine.a.tipo@gmail.com>\n---\nThe file no longer uses `the_repository` after this change. I left\nUSE_THE_REPOSITORY_VARIABLE in place to keep this patch focused, and\ncan drop it here or in a follow-up, whichever is preferred.\n\n builtin/clone.c               |  3 ++-\n builtin/fetch.c               |  7 +++++--\n list-objects-filter-options.c | 14 ++++++++------\n list-objects-filter-options.h |  3 +++\n 4 files changed, 18 insertions(+), 9 deletions(-)\n\ndiff --git a/builtin/clone.c b/builtin/clone.c\nindex 44037dd428..5a6859065e 100644\n--- a/builtin/clone.c\n+++ b/builtin/clone.c\n@@ -1619,7 +1619,8 @@ int cmd_clone(int argc,\n \t\t\t\t     remote_head_points_at, &branch_top);\n \n \tif (filter_options.choice)\n-\t\tpartial_clone_register(remote_name, &filter_options);\n+\t\tpartial_clone_register(the_repository, remote_name,\n+\t\t\t\t       &filter_options);\n \n \tif (is_local)\n \t\tclone_local(path, git_dir);\ndiff --git a/builtin/fetch.c b/builtin/fetch.c\nindex 1f76ae6242..5277047476 100644\n--- a/builtin/fetch.c\n+++ b/builtin/fetch.c\n@@ -2436,7 +2436,8 @@ static inline void fetch_one_setup_partial(struct remote *remote,\n \t * remote if there is currently no default filter-spec.\n \t */\n \tif (filter_options->choice) {\n-\t\tpartial_clone_register(remote->name, filter_options);\n+\t\tpartial_clone_register(the_repository, remote->name,\n+\t\t\t\t       filter_options);\n \t\treturn;\n \t}\n \n@@ -2446,7 +2447,9 @@ static inline void fetch_one_setup_partial(struct remote *remote,\n \t * the config.\n \t */\n \tif (!filter_options->choice)\n-\t\tpartial_clone_get_default_filter_spec(filter_options, remote->name);\n+\t\tpartial_clone_get_default_filter_spec(the_repository,\n+\t\t\t\t\t\t      filter_options,\n+\t\t\t\t\t\t      remote->name);\n \treturn;\n }\n \ndiff --git a/list-objects-filter-options.c b/list-objects-filter-options.c\nindex bc5d98f9e6..178624f6f5 100644\n--- a/list-objects-filter-options.c\n+++ b/list-objects-filter-options.c\n@@ -362,6 +362,7 @@ void list_objects_filter_release(\n }\n \n void partial_clone_register(\n+\tstruct repository *repo,\n \tconst char *remote,\n \tstruct list_objects_filter_options *filter_options)\n {\n@@ -370,7 +371,7 @@ void partial_clone_register(\n \tchar *filter_name;\n \n \t/* Check if it is already registered */\n-\tif ((promisor_remote = repo_promisor_remote_find(the_repository, remote))) {\n+\tif ((promisor_remote = repo_promisor_remote_find(repo, remote))) {\n \t\tif (promisor_remote->partial_clone_filter)\n \t\t\t/*\n \t\t\t * Remote is already registered and a filter is already\n@@ -378,12 +379,12 @@ void partial_clone_register(\n \t\t\t */\n \t\t\treturn;\n \t} else {\n-\t\tif (upgrade_repository_format(the_repository, 1) < 0)\n+\t\tif (upgrade_repository_format(repo, 1) < 0)\n \t\t\tdie(_(\"unable to upgrade repository format to support partial clone\"));\n \n \t\t/* Add promisor config for the remote */\n \t\tcfg_name = xstrfmt(\"remote.%s.promisor\", remote);\n-\t\trepo_config_set(the_repository, cfg_name, \"true\");\n+\t\trepo_config_set(repo, cfg_name, \"true\");\n \t\tfree(cfg_name);\n \t}\n \n@@ -393,19 +394,20 @@ void partial_clone_register(\n \t */\n \tfilter_name = xstrfmt(\"remote.%s.partialclonefilter\", remote);\n \t/* NEEDSWORK: 'expand' result leaking??? */\n-\trepo_config_set(the_repository, filter_name,\n+\trepo_config_set(repo, filter_name,\n \t\t\texpand_list_objects_filter_spec(filter_options));\n \tfree(filter_name);\n \n \t/* Make sure the config info are reset */\n-\trepo_promisor_remote_reinit(the_repository);\n+\trepo_promisor_remote_reinit(repo);\n }\n \n void partial_clone_get_default_filter_spec(\n+\tstruct repository *repo,\n \tstruct list_objects_filter_options *filter_options,\n \tconst char *remote)\n {\n-\tstruct promisor_remote *promisor = repo_promisor_remote_find(the_repository,\n+\tstruct promisor_remote *promisor = repo_promisor_remote_find(repo,\n \t\t\t\t\t\t\t\t     remote);\n \tstruct strbuf errbuf = STRBUF_INIT;\n \ndiff --git a/list-objects-filter-options.h b/list-objects-filter-options.h\nindex 77d7bbc846..6a349cb4da 100644\n--- a/list-objects-filter-options.h\n+++ b/list-objects-filter-options.h\n@@ -6,6 +6,7 @@\n #include \"strbuf.h\"\n \n struct option;\n+struct repository;\n \n /*\n  * The list of defined filters for list-objects.\n@@ -158,9 +159,11 @@ static inline void list_objects_filter_set_no_filter(\n }\n \n void partial_clone_register(\n+\tstruct repository *repo,\n \tconst char *remote,\n \tstruct list_objects_filter_options *filter_options);\n void partial_clone_get_default_filter_spec(\n+\tstruct repository *repo,\n \tstruct list_objects_filter_options *filter_options,\n \tconst char *remote);\n \n-- \n2.34.1\n\n\n"},{"id":"556691","messageId":"CAFpMFfCu6JrUC8i453qBP=AktqcG_9sGX=1-1ekEDCYm_+pkUw@mail.gmail.com","threadId":"66658","inReplyTo":"20261025190253.2207856-1-dorine.a.tipo@gmail.com","subject":"Re: [Outreachy PATCH] list-objects-filter-options: pass repository to partial clone helpers","fromName":"Okhuomon Ajayi","fromEmail":"okhuomonajayi54@gmail.com","sentAt":"2026-10-28T18:00:52Z","receivedAt":"2026-10-28T18:00:52Z","isPatch":true,"sender":{"key":"okhuomonajayi54@gmail.com","avatar":null},"body":"Hi Dorine,\n\nOn Sun, Oct 25, 2026 at 8:03 PM Dorine Tipo <dorine.a.tipo@gmail.com> wrote:\n> The file no longer uses `the_repository` after this change. I left\n> USE_THE_REPOSITORY_VARIABLE in place to keep this patch focused, and\n> can drop it here or in a follow-up, whichever is preferred.\n\nI applied the patch and tried removing the define;\nlist-objects-filter-options.c still builds without it, so I think it\ncan be dropped in this same patch.\n\nThanks.\nOkhuomon\n\n"},{"id":"556937","messageId":"20261030165923.53000-1-dorine.a.tipo@gmail.com","threadId":"66658","inReplyTo":"20261025190253.2207856-1-dorine.a.tipo@gmail.com","subject":"[Outreachy PATCH v2] list-objects-filter-options: pass repository to partial clone helpers","fromName":"Dorine Tipo","fromEmail":"dorine.a.tipo@gmail.com","sentAt":"2026-10-30T16:59:23Z","receivedAt":"2026-10-30T16:59:23Z","isPatch":true,"sender":{"key":"dorine.a.tipo@gmail.com","avatar":null},"body":"partial_clone_register() and partial_clone_get_default_filter_spec()\nuse `the_repository` to look up promisor remotes and to update the\nrepository's configuration, which ties them to the main repository of\nthe process.\n\nAccept the repository as a parameter instead, and have the callers in\nbuiltin/clone.c and builtin/fetch.c pass `the_repository` explicitly.\nThis moves the dependency on the global one level up, without changing\nbehavior.\n\nRemove the USE_THE_REPOSITORY_VARIABLE definition from\nlist-objects-filter-options.c, as the file no longer uses\n`the_repository`.\n\nHelped-by: Okhuomon Ajayi <okhuomonajayi54@gmail.com>\nSigned-off-by: Dorine Tipo <dorine.a.tipo@gmail.com>\n---\nChanges since v1:\n - Drop USE_THE_REPOSITORY_VARIABLE, which is no longer needed\n\n builtin/clone.c               |  3 ++-\n builtin/fetch.c               |  7 +++++--\n list-objects-filter-options.c | 16 ++++++++--------\n list-objects-filter-options.h |  3 +++\n 4 files changed, 18 insertions(+), 11 deletions(-)\n\ndiff --git a/builtin/clone.c b/builtin/clone.c\nindex 44037dd428..5a6859065e 100644\n--- a/builtin/clone.c\n+++ b/builtin/clone.c\n@@ -1619,7 +1619,8 @@ int cmd_clone(int argc,\n \t\t\t\t     remote_head_points_at, &branch_top);\n \n \tif (filter_options.choice)\n-\t\tpartial_clone_register(remote_name, &filter_options);\n+\t\tpartial_clone_register(the_repository, remote_name,\n+\t\t\t\t       &filter_options);\n \n \tif (is_local)\n \t\tclone_local(path, git_dir);\ndiff --git a/builtin/fetch.c b/builtin/fetch.c\nindex 1f76ae6242..5277047476 100644\n--- a/builtin/fetch.c\n+++ b/builtin/fetch.c\n@@ -2436,7 +2436,8 @@ static inline void fetch_one_setup_partial(struct remote *remote,\n \t * remote if there is currently no default filter-spec.\n \t */\n \tif (filter_options->choice) {\n-\t\tpartial_clone_register(remote->name, filter_options);\n+\t\tpartial_clone_register(the_repository, remote->name,\n+\t\t\t\t       filter_options);\n \t\treturn;\n \t}\n \n@@ -2446,7 +2447,9 @@ static inline void fetch_one_setup_partial(struct remote *remote,\n \t * the config.\n \t */\n \tif (!filter_options->choice)\n-\t\tpartial_clone_get_default_filter_spec(filter_options, remote->name);\n+\t\tpartial_clone_get_default_filter_spec(the_repository,\n+\t\t\t\t\t\t      filter_options,\n+\t\t\t\t\t\t      remote->name);\n \treturn;\n }\n \ndiff --git a/list-objects-filter-options.c b/list-objects-filter-options.c\nindex bc5d98f9e6..b74caf3bf7 100644\n--- a/list-objects-filter-options.c\n+++ b/list-objects-filter-options.c\n@@ -1,5 +1,3 @@\n-#define USE_THE_REPOSITORY_VARIABLE\n-\n #include \"git-compat-util.h\"\n #include \"config.h\"\n #include \"gettext.h\"\n@@ -362,6 +360,7 @@ void list_objects_filter_release(\n }\n \n void partial_clone_register(\n+\tstruct repository *repo,\n \tconst char *remote,\n \tstruct list_objects_filter_options *filter_options)\n {\n@@ -370,7 +369,7 @@ void partial_clone_register(\n \tchar *filter_name;\n \n \t/* Check if it is already registered */\n-\tif ((promisor_remote = repo_promisor_remote_find(the_repository, remote))) {\n+\tif ((promisor_remote = repo_promisor_remote_find(repo, remote))) {\n \t\tif (promisor_remote->partial_clone_filter)\n \t\t\t/*\n \t\t\t * Remote is already registered and a filter is already\n@@ -378,12 +377,12 @@ void partial_clone_register(\n \t\t\t */\n \t\t\treturn;\n \t} else {\n-\t\tif (upgrade_repository_format(the_repository, 1) < 0)\n+\t\tif (upgrade_repository_format(repo, 1) < 0)\n \t\t\tdie(_(\"unable to upgrade repository format to support partial clone\"));\n \n \t\t/* Add promisor config for the remote */\n \t\tcfg_name = xstrfmt(\"remote.%s.promisor\", remote);\n-\t\trepo_config_set(the_repository, cfg_name, \"true\");\n+\t\trepo_config_set(repo, cfg_name, \"true\");\n \t\tfree(cfg_name);\n \t}\n \n@@ -393,19 +392,20 @@ void partial_clone_register(\n \t */\n \tfilter_name = xstrfmt(\"remote.%s.partialclonefilter\", remote);\n \t/* NEEDSWORK: 'expand' result leaking??? */\n-\trepo_config_set(the_repository, filter_name,\n+\trepo_config_set(repo, filter_name,\n \t\t\texpand_list_objects_filter_spec(filter_options));\n \tfree(filter_name);\n \n \t/* Make sure the config info are reset */\n-\trepo_promisor_remote_reinit(the_repository);\n+\trepo_promisor_remote_reinit(repo);\n }\n \n void partial_clone_get_default_filter_spec(\n+\tstruct repository *repo,\n \tstruct list_objects_filter_options *filter_options,\n \tconst char *remote)\n {\n-\tstruct promisor_remote *promisor = repo_promisor_remote_find(the_repository,\n+\tstruct promisor_remote *promisor = repo_promisor_remote_find(repo,\n \t\t\t\t\t\t\t\t     remote);\n \tstruct strbuf errbuf = STRBUF_INIT;\n \ndiff --git a/list-objects-filter-options.h b/list-objects-filter-options.h\nindex 77d7bbc846..6a349cb4da 100644\n--- a/list-objects-filter-options.h\n+++ b/list-objects-filter-options.h\n@@ -6,6 +6,7 @@\n #include \"strbuf.h\"\n \n struct option;\n+struct repository;\n \n /*\n  * The list of defined filters for list-objects.\n@@ -158,9 +159,11 @@ static inline void list_objects_filter_set_no_filter(\n }\n \n void partial_clone_register(\n+\tstruct repository *repo,\n \tconst char *remote,\n \tstruct list_objects_filter_options *filter_options);\n void partial_clone_get_default_filter_spec(\n+\tstruct repository *repo,\n \tstruct list_objects_filter_options *filter_options,\n \tconst char *remote);\n \n-- \n2.34.1\n\n\n"}]}