-int main(int argc, char **argv)
-{
- unsigned char old[20], new[20];
- void *tree1, *tree2;
- unsigned long size1, size2;
- char type[20];
-
- if (argc != 3 || get_sha1_hex(argv[1], old) || get_sha1_hex(argv[2], new))
- usage("diff-tree <tree sha1> <tree sha1>");
- tree1 = read_sha1_file(old, type, &size1);
- if (!tree1 || strcmp(type, "tree"))
- usage("unable to read source tree");
- tree2 = read_sha1_file(new, type, &size2);
- if (!tree2 || strcmp(type, "tree"))
- usage("unable to read destination tree");
- return diff_tree(tree1, size1, tree2, size2);
+ if (opt->combine_merges)
+ opt->ignore_merges = 0;
+
+ /* We can only do dense combined merges with diff output */
+ if (opt->dense_combined_merges)
+ opt->diffopt.output_format = DIFF_FORMAT_PATCH;
+
+ if (opt->diffopt.output_format == DIFF_FORMAT_PATCH)
+ opt->diffopt.recursive = 1;
+
+ diff_tree_setup_paths(get_pathspec(prefix, argv), opt);
+ diff_setup_done(&opt->diffopt);
+
+ switch (nr_sha1) {
+ case 0:
+ if (!read_stdin)
+ usage(diff_tree_usage);
+ break;
+ case 1:
+ diff_tree_commit_sha1(sha1[0]);
+ break;
+ case 2:
+ diff_tree_sha1(sha1[0], sha1[1], "", &opt->diffopt);
+ log_tree_diff_flush(opt);
+ break;
+ }
+
+ if (!read_stdin)
+ return 0;
+
+ if (opt->diffopt.detect_rename)
+ opt->diffopt.setup |= (DIFF_SETUP_USE_SIZE_CACHE |
+ DIFF_SETUP_USE_CACHE);
+ while (fgets(line, sizeof(line), stdin))
+ diff_tree_stdin(line);
+
+ return 0;