return shown_header;
}
-int diff_tree_combined_merge(const unsigned char *sha1,
- const char *header, int dense)
+#define COLONS "::::::::::::::::::::::::::::::::"
+
+static void show_raw_diff(struct combine_diff_path *p, int num_parent, const char *header, struct diff_options *opt)
+{
+ int i, offset, mod_type = 'A';
+ const char *prefix;
+ int line_termination, inter_name_termination;
+
+ line_termination = opt->line_termination;
+ inter_name_termination = '\t';
+ if (!line_termination)
+ inter_name_termination = 0;
+
+ if (header)
+ puts(header);
+ offset = strlen(COLONS) - num_parent;
+ if (offset < 0)
+ offset = 0;
+ prefix = COLONS + offset;
+
+ /* Show the modes */
+ for (i = 0; i < num_parent; i++) {
+ int mode = p->parent[i].mode;
+ if (mode)
+ mod_type = 'M';
+ printf("%s%06o", prefix, mode);
+ prefix = " ";
+ }
+ printf("%s%06o", prefix, p->mode);
+ if (!p->mode)
+ mod_type = 'D';
+
+ /* Show sha1's */
+ for (i = 0; i < num_parent; i++) {
+ printf("%s%s", prefix, diff_unique_abbrev(p->parent[i].sha1, opt->abbrev));
+ prefix = " ";
+ }
+ printf("%s%s", prefix, diff_unique_abbrev(p->sha1, opt->abbrev));
+
+ /* Modification type, terminations, filename */
+ printf(" %c%c%s%c", mod_type, inter_name_termination, p->path, line_termination);
+}
+
+const char *diff_tree_combined_merge(const unsigned char *sha1,
+ const char *header, int dense,
+ struct diff_options *opt)
{
struct commit *commit = lookup_commit(sha1);
struct diff_options diffopts;
for (p = paths; p; p = p->next) {
if (!p->len)
continue;
+ if (opt->output_format == DIFF_FORMAT_RAW) {
+ show_raw_diff(p, num_parent, header, opt);
+ header = NULL;
+ continue;
+ }
if (show_combined_diff(p, num_parent, dense, header))
header = NULL;
}
paths = paths->next;
free(tmp);
}
- return 0;
+ return header;
}
static int no_commit_id = 0;
static int verbose_header = 0;
static int ignore_merges = 1;
-static int combine_merges = 0;
+static int combine_merges = 1;
static int dense_combined_merges = 0;
static int read_stdin = 0;
static int always_show_header = 0;
return 0;
else if (combine_merges) {
header = generate_header(sha1, sha1, commit);
- return diff_tree_combined_merge(sha1, header,
- dense_combined_merges);
+ header = diff_tree_combined_merge(sha1, header,
+ dense_combined_merges,
+ &diff_options);
+ if (!header && verbose_header)
+ header_prefix = "\ndiff-tree ";
+ return 0;
}
}
usage(diff_tree_usage);
}
- if (combine_merges) {
- diff_options.output_format = DIFF_FORMAT_PATCH;
+ if (combine_merges)
ignore_merges = 0;
- }
+
+ /* We can only do dense combined merges with diff output */
+ if (dense_combined_merges)
+ diff_options.output_format = DIFF_FORMAT_PATCH;
if (diff_options.output_format == DIFF_FORMAT_PATCH)
diff_options.recursive = 1;
(sizeof(struct combine_diff_path) + \
sizeof(struct combine_diff_parent) * (n) + (l) + 1)
-int show_combined_diff(struct combine_diff_path *elem, int num_parent,
- int dense, const char *header);
+extern int show_combined_diff(struct combine_diff_path *elem, int num_parent,
+ int dense, const char *header);
-extern int diff_tree_combined_merge(const unsigned char *sha1, const char *, int);
+extern const char *diff_tree_combined_merge(const unsigned char *sha1, const char *, int, struct diff_options *opt);
extern void diff_addremove(struct diff_options *,
int addremove,