X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=diff-tree.c;h=0f370927dd2496a420af53d137676b6c3c445f75;hb=aba06682473e2d797011f966d66c93043e3ed57a;hp=826812af83f1f267014860f285fc03286bc5329e;hpb=6cbd72f8d5d794112eab68f7e7222c9a0c5d6587;p=git.git diff --git a/diff-tree.c b/diff-tree.c index 826812af8..0f370927d 100644 --- a/diff-tree.c +++ b/diff-tree.c @@ -164,14 +164,13 @@ static int diff_tree_sha1(const unsigned char *old, const unsigned char *new, co { void *tree1, *tree2; unsigned long size1, size2; - char type[20]; int retval; - tree1 = read_sha1_file(old, type, &size1); - if (!tree1 || strcmp(type, "tree")) + tree1 = read_tree_with_tree_or_commit_sha1(old, &size1, 0); + if (!tree1) die("unable to read source tree (%s)", sha1_to_hex(old)); - tree2 = read_sha1_file(new, type, &size2); - if (!tree2 || strcmp(type, "tree")) + tree2 = read_tree_with_tree_or_commit_sha1(new, &size2, 0); + if (!tree2) die("unable to read destination tree (%s)", sha1_to_hex(new)); retval = diff_tree(tree1, size1, tree2, size2, base); free(tree1); @@ -179,6 +178,8 @@ static int diff_tree_sha1(const unsigned char *old, const unsigned char *new, co return retval; } +static char *diff_tree_usage = "diff-tree [-r] [-z] "; + int main(int argc, char **argv) { unsigned char old[20], new[20]; @@ -195,10 +196,10 @@ int main(int argc, char **argv) line_termination = '\0'; continue; } - usage("diff-tree [-r] [-z] "); + usage(diff_tree_usage); } if (argc != 3 || get_sha1_hex(argv[1], old) || get_sha1_hex(argv[2], new)) - usage("diff-tree "); + usage(diff_tree_usage); return diff_tree_sha1(old, new, ""); }