summaryrefslogtreecommitdiff
path: root/tree.c
diff options
context:
space:
mode:
authorDaniel Barkalow <barkalow@iabervon.org>2005-09-05 02:03:51 -0400
committerJunio C Hamano <junkio@cox.net>2005-09-10 18:27:40 -0700
commit77675e2aff434cb1f0e62540ae42f5716a5a778d (patch)
treec7b22fa699e2f64f3e503cecfa60abead90c9ebe /tree.c
parentc9d023b2a63ef233c63e1b8f95aabac74362719d (diff)
downloadgit-77675e2aff434cb1f0e62540ae42f5716a5a778d.tar.gz
[PATCH] Add a function for getting a struct tree for an ent.
Signed-off-by: Daniel Barkalow <barkalow@iabervon.org> Signed-off-by: Junio C Hamano <junkio@cox.net>
Diffstat (limited to 'tree.c')
-rw-r--r--tree.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/tree.c b/tree.c
index 8f490b8984..315b6a5d1c 100644
--- a/tree.c
+++ b/tree.c
@@ -1,5 +1,7 @@
#include "tree.h"
#include "blob.h"
+#include "commit.h"
+#include "tag.h"
#include "cache.h"
#include <stdlib.h>
@@ -212,3 +214,22 @@ int parse_tree(struct tree *item)
free(buffer);
return ret;
}
+
+struct tree *parse_tree_indirect(const unsigned char *sha1)
+{
+ struct object *obj = parse_object(sha1);
+ do {
+ if (!obj)
+ return NULL;
+ if (obj->type == tree_type)
+ return (struct tree *) obj;
+ else if (obj->type == commit_type)
+ obj = &(((struct commit *) obj)->tree->object);
+ else if (obj->type == tag_type)
+ obj = ((struct tag *) obj)->tagged;
+ else
+ return NULL;
+ if (!obj->parsed)
+ parse_object(obj->sha1);
+ } while (1);
+}