Git development
 help / color / mirror / Atom feed
From: Christian Couder <christian.couder@gmail.com>
To: git@vger.kernel.org
Cc: Junio C Hamano <gitster@pobox.com>,
	Patrick Steinhardt <ps@pks.im>,
	Christian Couder <christian.couder@gmail.com>
Subject: [PATCH v2 1/2] promisor-remote: pass a repository to promisor_remote_reply()
Date: Thu, 26 Nov 2026 15:16:28 +0100	[thread overview]
Message-ID: <20261126141626.914848-5-christian.couder@gmail.com> (raw)
In-Reply-To: <20261126141626.914848-4-christian.couder@gmail.com>

promisor_remote_reply() uses `the_repository` when it calls
filter_promisor_remote(), even though filter_promisor_remote()
already takes a `struct repository *` argument.

Let's add a `struct repository *repo` parameter to
promisor_remote_reply() and pass it down to filter_promisor_remote().
Its two callers, send_capabilities() in "connect.c" and
do_fetch_pack_v2() in "fetch-pack.c", pass `the_repository` for now.

This is a small step towards getting rid of `the_repository`, and it
prepares for a following commit that will make promisor_remote_reply()
check the repository it is passed, to fix a crash when it's called
outside a repository.

No functional change intended.

Signed-off-by: Christian Couder <christian.couder@gmail.com>
---
 connect.c         | 2 +-
 fetch-pack.c      | 2 +-
 promisor-remote.c | 6 ++++--
 promisor-remote.h | 4 +++-
 4 files changed, 9 insertions(+), 5 deletions(-)

diff --git a/connect.c b/connect.c
index 87d2e8bccd..bcd9d65f6e 100644
--- a/connect.c
+++ b/connect.c
@@ -520,7 +520,7 @@ static void send_capabilities(int fd_out, struct packet_reader *reader)
 	}
 	if (server_feature_v2("promisor-remote", &promisor_remote_info)) {
 		char *reply;
-		promisor_remote_reply(promisor_remote_info, &reply);
+		promisor_remote_reply(the_repository, promisor_remote_info, &reply);
 		if (reply) {
 			packet_write_fmt(fd_out, "promisor-remote=%s", reply);
 			free(reply);
diff --git a/fetch-pack.c b/fetch-pack.c
index 55d311c0c3..ff14c28f08 100644
--- a/fetch-pack.c
+++ b/fetch-pack.c
@@ -1699,7 +1699,7 @@ static struct ref *do_fetch_pack_v2(struct fetch_pack_args *args,
 	fsck_options_init(&fsck_options, the_repository, FSCK_OPTIONS_MISSING_GITMODULES);
 
 	if (server_feature_v2("promisor-remote", &promisor_remote_config))
-		promisor_remote_reply(promisor_remote_config, NULL);
+		promisor_remote_reply(the_repository, promisor_remote_config, NULL);
 
 	if (args->filter_options.choice == LOFC_AUTO) {
 		struct strbuf errbuf = STRBUF_INIT;
diff --git a/promisor-remote.c b/promisor-remote.c
index 316d9950aa..85adb66c80 100644
--- a/promisor-remote.c
+++ b/promisor-remote.c
@@ -1373,11 +1373,13 @@ static void filter_promisor_remote(struct repository *repo,
 	}
 }
 
-void promisor_remote_reply(const char *info, char **accepted_out)
+void promisor_remote_reply(struct repository *repo,
+			   const char *info,
+			   char **accepted_out)
 {
 	struct string_list accepted_remotes = STRING_LIST_INIT_NODUP;
 
-	filter_promisor_remote(the_repository, &accepted_remotes, info);
+	filter_promisor_remote(repo, &accepted_remotes, info);
 
 	if (accepted_out) {
 		if (accepted_remotes.nr) {
diff --git a/promisor-remote.h b/promisor-remote.h
index 301f5ac5cb..198fe768e5 100644
--- a/promisor-remote.h
+++ b/promisor-remote.h
@@ -65,7 +65,9 @@ char *promisor_remote_info(struct repository *repo);
  * the names of the accepted promisor remotes separated by ';' if
  * any. See gitprotocol-v2(5).
  */
-void promisor_remote_reply(const char *info, char **accepted_out);
+void promisor_remote_reply(struct repository *repo,
+			   const char *info,
+			   char **accepted_out);
 
 /*
  * Set the 'accepted' flag for some promisor remotes. Useful on the
-- 
2.56.0


  reply	other threads:[~2026-11-26 14:16 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-13  0:06 [PATCH] promisor-remote: fix crash without a repository Christian Couder
2026-11-13 19:42 ` Junio C Hamano
2026-11-16  6:35   ` Patrick Steinhardt
2026-11-16 15:29     ` Junio C Hamano
2026-11-26 14:25       ` Christian Couder
2026-11-26 14:16 ` [PATCH v2 0/2] Fix crash without a repository in ls-remote Christian Couder
2026-11-26 14:16   ` Christian Couder [this message]
2026-11-26 14:16   ` [PATCH v2 2/2] promisor-remote: fix crash without a repository Christian Couder

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=20261126141626.914848-5-christian.couder@gmail.com \
    --to=christian.couder@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=ps@pks.im \
    /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