aboutsummaryrefslogtreecommitdiff
path: root/diff-tree.c
diff options
context:
space:
mode:
authorPetr Baudis <pasky@ucw.cz>2005-04-13 02:28:48 -0700
committerPetr Baudis <xpasky@machine>2005-04-13 02:28:48 -0700
commit2de381f919829aec1e35d6c7cc33519295dcd053 (patch)
tree3f703cd0cd32a4aa9892bda84c664c36e40f7921 /diff-tree.c
parentbdd4da595a265a091a859754a22688f7351cddee (diff)
downloadgit-2de381f919829aec1e35d6c7cc33519295dcd053.tar.gz
git-2de381f919829aec1e35d6c7cc33519295dcd053.tar.xz
[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 <pasky@ucw.cz>
Diffstat (limited to 'diff-tree.c')
-rw-r--r--diff-tree.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/diff-tree.c b/diff-tree.c
index 1960c2356..04eb933b0 100644
--- a/diff-tree.c
+++ b/diff-tree.c
@@ -11,7 +11,7 @@ static void update_tree_entry(void **bufp, unsigned long *sizep)
int len = strlen(buf) + 1 + 20;
if (size < len)
- usage("corrupt tree file");
+ die("corrupt tree file");
*bufp = buf + len;
*sizep = size - len;
}
@@ -23,7 +23,7 @@ static const unsigned char *extract(void *tree, unsigned long size, const char *
const char *path = strchr(tree, ' ');
if (!path || size < len + 20 || sscanf(tree, "%o", modep) != 1)
- usage("corrupt tree file");
+ die("corrupt tree file");
*pathp = path+1;
return sha1;
}
@@ -64,7 +64,7 @@ static void show_file(const char *prefix, void *tree, unsigned long size, const
tree = read_sha1_file(sha1, type, &size);
if (!tree || strcmp(type, "tree"))
- usage("corrupt tree sha %s", sha1_to_hex(sha1));
+ die("corrupt tree sha %s", sha1_to_hex(sha1));
show_tree(prefix, tree, size, newbase);
@@ -148,7 +148,7 @@ static int diff_tree(void *tree1, unsigned long size1, void *tree2, unsigned lon
update_tree_entry(&tree2, &size2);
continue;
}
- usage("diff-tree: internal error");
+ die("diff-tree: internal error");
}
return 0;
}
@@ -162,10 +162,10 @@ static int diff_tree_sha1(const unsigned char *old, const unsigned char *new, co
tree1 = read_sha1_file(old, type, &size1);
if (!tree1 || strcmp(type, "tree"))
- usage("unable to read source tree");
+ die("unable to read source tree (%s)", sha1_to_hex(old));
tree2 = read_sha1_file(new, type, &size2);
if (!tree2 || strcmp(type, "tree"))
- usage("unable to read destination tree");
+ die("unable to read destination tree (%s)", sha1_to_hex(new));
retval = diff_tree(tree1, size1, tree2, size2, base);
free(tree1);
free(tree2);