Reworked read-tree.

Subsystems: the rest

2 messages, 2 authors, 2016-06-15 · open the first message on its own page

Reworked read-tree.

From: Junio C Hamano <hidden>
Date: 2016-06-15 22:42:05

Daniel, I do not know what your current status is, but I think
you need something like this.

I was scratching my head figuring out why it passes all the t/
tests but couldn't do a simple 'git-read-tree HEAD'.

---
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);
 		else if (obj->type == tag_type)
-			obj = ((struct tag *) obj)->tagged;
+			obj = deref_tag(obj);
 		else
 			return NULL;
+		if (!obj->parsed)
+			parse_object(obj->sha1);
 	} while (1);
 }

Re: Reworked read-tree.

From: Daniel Barkalow <hidden>
Date: 2016-06-15 22:42:05

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.
quoted hunk
---
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.
 		else
 			return NULL;
+		if (!obj->parsed)
+			parse_object(obj->sha1);
 	} while (1);
 }
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help