summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 6683463)
raw | patch | inline | side by side (parent: 6683463)
author | Linus Torvalds <torvalds@ppc970.osdl.org> | |
Sun, 17 Apr 2005 19:40:18 +0000 (12:40 -0700) | ||
committer | Linus Torvalds <torvalds@ppc970.osdl.org> | |
Sun, 17 Apr 2005 19:40:18 +0000 (12:40 -0700) |
Also, make it a fatal error to pass in a non-commit object. The callers
never checked, so better check here.
This simplifies merge-base further. It's now so trivial that it's almost
ridiculous.
never checked, so better check here.
This simplifies merge-base further. It's now so trivial that it's almost
ridiculous.
merge-base.c | patch | blob | history | |
revision.h | patch | blob | history |
diff --git a/merge-base.c b/merge-base.c
index 36ac42008c924e3364b51bfb27cf6ac2c5a89de2..dac5e4b5e0da239dccc0ee1d43ffc6fb35e1a817 100644 (file)
--- a/merge-base.c
+++ b/merge-base.c
* That's some time off, though, and in the meantime we know
* that we have a solution to the eventual expense.
*/
- parse_commit(rev1);
- parse_commit(rev2);
-
- common = common_parent(lookup_rev(rev1), lookup_rev(rev2));
+ common = common_parent(parse_commit(rev1), parse_commit(rev2));
if (!common)
die("no common parent found");
printf("%s\n", sha1_to_hex(common->sha1));
diff --git a/revision.h b/revision.h
index f965f3fc5f66827759223dc9caf63d9abf40ae15..482729575cfe94db3dec486ad5d1811e65e717b4 100644 (file)
--- a/revision.h
+++ b/revision.h
return date;
}
-static int parse_commit(unsigned char *sha1)
+static struct revision * parse_commit(unsigned char *sha1)
{
struct revision *rev = lookup_rev(sha1);
rev->flags |= SEEN;
buffer = bufptr = read_sha1_file(sha1, type, &size);
if (!buffer || strcmp(type, "commit"))
- return -1;
+ die("%s is not a commit object", sha1_to_hex(sha1));
bufptr += 46; /* "tree " + "hex sha1" + "\n" */
while (!memcmp(bufptr, "parent ", 7) && !get_sha1_hex(bufptr+7, parent)) {
add_relationship(rev, parent);
rev->date = parse_commit_date(bufptr);
free(buffer);
}
- return 0;
+ return rev;
}
#endif /* REVISION_H */