summaryrefslogtreecommitdiff
path: root/object.c
diff options
context:
space:
mode:
authorDaniel Barkalow <barkalow@iabervon.org>2005-06-21 20:35:10 -0400
committerLinus Torvalds <torvalds@ppc970.osdl.org>2005-06-21 18:29:12 -0700
commit89e4202f9828c18f5db4db80a008a2a8a458855e (patch)
tree18d3bfddecf89de84930ddb66aedc37e9cbd56a7 /object.c
parent9661c256400d1a17a27e014592f887359f74707e (diff)
downloadgit-89e4202f9828c18f5db4db80a008a2a8a458855e.tar.gz
[PATCH] Parse tags for absent objects
Handle parsing a tag for a non-present object. This adds a function to lookup an object with lookup_* for * in a string, so that it can get the right storage based on the "type" line in the tag. Signed-off-by: Daniel Barkalow <barkalow@iabervon.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'object.c')
-rw-r--r--object.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/object.c b/object.c
index 5e83788570..21f872ee16 100644
--- a/object.c
+++ b/object.c
@@ -98,6 +98,22 @@ void mark_reachable(struct object *obj, unsigned int mask)
}
}
+struct object *lookup_object_type(const unsigned char *sha1, const char *type)
+{
+ if (!strcmp(type, blob_type)) {
+ return &lookup_blob(sha1)->object;
+ } else if (!strcmp(type, tree_type)) {
+ return &lookup_tree(sha1)->object;
+ } else if (!strcmp(type, commit_type)) {
+ return &lookup_commit(sha1)->object;
+ } else if (!strcmp(type, tag_type)) {
+ return &lookup_tag(sha1)->object;
+ } else {
+ error("Unknown type %s", type);
+ return NULL;
+ }
+}
+
struct object *parse_object(const unsigned char *sha1)
{
unsigned long mapsize;