From 2de381f919829aec1e35d6c7cc33519295dcd053 Mon Sep 17 00:00:00 2001 From: Petr Baudis Date: Wed, 13 Apr 2005 02:28:48 -0700 Subject: [PATCH] Consolidate the error handling Now there is error() for "library" errors and die() for fatal "application" errors. usage() is now used strictly only for usage errors. Signed-off-by: Petr Baudis --- ls-tree.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'ls-tree.c') diff --git a/ls-tree.c b/ls-tree.c index 05c743ab6a..102b12555b 100644 --- a/ls-tree.c +++ b/ls-tree.c @@ -13,9 +13,9 @@ static int list(unsigned char *sha1) buffer = read_sha1_file(sha1, type, &size); if (!buffer) - usage("unable to read sha1 file"); + die("unable to read sha1 file"); if (strcmp(type, "tree")) - usage("expected a 'tree' node"); + die("expected a 'tree' node"); while (size) { int len = strlen(buffer)+1; unsigned char *sha1 = buffer + len; @@ -24,7 +24,7 @@ static int list(unsigned char *sha1) unsigned char *type; if (size < len + 20 || sscanf(buffer, "%o", &mode) != 1) - usage("corrupt 'tree' file"); + die("corrupt 'tree' file"); buffer = sha1 + 20; size -= len + 20; /* XXX: We do some ugly mode heuristics here. @@ -48,6 +48,6 @@ int main(int argc, char **argv) if (!sha1_file_directory) sha1_file_directory = DEFAULT_DB_ENVIRONMENT; if (list(sha1) < 0) - usage("list failed"); + die("list failed"); return 0; } -- cgit v1.2.3