Skip to content
This repository was archived by the owner on Nov 9, 2017. It is now read-only.

Commit d49f9f1

Browse files
committed
Merge branch 'jc/combine-diff-many-parents' into maint
* jc/combine-diff-many-parents: t4038: add tests for "diff --cc --raw <trees>" combine-diff: lift 32-way limit of combined diff
2 parents 66d12f9 + edbc00e commit d49f9f1

File tree

2 files changed

+31
-14
lines changed

2 files changed

+31
-14
lines changed

combine-diff.c

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -982,14 +982,10 @@ static void show_patch_diff(struct combine_diff_path *elem, int num_parent,
982982
free(sline);
983983
}
984984

985-
#define COLONS "::::::::::::::::::::::::::::::::"
986-
987985
static void show_raw_diff(struct combine_diff_path *p, int num_parent, struct rev_info *rev)
988986
{
989987
struct diff_options *opt = &rev->diffopt;
990-
int i, offset;
991-
const char *prefix;
992-
int line_termination, inter_name_termination;
988+
int line_termination, inter_name_termination, i;
993989

994990
line_termination = opt->line_termination;
995991
inter_name_termination = '\t';
@@ -1000,17 +996,14 @@ static void show_raw_diff(struct combine_diff_path *p, int num_parent, struct re
1000996
show_log(rev);
1001997

1002998
if (opt->output_format & DIFF_FORMAT_RAW) {
1003-
offset = strlen(COLONS) - num_parent;
1004-
if (offset < 0)
1005-
offset = 0;
1006-
prefix = COLONS + offset;
999+
/* As many colons as there are parents */
1000+
for (i = 0; i < num_parent; i++)
1001+
putchar(':');
10071002

10081003
/* Show the modes */
1009-
for (i = 0; i < num_parent; i++) {
1010-
printf("%s%06o", prefix, p->parent[i].mode);
1011-
prefix = " ";
1012-
}
1013-
printf("%s%06o", prefix, p->mode);
1004+
for (i = 0; i < num_parent; i++)
1005+
printf("%06o ", p->parent[i].mode);
1006+
printf("%06o", p->mode);
10141007

10151008
/* Show sha1's */
10161009
for (i = 0; i < num_parent; i++)

t/t4038-diff-combined.sh

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,4 +89,28 @@ test_expect_success 'diagnose truncated file' '
8989
grep "diff --cc file" out
9090
'
9191

92+
test_expect_success 'setup for --cc --raw' '
93+
blob=$(echo file | git hash-object --stdin -w) &&
94+
base_tree=$(echo "100644 blob $blob file" | git mktree) &&
95+
trees= &&
96+
for i in `test_seq 1 40`
97+
do
98+
blob=$(echo file$i | git hash-object --stdin -w) &&
99+
trees="$trees$(echo "100644 blob $blob file" | git mktree)$LF"
100+
done
101+
'
102+
103+
test_expect_success 'check --cc --raw with four trees' '
104+
four_trees=$(echo "$trees" | sed -e 4q) &&
105+
git diff --cc --raw $four_trees $base_tree >out &&
106+
# Check for four leading colons in the output:
107+
grep "^::::[^:]" out
108+
'
109+
110+
test_expect_success 'check --cc --raw with forty trees' '
111+
git diff --cc --raw $trees $base_tree >out &&
112+
# Check for forty leading colons in the output:
113+
grep "^::::::::::::::::::::::::::::::::::::::::[^:]" out
114+
'
115+
92116
test_done

0 commit comments

Comments
 (0)