[patch] git: report parse_commit() errors in rev-tree.c
- From
- Ingo Molnar <mingo@elte.hu>
- Date
- Apr 14, 2005, 12:05 UTC
- Message-ID
- <20050414120516.GC14065@elte.hu>
- In-Reply-To
- <20050414115800.GB14065@elte.hu>
make actual use of the parse_commit() return value and print a warning, instead of silently ignoring it. Should never trigger on a valid DB.
(alternatively we might use a die() in the sanity check place and could remove all the return code handling?)
Ingo
Signed-off-by: Ingo Molnar <mingo@elte.hu>
--- rev-tree.c.orig +++ rev-tree.c
@@ -64,6 +64,7 @@ static unsigned long parse_commit_date(c static int parse_commit(unsigned char *sha1) { struct revision *rev = lookup_rev(sha1); + int ret = 0; if (!(rev->flags & SEEN)) { void *buffer, *bufptr; @@ -81,13 +82,13 @@ static int parse_commit(unsigned char *s bufptr += 46; /* "tree " + "hex sha1" + "\n" */ while (!memcmp(bufptr, "parent ", 7) && !get_sha1_hex(bufptr+7, parent)) { add_relationship(rev, parent); - parse_commit(parent); + ret |= parse_commit(parent); bufptr += 48; /* "parent " + "hex sha1" + "\n" */ } rev->date = parse_commit_date(bufptr); free(buffer); } - return 0; + return ret; } static void read_cache_file(const char *path) @@ -208,7 +209,8 @@ int main(int argc, char **argv) } if (nr >= MAX_COMMITS || get_sha1_hex(arg, sha1[nr])) usage("rev-tree [--edges] [--cache <cache-file>] <commit-id> [<commit-id>]"); - parse_commit(sha1[nr]); + if (parse_commit(sha1[nr])) + fprintf(stderr, "warning: rev-tree: bad commit!\n"); nr++; }