diff: get rid of redundant 'dense' argument
Get rid of 'dense' argument that is redundant for every function that has 'struct rev_info *rev' argument as well, as the value of 'dense' passed is always taken from 'rev->dense_combined_merges' field. The only place where this was not the case is in 'submodule.c' where 'diff_tree_combined_merge()' was called with '1' for 'dense' argument. However, at that call the 'revs' instance used is local to the function, and we now just set 'revs->dense_combined_merges' to 1 in this local instance. Signed-off-by: Sergey Organov <sorganov@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Sergey Organov committed
Sep 29, 2020 at 14:31 UTC
d01141de5ab02cf4a156183ef4dc5ee8bf2638a3
6 files changed
+18
-23
builtin/diff.c
+1
-2
@@ -203,8 +203,7 @@ static int builtin_diff_combined(struct rev_info *revs,
203
revs->dense_combined_merges = revs->combine_merges = 1;
204
for (i = 1; i < ents; i++)
205
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);
207
oid_array_clear(&parents);
208
return 0;
209
}
combine-diff.c
+9
-12
@@ -923,7 +923,6 @@ static void dump_quoted_path(const char *head,
923
924
static void show_combined_header(struct combine_diff_path *elem,
925
int num_parent,
926
- int dense,
926
struct rev_info *rev,
927
const char *line_prefix,
928
int mode_differs,
@@ -939,6 +938,7 @@ static void show_combined_header(struct combine_diff_path *elem,
938
int added = 0;
939
int deleted = 0;
940
int i;
941
+ int dense = rev->dense_combined_merges;
942
943
if (rev->loginfo && !rev->no_commit_id)
944
show_log(rev);
@@ -1012,7 +1012,7 @@ static void show_combined_header(struct combine_diff_path *elem,
1012
}
1013
1014
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,
1016
struct rev_info *rev)
1017
{
1018
struct diff_options *opt = &rev->diffopt;
@@ -1145,7 +1145,7 @@ static void show_patch_diff(struct combine_diff_path *elem, int num_parent,
1145
}
1146
}
1147
if (is_binary) {
1148
- show_combined_header(elem, num_parent, dense, rev,
1148
+ show_combined_header(elem, num_parent, rev,
1149
line_prefix, mode_differs, 0);
1150
printf("Binary files differ\n");
1151
free(result);
@@ -1200,10 +1200,10 @@ static void show_patch_diff(struct combine_diff_path *elem, int num_parent,
1200
textconv, elem->path, opt->xdl_opts);
1201
}
1202
1203
- show_hunks = make_hunks(sline, cnt, num_parent, dense);
1203
+ show_hunks = make_hunks(sline, cnt, num_parent, rev->dense_combined_merges);
1204
1205
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,
1207
line_prefix, mode_differs, 1);
1208
dump_sline(sline, line_prefix, cnt, num_parent,
1209
opt->use_color, result_deleted);
@@ -1284,7 +1284,6 @@ static void show_raw_diff(struct combine_diff_path *p, int num_parent, struct re
1284
*/
1285
void show_combined_diff(struct combine_diff_path *p,
1286
int num_parent,
1287
- int dense,
1287
struct rev_info *rev)
1288
{
1289
struct diff_options *opt = &rev->diffopt;
@@ -1294,7 +1293,7 @@ void show_combined_diff(struct combine_diff_path *p,
1293
DIFF_FORMAT_NAME_STATUS))
1294
show_raw_diff(p, num_parent, rev);
1295
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);
1297
}
1298
1299
static void free_combined_pair(struct diff_filepair *pair)
@@ -1454,7 +1453,6 @@ static struct combine_diff_path *find_paths_multitree(
1453
1454
void diff_tree_combined(const struct object_id *oid,
1455
const struct oid_array *parents,
1457
- int dense,
1456
struct rev_info *rev)
1457
{
1458
struct diff_options *opt = &rev->diffopt;
@@ -1581,8 +1579,7 @@ void diff_tree_combined(const struct object_id *oid,
1579
printf("%s%c", diff_line_prefix(opt),
1580
opt->line_termination);
1581
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);
1583
}
1584
}
1585
@@ -1600,7 +1597,7 @@ void diff_tree_combined(const struct object_id *oid,
1597
clear_pathspec(&diffopts.pathspec);
1598
}
1599
1603
-void diff_tree_combined_merge(const struct commit *commit, int dense,
1600
+void diff_tree_combined_merge(const struct commit *commit,
1601
struct rev_info *rev)
1602
{
1603
struct commit_list *parent = get_saved_parents(rev, commit);
@@ -1610,6 +1607,6 @@ void diff_tree_combined_merge(const struct commit *commit, int dense,
1607
oid_array_append(&parents, &parent->item->object.oid);
1608
parent = parent->next;
1609
}
1613
- diff_tree_combined(&commit->object.oid, &parents, dense, rev);
1610
+ diff_tree_combined(&commit->object.oid, &parents, rev);
1611
oid_array_clear(&parents);
1612
}
diff-lib.c
+2
-4
@@ -177,9 +177,7 @@ int run_diff_files(struct rev_info *revs, unsigned int option)
177
i--;
178
179
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);
181
free(dpath);
182
continue;
183
}
@@ -360,7 +358,7 @@ static int show_modified(struct rev_info *revs,
358
p->parent[1].status = DIFF_STATUS_MODIFIED;
359
p->parent[1].mode = old_entry->ce_mode;
360
oidcpy(&p->parent[1].oid, &old_entry->oid);
363
- show_combined_diff(p, 2, revs->dense_combined_merges, revs);
361
+ show_combined_diff(p, 2, revs);
362
free(p);
363
return 0;
364
}
diff.h
+3
-3
@@ -454,11 +454,11 @@ struct combine_diff_path {
454
st_mult(sizeof(struct combine_diff_parent), (n)))
455
456
void show_combined_diff(struct combine_diff_path *elem, int num_parent,
457
- int dense, struct rev_info *);
457
+ struct rev_info *);
458
459
-void diff_tree_combined(const struct object_id *oid, const struct oid_array *parents, int dense, struct rev_info *rev);
459
+void diff_tree_combined(const struct object_id *oid, const struct oid_array *parents, struct rev_info *rev);
460
461
-void diff_tree_combined_merge(const struct commit *commit, int dense, struct rev_info *rev);
461
+void diff_tree_combined_merge(const struct commit *commit, struct rev_info *rev);
462
463
void diff_set_mnemonic_prefix(struct diff_options *options, const char *a, const char *b);
464
log-tree.c
+1
-1
@@ -885,7 +885,7 @@ int log_tree_diff_flush(struct rev_info *opt)
885
886
static int do_diff_combined(struct rev_info *opt, struct commit *commit)
887
{
888
- diff_tree_combined_merge(commit, opt->dense_combined_merges, opt);
888
+ diff_tree_combined_merge(commit, opt);
889
return !opt->loginfo;
890
}
891
submodule.c
+2
-1
@@ -857,7 +857,8 @@ static void collect_changed_submodules(struct repository *r,
857
diff_rev.diffopt.output_format |= DIFF_FORMAT_CALLBACK;
858
diff_rev.diffopt.format_callback = collect_changed_submodules_cb;
859
diff_rev.diffopt.format_callback_data = &data;
860
- diff_tree_combined_merge(commit, 1, &diff_rev);
860
+ diff_rev.dense_combined_merges = 1;
861
+ diff_tree_combined_merge(commit, &diff_rev);
862
}
863
864
reset_revision_walk();