X-Git-Url: https://git.verplant.org/?a=blobdiff_plain;f=rev-tree.c;h=f7dc98b1aaacacedeef059b3424d0a42259bb9b8;hb=de809dbbce497e0d107562615c1d85ff35b4e0c5;hp=c3884e3595cd00f8c1108429060ed195f7506514;hpb=b51ad4314078298194d23d46e2b4473ffd32a88a;p=git.git diff --git a/rev-tree.c b/rev-tree.c index c3884e35..f7dc98b1 100644 --- a/rev-tree.c +++ b/rev-tree.c @@ -1,8 +1,3 @@ -#define _XOPEN_SOURCE /* glibc2 needs this */ -#define _BSD_SOURCE /* for tm.tm_gmtoff */ -#include -#include - #include "cache.h" #include "commit.h" @@ -55,8 +50,12 @@ void process_commit(unsigned char *sha1) { struct commit_list *parents; struct commit *obj = lookup_commit(sha1); - parse_commit(obj); - + + if (obj && obj->object.parsed) + return; + if (!obj || parse_commit(obj)) + die("unable to parse commit (%s)", sha1_to_hex(sha1)); + parents = obj->parents; while (parents) { process_commit(parents->item->object.sha1); @@ -65,7 +64,7 @@ void process_commit(unsigned char *sha1) } /* - * Usage: rev-tree [--edges] [--cache ] [] + * Usage: git-rev-tree [--edges] [--cache ] [] * * The cache-file can be quite important for big trees. This is an * expensive operation if you have to walk the whole chain of @@ -85,8 +84,7 @@ int main(int argc, char **argv) char *arg = argv[i]; if (!strcmp(arg, "--cache")) { - read_cache_file(argv[2]); - i++; + read_cache_file(argv[++i]); continue; } @@ -99,8 +97,8 @@ int main(int argc, char **argv) arg++; basemask |= 1<= MAX_COMMITS || get_sha1_hex(arg, sha1[nr])) - usage("rev-tree [--edges] [--cache ] []"); + if (nr >= MAX_COMMITS || get_sha1(arg, sha1[nr])) + usage("git-rev-tree [--edges] [--cache ] []"); process_commit(sha1[nr]); nr++; }