summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: c9d023b)
raw | patch | inline | side by side (parent: c9d023b)
author | Daniel Barkalow <barkalow@iabervon.org> | |
Mon, 5 Sep 2005 06:03:51 +0000 (02:03 -0400) | ||
committer | Junio C Hamano <junkio@cox.net> | |
Sun, 11 Sep 2005 01:27:40 +0000 (18:27 -0700) |
Signed-off-by: Daniel Barkalow <barkalow@iabervon.org>
Signed-off-by: Junio C Hamano <junkio@cox.net>
Signed-off-by: Junio C Hamano <junkio@cox.net>
tree.c | patch | blob | history | |
tree.h | patch | blob | history |
index 8f490b8984bf95a13720ffb2d9b23a2dd8c03394..315b6a5d1ce0e83fc75a399a3b74e51f46c5b392 100644 (file)
--- a/tree.c
+++ b/tree.c
#include "tree.h"
#include "blob.h"
+#include "commit.h"
+#include "tag.h"
#include "cache.h"
#include <stdlib.h>
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);
+}
index 0df065ae363c016b17db26f00b982396baf066db..9975e88216dc6924c1d6e9ec3c7ae6d90c2df1dd 100644 (file)
--- a/tree.h
+++ b/tree.h
int parse_tree(struct tree *tree);
+/* Parses and returns the tree in the given ent, chasing tags and commits. */
+struct tree *parse_tree_indirect(const unsigned char *sha1);
+
#endif /* TREE_H */