From: Johannes Schindelin <Johannes.Schindelin@gmx.de>
To: Davide Berardi <berardi.dav@gmail.com>
Cc: git@vger.kernel.org
Subject: Re: [PATCH] Segmentation fault on non-commit objects.
Date: Tue, 29 Oct 2019 14:11:23 +0100 (CET) [thread overview]
Message-ID: <nycvar.QRO.7.76.6.1910291408460.46@tvgsbejvaqbjf.bet> (raw)
In-Reply-To: <20191029092735.GA84120@carpenter.lan>
Hi Davide,
[please remove the trailing period character in the commit subject]
On Tue, 29 Oct 2019, Davide Berardi wrote:
> Fixed segmentation fault that can be triggered using
> $ git clone --branch $object $repository
> with object pointing to a non-commit (e.g. a blob).
>
> Signed-off-by: Davide Berardi <berardi.dav@gmail.com>
> ---
> builtin/clone.c | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/builtin/clone.c b/builtin/clone.c
> index f665b28ccc..6ad2d8fe77 100644
> --- a/builtin/clone.c
> +++ b/builtin/clone.c
> @@ -720,6 +720,9 @@ static void update_head(const struct ref *our, const
> struct ref *remote,
> } else if (our) {
> struct commit *c = lookup_commit_reference(the_repository,
> &our->old_oid);
> + /* Check if --branch specifies a non-commit. */
> + if (c == NULL)
> + die(_("unable to update HEAD (cannot find commit)"));
Could the error message maybe repeat whatever the user specified for
`$object`? That would probably be more helpful. Maybe even say "not a
commit"?
Ciao,
Johannes
> /* --branch specifies a non-branch (i.e. tags), detach HEAD */
> update_ref(msg, "HEAD", &c->object.oid, NULL, REF_NO_DEREF,
> UPDATE_REFS_DIE_ON_ERR);
> --
> 2.23.0
>
>
>
next prev parent reply other threads:[~2019-10-29 13:11 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-10-29 9:27 [PATCH] Segmentation fault on non-commit objects Davide Berardi
2019-10-29 13:11 ` Johannes Schindelin [this message]
2019-11-01 0:26 ` Davide Berardi
2019-10-29 14:06 ` Jeff King
2019-10-30 2:44 ` Junio C Hamano
2019-10-31 5:37 ` Jeff King
2019-10-31 10:43 ` Davide Berardi
2019-11-01 0:29 ` Davide Berardi
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
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=nycvar.QRO.7.76.6.1910291408460.46@tvgsbejvaqbjf.bet \
--to=johannes.schindelin@gmx.de \
--cc=berardi.dav@gmail.com \
--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.
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
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 read-only IMAP folder(s) and NNTP newsgroup(s).