- while (size1 | size2) {
- if (!size1) {
- show_file("+", tree2, size2, base);
- update_tree_entry(&tree2, &size2);
- continue;
- }
- if (!size2) {
- show_file("-", tree1, size1, base);
- update_tree_entry(&tree1, &size1);
- continue;
- }
- switch (compare_tree_entry(tree1, size1, tree2, size2, base)) {
- case -1:
- update_tree_entry(&tree1, &size1);
- continue;
- case 0:
- update_tree_entry(&tree1, &size1);
- /* Fallthrough */
- case 1:
- update_tree_entry(&tree2, &size2);
- continue;
+ static char this_header[16384];
+ int offset;
+ unsigned long len;
+
+ if (!verbose_header)
+ return commit;
+
+ len = strlen(msg);
+ offset = sprintf(this_header, "%s%s (from %s)\n", header_prefix, commit, parent);
+ offset += pretty_print_commit(commit_format, msg, len, this_header + offset, sizeof(this_header) - offset);
+ 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))
+ return -1;
+ name[40] = 0;
+ commit = lookup_commit(sha1);
+
+ /* Root commit? */
+ if (show_root_diff && !commit->parents) {
+ header = generate_header(name, "root", commit->buffer);
+ diff_root_tree(commit_sha1, "");
+ }
+
+ /* More than one parent? */
+ if (ignore_merges && commit->parents && commit->parents->next)
+ return 0;
+
+ for (parents = commit->parents; parents; parents = parents->next) {
+ struct commit *parent = parents->item;
+ header = generate_header(name,
+ sha1_to_hex(parent->object.sha1),
+ commit->buffer);
+ diff_tree_sha1_top(parent->object.sha1, commit_sha1, "");
+ if (!header && verbose_header) {
+ header_prefix = "\ndiff-tree ";
+ /*
+ * Don't print multiple merge entries if we
+ * don't print the diffs.
+ */