From: Junio C Hamano <gitster@pobox.com>
To: Clemens Fruhwirth <clemens@endorphin.org>
Cc: git@vger.kernel.org
Subject: Re: [PATCH] fetch: Fix segfault on pull --set-upstream outside a branch.
Date: Tue, 06 Jul 2021 10:57:01 -0700 [thread overview]
Message-ID: <xmqq1r8bl40i.fsf@gitster.g> (raw)
In-Reply-To: <20210706162238.575988-1-clemens@endorphin.org> (Clemens Fruhwirth's message of "Tue, 6 Jul 2021 18:22:38 +0200")
Clemens Fruhwirth <clemens@endorphin.org> writes:
> branch_get("HEAD") can return NULL, when we are outside a branch and
> the user calls pull --set-upstream. Catch this case and warn the user
> to avoid a segfault.
Nit. What do you mean by "outside a branch"? If you mean "when the
HEAD is detached", please say so, and use the same terminology in
your warning message.
Thanks.
>
> Signed-off-by: Clemens Fruhwirth <clemens@endorphin.org>
> ---
> builtin/fetch.c | 4 ++++
> 1 file changed, 4 insertions(+)
>
> diff --git a/builtin/fetch.c b/builtin/fetch.c
> index 9191620e50..1097235b90 100644
> --- a/builtin/fetch.c
> +++ b/builtin/fetch.c
> @@ -1602,6 +1602,10 @@ static int do_fetch(struct transport *transport,
> struct ref *rm;
> struct ref *source_ref = NULL;
>
> + if (!branch) {
> + warning(_("no branch detected to use --set-upstream with."));
> + goto skip;
> + }
> /*
> * We're setting the upstream configuration for the
> * current branch. The relevant upstream is the
next prev parent reply other threads:[~2021-07-06 17:57 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-07-06 16:22 [PATCH] fetch: Fix segfault on pull --set-upstream outside a branch Clemens Fruhwirth
2021-07-06 17:57 ` Junio C Hamano [this message]
2021-07-06 18:03 ` Eric Sunshine
2021-07-06 19:48 ` Junio C Hamano
2021-07-06 19:50 ` Junio C Hamano
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=xmqq1r8bl40i.fsf@gitster.g \
--to=gitster@pobox.com \
--cc=clemens@endorphin.org \
--cc=git@vger.kernel.org \
/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;
as well as URLs for NNTP newsgroup(s).