All of lore.kernel.org
 help / color / mirror / Atom feed
From: Patrick Steinhardt <ps@pks.im>
To: Christian Couder <christian.couder@gmail.com>
Cc: git@vger.kernel.org, Junio C Hamano <gitster@pobox.com>
Subject: Re: [PATCH v2 2/2] promisor-remote: fix crash without a repository
Date: Tue, 1 Dec 2026 08:40:20 +0100	[thread overview]
Message-ID: <aw555MxNdMwTvtQ1@pks.im> (raw)
In-Reply-To: <20261126141626.914848-6-christian.couder@gmail.com>

On Thu, Nov 26, 2026 at 03:16:29PM +0100, Christian Couder wrote:
> diff --git a/promisor-remote.c b/promisor-remote.c
> index 85adb66c80..b37ec23a3f 100644
> --- a/promisor-remote.c
> +++ b/promisor-remote.c
> @@ -1379,6 +1379,17 @@ void promisor_remote_reply(struct repository *repo,
>  {
>  	struct string_list accepted_remotes = STRING_LIST_INIT_NODUP;
>  
> +	/*
> +	 * We can be called outside a repository, for example by
> +	 * "git ls-remote", which has no use for promisor remotes.
> +	 * Not replying is fine then (see gitprotocol-v2(5)).
> +	 */
> +	if (!repo || !repo->gitdir) {
> +		if (accepted_out)
> +			*accepted_out = NULL;
> +		return;
> +	}

Yup, makes sense. We could add a NEEDSWORK comment here that says that
we'd eventually want to get rid of `!repo->gitdir`. But I think the
current version is good enough.

> diff --git a/t/t5710-promisor-remote-capability.sh b/t/t5710-promisor-remote-capability.sh
> index 463e9e00b0..50a73ec8b0 100755
> --- a/t/t5710-promisor-remote-capability.sh
> +++ b/t/t5710-promisor-remote-capability.sh
> @@ -813,6 +813,37 @@ test_expect_success "clone with invalid promisor.acceptFromServerUrl" '
>  	initialize_server 1 "$oid"
>  '
>  
> +test_expect_success "ls-remote without a repo doesn't auto-configure" '
> +	git -C server config promisor.advertise true &&
> +
> +	nongit git -c promisor.acceptFromServerUrl="$ENCODED_TRASH_DIRECTORY_URL/*" \
> +		ls-remote "$TRASH_DIRECTORY_URL/server" >out 2>&1 &&
> +
> +	# Refs are properly listed
> +	test_grep "refs/heads/" out &&
> +
> +	# No remote is configured
> +	test_grep ! "Auto-creating" out
> +'
> +
> +test_expect_success "ls-remote without a repo doesn't store fields" '
> +	git -C server config promisor.advertise true &&
> +	test_config -C server promisor.sendFields token &&
> +	test_config -C server remote.lop.token "fooBar" &&
> +
> +	nongit git -c promisor.acceptFromServer=All \
> +		-c promisor.storeFields=token \
> +		-c remote.lop.promisor=true \
> +		-c remote.lop.url="$TRASH_DIRECTORY_URL/lop" \
> +		ls-remote "$TRASH_DIRECTORY_URL/server" >out 2>&1 &&
> +
> +	# Refs are properly listed
> +	test_grep "refs/heads/" out &&
> +
> +	# No field is stored
> +	test_grep ! "Storing new token" out
> +'

Both tests fail indeed without the changes.

So overall this looks good to me, thanks!

Patrick

      reply	other threads:[~2026-12-01  7:40 UTC|newest]

Thread overview: 9+ 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   ` [PATCH v2 1/2] promisor-remote: pass a repository to promisor_remote_reply() Christian Couder
2026-11-26 14:16   ` [PATCH v2 2/2] promisor-remote: fix crash without a repository Christian Couder
2026-12-01  7:40     ` Patrick Steinhardt [this message]

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=aw555MxNdMwTvtQ1@pks.im \
    --to=ps@pks.im \
    --cc=christian.couder@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.