summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: fbab835)
raw | patch | inline | side by side (parent: fbab835)
author | Linus Torvalds <torvalds@ppc970.osdl.org> | |
Wed, 18 May 2005 23:14:22 +0000 (16:14 -0700) | ||
committer | Linus Torvalds <torvalds@ppc970.osdl.org> | |
Wed, 18 May 2005 23:14:22 +0000 (16:14 -0700) |
It's pretty much the same as "lookup_commit()", but it will take
tags too, and look up the commit (if any) associated with them.
tags too, and look up the commit (if any) associated with them.
commit.c | patch | blob | history | |
commit.h | patch | blob | history |
diff --git a/commit.c b/commit.c
index 706c7cba08ebc2100c2dbf63ed1238f39324f750..e83056406f54495fe8a1090a816c425375858d4d 100644 (file)
--- a/commit.c
+++ b/commit.c
+#include "tag.h"
#include "commit.h"
#include "cache.h"
#include <string.h>
const char *commit_type = "commit";
+static struct commit *check_commit(struct object *obj, unsigned char *sha1)
+{
+ if (obj->type != commit_type) {
+ error("Object %s is a %s, not a commit",
+ sha1_to_hex(sha1), obj->type);
+ return NULL;
+ }
+ return (struct commit *) obj;
+}
+
+struct commit *lookup_commit_reference(unsigned char *sha1)
+{
+ struct object *obj = parse_object(sha1);
+
+ if (!obj)
+ return NULL;
+ if (obj->type == tag_type)
+ obj = ((struct tag *)obj)->tagged;
+ return check_commit(obj, sha1);
+}
+
struct commit *lookup_commit(unsigned char *sha1)
{
struct object *obj = lookup_object(sha1);
ret->object.type = commit_type;
return ret;
}
- if (obj->type != commit_type) {
- error("Object %s is a %s, not a commit",
- sha1_to_hex(sha1), obj->type);
- return NULL;
- }
- return (struct commit *) obj;
+ return check_commit(obj, sha1);
}
static unsigned long parse_commit_date(const char *buf)
diff --git a/commit.h b/commit.h
index ce0b436711161d667eb9c067d343b82bad20f21d..620e936bbc70d713ac351af3a2950400579841dc 100644 (file)
--- a/commit.h
+++ b/commit.h
extern const char *commit_type;
struct commit *lookup_commit(unsigned char *sha1);
+struct commit *lookup_commit_reference(unsigned char *sha1);
int parse_commit_buffer(struct commit *item, void *buffer, unsigned long size);