- int ret;
-
- ret = diff_tree_sha1(old, new, base, &diff_options);
- call_diff_flush();
- return ret;
-}
-
-static int diff_root_tree(const unsigned char *new, const char *base)
-{
- int retval;
- void *tree;
- struct tree_desc empty, real;
-
- tree = read_object_with_reference(new, "tree", &real.size, NULL);
- if (!tree)
- die("unable to read root tree (%s)", sha1_to_hex(new));
- real.buf = tree;
-
- empty.buf = "";
- empty.size = 0;
- retval = diff_tree(&empty, &real, base, &diff_options);
- free(tree);
- call_diff_flush();
- return retval;
-}
-
-static const char *generate_header(const unsigned char *commit_sha1,
- const unsigned char *parent_sha1,
- const struct commit *commit)
-{
- static char this_header[16384];
- int offset;
- unsigned long len;
- int abbrev = diff_options.abbrev;
- const char *msg = commit->buffer;
-
- if (!verbose_header)
- return sha1_to_hex(commit_sha1);
-
- len = strlen(msg);
-
- offset = sprintf(this_header, "%s%s ",
- header_prefix,
- diff_unique_abbrev(commit_sha1, abbrev));
- if (commit_sha1 != parent_sha1)
- offset += sprintf(this_header + offset, "(from %s)\n",
- parent_sha1
- ? diff_unique_abbrev(parent_sha1, abbrev)
- : "root");
- else
- offset += sprintf(this_header + offset, "(from parents)\n");
- offset += pretty_print_commit(commit_format, commit, len,
- this_header + offset,
- sizeof(this_header) - offset, abbrev);
- return this_header;
-}
-
-static int diff_tree_commit(const unsigned char *commit_sha1)
-{
- struct commit *commit;
- struct commit_list *parents;
- char name[50];
- unsigned char sha1[20];
-
- sprintf(name, "%s^0", sha1_to_hex(commit_sha1));
- if (get_sha1(name, sha1))