git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] Segmentation fault on non-commit objects.

From
Johannes Schindelin <johannes.schindelin@gmx.de>
Date
Oct 29, 2019, 13:11 UTC
Message-ID
<nycvar.QRO.7.76.6.1910291408460.46@tvgsbejvaqbjf.bet>
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:
Show 21 quoted lines
> 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

Show 8 quoted lines
> 		/* --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
>
>
>
Previous: Davide BerardiNext: Davide Berardi
Message 2 of 8 in “Segmentation fault on non-commit objects.”
  1. Segmentation fault on non-commit objects.Davide Berardi, Oct 29, 2019
  2. Johannes SchindelinOct 29, 2019
  3. Davide BerardiNov 1, 2019
  4. Jeff KingOct 29, 2019
  5. Junio C HamanoOct 30, 2019
  6. Jeff KingOct 31, 2019
  7. Davide BerardiOct 31, 2019
  8. Davide BerardiNov 1, 2019

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.