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

Re: Reworked read-tree.

From
Daniel Barkalow <barkalow@iabervon.org>
Date
Sep 1, 2005, 15:55 UTC
Message-ID
<Pine.LNX.4.63.0509011143350.23242@iabervon.org>
In-Reply-To
<7vpsrt1cwc.fsf_-_@assigned-by-dhcp.cox.net>
On Thu, 1 Sep 2005, Junio C Hamano wrote:
> Daniel, I do not know what your current status is, but I think
> you need something like this.
Yup, I forgot to actually test that functionality.
Show 10 quoted lines
> ---
> diff --git a/tree.c b/tree.c
> --- a/tree.c
> +++ b/tree.c
> @@ -224,10 +224,12 @@ struct tree *parse_tree_indirect(const u
>  		if (obj->type == tree_type)
>  			return (struct tree *) obj;
>  		else if (obj->type == commit_type)
> -			return ((struct commit *) obj)->tree;
> +			obj = (struct object *)(((struct commit *) obj)->tree);
obj = &((struct commit *) obj)->tree->object;

Multiple sequential casts always bother me, and we do actually have a field for this.

>  		else if (obj->type == tag_type)
> -			obj = ((struct tag *) obj)->tagged;
> +			obj = deref_tag(obj);

Shouldn't be necessary (once you've got the parse_object below); we're already in a loop dereferencing things.

Show 8 quoted lines
>  		else
>  			return NULL;
> +		if (!obj->parsed)
> +			parse_object(obj->sha1);
>  	} while (1);
>  }
> 
> 
Previous: Junio C Hamano
Message 7 of 7 in “Couple of read-tree questions”
  1. Daniel BarkalowSep 1, 2005
  2. Junio C HamanoSep 1, 2005
  3. Junio C HamanoSep 1, 2005
  4. Daniel BarkalowSep 1, 2005
  5. Junio C HamanoSep 1, 2005
  6. Reworked read-tree.Junio C Hamano, Sep 1, 2005
  7. Daniel BarkalowSep 1, 2005

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.