From: Dorine Tipo <dorine.a.tipo@gmail.com>
To: git@vger.kernel.org
Cc: ps@pks.im, kaartic.sivaraam@gmail.com,
christian.couder@gmail.com, siddharthasthana31@gmail.com,
usmanakinyemi202@gmail.com, Dorine Tipo <dorine.a.tipo@gmail.com>
Subject: [Outreachy PATCH] list-objects-filter-options: pass repository to partial clone helpers
Date: Sun, 25 Oct 2026 22:02:53 +0300 [thread overview]
Message-ID: <20261025190253.2207856-1-dorine.a.tipo@gmail.com> (raw)
partial_clone_register() and partial_clone_get_default_filter_spec()
use `the_repository` to look up promisor remotes and to update the
repository's configuration, which ties them to the main repository of
the process.
Accept the repository as a parameter instead, and have the callers in
builtin/clone.c and builtin/fetch.c pass `the_repository` explicitly.
This moves the dependency on the global one level up, without changing
behavior.
Signed-off-by: Dorine Tipo <dorine.a.tipo@gmail.com>
---
The file no longer uses `the_repository` after this change. I left
USE_THE_REPOSITORY_VARIABLE in place to keep this patch focused, and
can drop it here or in a follow-up, whichever is preferred.
builtin/clone.c | 3 ++-
builtin/fetch.c | 7 +++++--
list-objects-filter-options.c | 14 ++++++++------
list-objects-filter-options.h | 3 +++
4 files changed, 18 insertions(+), 9 deletions(-)
diff --git a/builtin/clone.c b/builtin/clone.c
index 44037dd428..5a6859065e 100644
--- a/builtin/clone.c
+++ b/builtin/clone.c
@@ -1619,7 +1619,8 @@ int cmd_clone(int argc,
remote_head_points_at, &branch_top);
if (filter_options.choice)
- partial_clone_register(remote_name, &filter_options);
+ partial_clone_register(the_repository, remote_name,
+ &filter_options);
if (is_local)
clone_local(path, git_dir);
diff --git a/builtin/fetch.c b/builtin/fetch.c
index 1f76ae6242..5277047476 100644
--- a/builtin/fetch.c
+++ b/builtin/fetch.c
@@ -2436,7 +2436,8 @@ static inline void fetch_one_setup_partial(struct remote *remote,
* remote if there is currently no default filter-spec.
*/
if (filter_options->choice) {
- partial_clone_register(remote->name, filter_options);
+ partial_clone_register(the_repository, remote->name,
+ filter_options);
return;
}
@@ -2446,7 +2447,9 @@ static inline void fetch_one_setup_partial(struct remote *remote,
* the config.
*/
if (!filter_options->choice)
- partial_clone_get_default_filter_spec(filter_options, remote->name);
+ partial_clone_get_default_filter_spec(the_repository,
+ filter_options,
+ remote->name);
return;
}
diff --git a/list-objects-filter-options.c b/list-objects-filter-options.c
index bc5d98f9e6..178624f6f5 100644
--- a/list-objects-filter-options.c
+++ b/list-objects-filter-options.c
@@ -362,6 +362,7 @@ void list_objects_filter_release(
}
void partial_clone_register(
+ struct repository *repo,
const char *remote,
struct list_objects_filter_options *filter_options)
{
@@ -370,7 +371,7 @@ void partial_clone_register(
char *filter_name;
/* Check if it is already registered */
- if ((promisor_remote = repo_promisor_remote_find(the_repository, remote))) {
+ if ((promisor_remote = repo_promisor_remote_find(repo, remote))) {
if (promisor_remote->partial_clone_filter)
/*
* Remote is already registered and a filter is already
@@ -378,12 +379,12 @@ void partial_clone_register(
*/
return;
} else {
- if (upgrade_repository_format(the_repository, 1) < 0)
+ if (upgrade_repository_format(repo, 1) < 0)
die(_("unable to upgrade repository format to support partial clone"));
/* Add promisor config for the remote */
cfg_name = xstrfmt("remote.%s.promisor", remote);
- repo_config_set(the_repository, cfg_name, "true");
+ repo_config_set(repo, cfg_name, "true");
free(cfg_name);
}
@@ -393,19 +394,20 @@ void partial_clone_register(
*/
filter_name = xstrfmt("remote.%s.partialclonefilter", remote);
/* NEEDSWORK: 'expand' result leaking??? */
- repo_config_set(the_repository, filter_name,
+ repo_config_set(repo, filter_name,
expand_list_objects_filter_spec(filter_options));
free(filter_name);
/* Make sure the config info are reset */
- repo_promisor_remote_reinit(the_repository);
+ repo_promisor_remote_reinit(repo);
}
void partial_clone_get_default_filter_spec(
+ struct repository *repo,
struct list_objects_filter_options *filter_options,
const char *remote)
{
- struct promisor_remote *promisor = repo_promisor_remote_find(the_repository,
+ struct promisor_remote *promisor = repo_promisor_remote_find(repo,
remote);
struct strbuf errbuf = STRBUF_INIT;
diff --git a/list-objects-filter-options.h b/list-objects-filter-options.h
index 77d7bbc846..6a349cb4da 100644
--- a/list-objects-filter-options.h
+++ b/list-objects-filter-options.h
@@ -6,6 +6,7 @@
#include "strbuf.h"
struct option;
+struct repository;
/*
* The list of defined filters for list-objects.
@@ -158,9 +159,11 @@ static inline void list_objects_filter_set_no_filter(
}
void partial_clone_register(
+ struct repository *repo,
const char *remote,
struct list_objects_filter_options *filter_options);
void partial_clone_get_default_filter_spec(
+ struct repository *repo,
struct list_objects_filter_options *filter_options,
const char *remote);
--
2.34.1
reply other threads:[~2026-10-25 19:03 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261025190253.2207856-1-dorine.a.tipo@gmail.com \
--to=dorine.a.tipo@gmail.com \
--cc=christian.couder@gmail.com \
--cc=git@vger.kernel.org \
--cc=kaartic.sivaraam@gmail.com \
--cc=ps@pks.im \
--cc=siddharthasthana31@gmail.com \
--cc=usmanakinyemi202@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox