Skip to content

Commit 34415c7

Browse files
committed
Merge branch 'so/combine-diff-simplify'
Code simplification. * so/combine-diff-simplify: diff: get rid of redundant 'dense' argument
2 parents 58138d3 + d01141d commit 34415c7

File tree

6 files changed

+18
-23
lines changed

6 files changed

+18
-23
lines changed

builtin/diff.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -203,8 +203,7 @@ static int builtin_diff_combined(struct rev_info *revs,
203203
revs->dense_combined_merges = revs->combine_merges = 1;
204204
for (i = 1; i < ents; i++)
205205
oid_array_append(&parents, &ent[i].item->oid);
206-
diff_tree_combined(&ent[0].item->oid, &parents,
207-
revs->dense_combined_merges, revs);
206+
diff_tree_combined(&ent[0].item->oid, &parents, revs);
208207
oid_array_clear(&parents);
209208
return 0;
210209
}

combine-diff.c

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -923,7 +923,6 @@ static void dump_quoted_path(const char *head,
923923

924924
static void show_combined_header(struct combine_diff_path *elem,
925925
int num_parent,
926-
int dense,
927926
struct rev_info *rev,
928927
const char *line_prefix,
929928
int mode_differs,
@@ -939,6 +938,7 @@ static void show_combined_header(struct combine_diff_path *elem,
939938
int added = 0;
940939
int deleted = 0;
941940
int i;
941+
int dense = rev->dense_combined_merges;
942942

943943
if (rev->loginfo && !rev->no_commit_id)
944944
show_log(rev);
@@ -1012,7 +1012,7 @@ static void show_combined_header(struct combine_diff_path *elem,
10121012
}
10131013

10141014
static void show_patch_diff(struct combine_diff_path *elem, int num_parent,
1015-
int dense, int working_tree_file,
1015+
int working_tree_file,
10161016
struct rev_info *rev)
10171017
{
10181018
struct diff_options *opt = &rev->diffopt;
@@ -1145,7 +1145,7 @@ static void show_patch_diff(struct combine_diff_path *elem, int num_parent,
11451145
}
11461146
}
11471147
if (is_binary) {
1148-
show_combined_header(elem, num_parent, dense, rev,
1148+
show_combined_header(elem, num_parent, rev,
11491149
line_prefix, mode_differs, 0);
11501150
printf("Binary files differ\n");
11511151
free(result);
@@ -1200,10 +1200,10 @@ static void show_patch_diff(struct combine_diff_path *elem, int num_parent,
12001200
textconv, elem->path, opt->xdl_opts);
12011201
}
12021202

1203-
show_hunks = make_hunks(sline, cnt, num_parent, dense);
1203+
show_hunks = make_hunks(sline, cnt, num_parent, rev->dense_combined_merges);
12041204

12051205
if (show_hunks || mode_differs || working_tree_file) {
1206-
show_combined_header(elem, num_parent, dense, rev,
1206+
show_combined_header(elem, num_parent, rev,
12071207
line_prefix, mode_differs, 1);
12081208
dump_sline(sline, line_prefix, cnt, num_parent,
12091209
opt->use_color, result_deleted);
@@ -1284,7 +1284,6 @@ static void show_raw_diff(struct combine_diff_path *p, int num_parent, struct re
12841284
*/
12851285
void show_combined_diff(struct combine_diff_path *p,
12861286
int num_parent,
1287-
int dense,
12881287
struct rev_info *rev)
12891288
{
12901289
struct diff_options *opt = &rev->diffopt;
@@ -1294,7 +1293,7 @@ void show_combined_diff(struct combine_diff_path *p,
12941293
DIFF_FORMAT_NAME_STATUS))
12951294
show_raw_diff(p, num_parent, rev);
12961295
else if (opt->output_format & DIFF_FORMAT_PATCH)
1297-
show_patch_diff(p, num_parent, dense, 1, rev);
1296+
show_patch_diff(p, num_parent, 1, rev);
12981297
}
12991298

13001299
static void free_combined_pair(struct diff_filepair *pair)
@@ -1454,7 +1453,6 @@ static struct combine_diff_path *find_paths_multitree(
14541453

14551454
void diff_tree_combined(const struct object_id *oid,
14561455
const struct oid_array *parents,
1457-
int dense,
14581456
struct rev_info *rev)
14591457
{
14601458
struct diff_options *opt = &rev->diffopt;
@@ -1581,8 +1579,7 @@ void diff_tree_combined(const struct object_id *oid,
15811579
printf("%s%c", diff_line_prefix(opt),
15821580
opt->line_termination);
15831581
for (p = paths; p; p = p->next)
1584-
show_patch_diff(p, num_parent, dense,
1585-
0, rev);
1582+
show_patch_diff(p, num_parent, 0, rev);
15861583
}
15871584
}
15881585

@@ -1600,7 +1597,7 @@ void diff_tree_combined(const struct object_id *oid,
16001597
clear_pathspec(&diffopts.pathspec);
16011598
}
16021599

1603-
void diff_tree_combined_merge(const struct commit *commit, int dense,
1600+
void diff_tree_combined_merge(const struct commit *commit,
16041601
struct rev_info *rev)
16051602
{
16061603
struct commit_list *parent = get_saved_parents(rev, commit);
@@ -1610,6 +1607,6 @@ void diff_tree_combined_merge(const struct commit *commit, int dense,
16101607
oid_array_append(&parents, &parent->item->object.oid);
16111608
parent = parent->next;
16121609
}
1613-
diff_tree_combined(&commit->object.oid, &parents, dense, rev);
1610+
diff_tree_combined(&commit->object.oid, &parents, rev);
16141611
oid_array_clear(&parents);
16151612
}

diff-lib.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -177,9 +177,7 @@ int run_diff_files(struct rev_info *revs, unsigned int option)
177177
i--;
178178

179179
if (revs->combine_merges && num_compare_stages == 2) {
180-
show_combined_diff(dpath, 2,
181-
revs->dense_combined_merges,
182-
revs);
180+
show_combined_diff(dpath, 2, revs);
183181
free(dpath);
184182
continue;
185183
}
@@ -361,7 +359,7 @@ static int show_modified(struct rev_info *revs,
361359
p->parent[1].status = DIFF_STATUS_MODIFIED;
362360
p->parent[1].mode = old_entry->ce_mode;
363361
oidcpy(&p->parent[1].oid, &old_entry->oid);
364-
show_combined_diff(p, 2, revs->dense_combined_merges, revs);
362+
show_combined_diff(p, 2, revs);
365363
free(p);
366364
return 0;
367365
}

diff.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -452,11 +452,11 @@ struct combine_diff_path {
452452
st_mult(sizeof(struct combine_diff_parent), (n)))
453453

454454
void show_combined_diff(struct combine_diff_path *elem, int num_parent,
455-
int dense, struct rev_info *);
455+
struct rev_info *);
456456

457-
void diff_tree_combined(const struct object_id *oid, const struct oid_array *parents, int dense, struct rev_info *rev);
457+
void diff_tree_combined(const struct object_id *oid, const struct oid_array *parents, struct rev_info *rev);
458458

459-
void diff_tree_combined_merge(const struct commit *commit, int dense, struct rev_info *rev);
459+
void diff_tree_combined_merge(const struct commit *commit, struct rev_info *rev);
460460

461461
void diff_set_mnemonic_prefix(struct diff_options *options, const char *a, const char *b);
462462

log-tree.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -885,7 +885,7 @@ int log_tree_diff_flush(struct rev_info *opt)
885885

886886
static int do_diff_combined(struct rev_info *opt, struct commit *commit)
887887
{
888-
diff_tree_combined_merge(commit, opt->dense_combined_merges, opt);
888+
diff_tree_combined_merge(commit, opt);
889889
return !opt->loginfo;
890890
}
891891

submodule.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -865,7 +865,8 @@ static void collect_changed_submodules(struct repository *r,
865865
diff_rev.diffopt.output_format |= DIFF_FORMAT_CALLBACK;
866866
diff_rev.diffopt.format_callback = collect_changed_submodules_cb;
867867
diff_rev.diffopt.format_callback_data = &data;
868-
diff_tree_combined_merge(commit, 1, &diff_rev);
868+
diff_rev.dense_combined_merges = 1;
869+
diff_tree_combined_merge(commit, &diff_rev);
869870
}
870871

871872
reset_revision_walk();

0 commit comments

Comments
 (0)