🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: linux.kernel.git
3 messages
3 total messages Started by Dorine Tipo Sun, 25 Oct 2026 19:02
[Outreachy PATCH] list-objects-filter-options: pass repository to partial clone helpers
#1438
Author: Dorine Tipo
Date: Sun, 25 Oct 2026 19:02
148 lines
15423 bytes
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
Re: [Outreachy PATCH] list-objects-filter-options: pass repository to partial clone helpers
#1759
Author: Okhuomon Ajayi
Date: Wed, 28 Oct 2026 18:00
15 lines
12337 bytes
Hi Dorine,

On Sun, Oct 25, 2026 at 8:03 PM Dorine Tipo <dorine.a.tipo@gmail.com> wrote:
> 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.

I applied the patch and tried removing the define;
list-objects-filter-options.c still builds without it, so I think it
can be dropped in this same patch.

Thanks.
Okhuomon
[Outreachy PATCH v2] list-objects-filter-options: pass repository to partial clone helpers
#1937
Author: Dorine Tipo
Date: Fri, 30 Oct 2026 16:59
158 lines
15954 bytes
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.

Remove the USE_THE_REPOSITORY_VARIABLE definition from
list-objects-filter-options.c, as the file no longer uses
`the_repository`.

Helped-by: Okhuomon Ajayi <okhuomonajayi54@gmail.com>
Signed-off-by: Dorine Tipo <dorine.a.tipo@gmail.com>
---
Changes since v1:
 - Drop USE_THE_REPOSITORY_VARIABLE, which is no longer needed

 builtin/clone.c               |  3 ++-
 builtin/fetch.c               |  7 +++++--
 list-objects-filter-options.c | 16 ++++++++--------
 list-objects-filter-options.h |  3 +++
 4 files changed, 18 insertions(+), 11 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..b74caf3bf7 100644
--- a/list-objects-filter-options.c
+++ b/list-objects-filter-options.c
@@ -1,5 +1,3 @@
-#define USE_THE_REPOSITORY_VARIABLE
-
 #include "git-compat-util.h"
 #include "config.h"
 #include "gettext.h"
@@ -362,6 +360,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 +369,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 +377,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 +392,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
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads