#include "diff.h"
static int silent = 0;
+static int show_root_diff = 0;
static int verbose_header = 0;
static int ignore_merges = 1;
static int recursive = 0;
return ret;
}
+static int diff_root_tree(const unsigned char *new, const char *base)
+{
+ int retval;
+ void *tree;
+ unsigned long size;
+
+ if (generate_patch)
+ diff_setup(detect_rename, 0, 0, 0, 0);
+ tree = read_object_with_reference(new, "tree", &size, 0);
+ if (!tree)
+ die("unable to read root tree (%s)", sha1_to_hex(new));
+ retval = diff_tree("", 0, tree, size, base);
+ free(tree);
+ if (generate_patch)
+ diff_flush();
+ return retval;
+}
+
static int get_one_line(const char *msg, unsigned long len)
{
int ret = 0;
if (!buf)
return -1;
- /* More than one parent? */
- if (ignore_merges) {
- if (!memcmp(buf + 46 + 48, "parent ", 7))
- return 0;
- }
-
if (!name) {
static char commit_name[60];
strcpy(commit_name, sha1_to_hex(commit));
name = commit_name;
}
+ /* Root commit? */
+ if (show_root_diff && memcmp(buf + 46, "parent ", 7)) {
+ header = generate_header(name, "root", buf, size);
+ diff_root_tree(commit, "");
+ }
+
+ /* More than one parent? */
+ if (ignore_merges) {
+ if (!memcmp(buf + 46 + 48, "parent ", 7))
+ return 0;
+ }
+
offset = 46;
while (offset + 48 < size && !memcmp(buf + offset, "parent ", 7)) {
unsigned char parent[20];
read_stdin = 1;
continue;
}
+ if (!strcmp(arg, "--root")) {
+ show_root_diff = 1;
+ continue;
+ }
usage(diff_tree_usage);
}