23
two->path, strlen(two->path), two->mode);
24
}
25
26
-static struct combine_diff_path *intersect_paths(struct combine_diff_path *curr, int n, int num_parent)
26
+static int filename_changed(char status)
27
+{
28
+ return status == 'R' || status == 'C';
29
+}
30
+
31
+static struct combine_diff_path *intersect_paths(
32
+ struct combine_diff_path *curr,
33
+ int n,
34
+ int num_parent,
35
+ int combined_all_paths)
36
{
37
struct diff_queue_struct *q = &diff_queued_diff;
38
struct combine_diff_path *p, **tail = &curr;
30
- int i, cmp;
39
+ int i, j, cmp;
40
41
if (!n) {
42
for (i = 0; i < q->nr; i++) {
59
oidcpy(&p->parent[n].oid, &q->queue[i]->one->oid);
60
p->parent[n].mode = q->queue[i]->one->mode;
61
p->parent[n].status = q->queue[i]->status;
62
+
63
+ if (combined_all_paths &&
64
+ filename_changed(p->parent[n].status)) {
65
+ strbuf_init(&p->parent[n].path, 0);
66
+ strbuf_addstr(&p->parent[n].path,
67
+ q->queue[i]->one->path);
68
+ }
69
*tail = p;
70
tail = &p->next;
71
}
84
if (cmp < 0) {
85
/* p->path not in q->queue[]; drop it */
86
*tail = p->next;
87
+ for (j = 0; j < num_parent; j++)
88
+ if (combined_all_paths &&
89
+ filename_changed(p->parent[j].status))
90
+ strbuf_release(&p->parent[j].path);
91
free(p);
92
continue;
93
}
101
oidcpy(&p->parent[n].oid, &q->queue[i]->one->oid);
102
p->parent[n].mode = q->queue[i]->one->mode;
103
p->parent[n].status = q->queue[i]->status;
104
+ if (combined_all_paths &&
105
+ filename_changed(p->parent[n].status))
106
+ strbuf_addstr(&p->parent[n].path,
107
+ q->queue[i]->one->path);
108
109
tail = &p->next;
110
i++;
984
if (!show_file_header)
985
return;
986
963
- if (added)
964
- dump_quoted_path("--- ", "", "/dev/null",
965
- line_prefix, c_meta, c_reset);
966
- else
967
- dump_quoted_path("--- ", a_prefix, elem->path,
968
- line_prefix, c_meta, c_reset);
987
+ if (rev->combined_all_paths) {
988
+ for (i = 0; i < num_parent; i++) {
989
+ char *path = filename_changed(elem->parent[i].status)
990
+ ? elem->parent[i].path.buf : elem->path;
991
+ if (elem->parent[i].status == DIFF_STATUS_ADDED)
992
+ dump_quoted_path("--- ", "", "/dev/null",
993
+ line_prefix, c_meta, c_reset);
994
+ else
995
+ dump_quoted_path("--- ", a_prefix, path,
996
+ line_prefix, c_meta, c_reset);
997
+ }
998
+ } else {
999
+ if (added)
1000
+ dump_quoted_path("--- ", "", "/dev/null",
1001
+ line_prefix, c_meta, c_reset);
1002
+ else
1003
+ dump_quoted_path("--- ", a_prefix, elem->path,
1004
+ line_prefix, c_meta, c_reset);
1005
+ }
1006
if (deleted)
1007
dump_quoted_path("+++ ", "", "/dev/null",
1008
line_prefix, c_meta, c_reset);
1264
putchar(inter_name_termination);
1265
}
1266
1267
+ for (i = 0; i < num_parent; i++)
1268
+ if (rev->combined_all_paths) {
1269
+ if (filename_changed(p->parent[i].status))
1270
+ write_name_quoted(p->parent[i].path.buf, stdout,
1271
+ inter_name_termination);
1272
+ else
1273
+ write_name_quoted(p->path, stdout,
1274
+ inter_name_termination);
1275
+ }
1276
write_name_quoted(p->path, stdout, line_termination);
1277
}
1278
1370
1371
/* find set of paths that every parent touches */
1372
static struct combine_diff_path *find_paths_generic(const struct object_id *oid,
1327
- const struct oid_array *parents, struct diff_options *opt)
1373
+ const struct oid_array *parents,
1374
+ struct diff_options *opt,
1375
+ int combined_all_paths)
1376
{
1377
struct combine_diff_path *paths = NULL;
1378
int i, num_parent = parents->nr;
1398
opt->output_format = DIFF_FORMAT_NO_OUTPUT;
1399
diff_tree_oid(&parents->oid[i], oid, "", opt);
1400
diffcore_std(opt);
1353
- paths = intersect_paths(paths, i, num_parent);
1401
+ paths = intersect_paths(paths, i, num_parent,
1402
+ combined_all_paths);
1403
1404
/* if showing diff, show it in requested order */
1405
if (opt->output_format != DIFF_FORMAT_NO_OUTPUT &&
1509
* diff(sha1,parent_i) for all i to do the job, specifically
1510
* for parent0.
1511
*/
1463
- paths = find_paths_generic(oid, parents, &diffopts);
1512
+ paths = find_paths_generic(oid, parents, &diffopts,
1513
+ rev->combined_all_paths);
1514
}
1515
else {
1516
int stat_opt;
1585
while (paths) {
1586
struct combine_diff_path *tmp = paths;
1587
paths = paths->next;
1588
+ for (i = 0; i < num_parent; i++)
1589
+ if (rev->combined_all_paths &&
1590
+ filename_changed(tmp->parent[i].status))
1591
+ strbuf_release(&tmp->parent[i].path);
1592
free(tmp);
1593
}
1594