зеркало из https://github.com/microsoft/git.git
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>
This commit is contained in:
Родитель
47ae905ffb
Коммит
d01141de5a
|
@ -203,8 +203,7 @@ static int builtin_diff_combined(struct rev_info *revs,
|
||||||
revs->dense_combined_merges = revs->combine_merges = 1;
|
revs->dense_combined_merges = revs->combine_merges = 1;
|
||||||
for (i = 1; i < ents; i++)
|
for (i = 1; i < ents; i++)
|
||||||
oid_array_append(&parents, &ent[i].item->oid);
|
oid_array_append(&parents, &ent[i].item->oid);
|
||||||
diff_tree_combined(&ent[0].item->oid, &parents,
|
diff_tree_combined(&ent[0].item->oid, &parents, revs);
|
||||||
revs->dense_combined_merges, revs);
|
|
||||||
oid_array_clear(&parents);
|
oid_array_clear(&parents);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -923,7 +923,6 @@ static void dump_quoted_path(const char *head,
|
||||||
|
|
||||||
static void show_combined_header(struct combine_diff_path *elem,
|
static void show_combined_header(struct combine_diff_path *elem,
|
||||||
int num_parent,
|
int num_parent,
|
||||||
int dense,
|
|
||||||
struct rev_info *rev,
|
struct rev_info *rev,
|
||||||
const char *line_prefix,
|
const char *line_prefix,
|
||||||
int mode_differs,
|
int mode_differs,
|
||||||
|
@ -939,6 +938,7 @@ static void show_combined_header(struct combine_diff_path *elem,
|
||||||
int added = 0;
|
int added = 0;
|
||||||
int deleted = 0;
|
int deleted = 0;
|
||||||
int i;
|
int i;
|
||||||
|
int dense = rev->dense_combined_merges;
|
||||||
|
|
||||||
if (rev->loginfo && !rev->no_commit_id)
|
if (rev->loginfo && !rev->no_commit_id)
|
||||||
show_log(rev);
|
show_log(rev);
|
||||||
|
@ -1012,7 +1012,7 @@ static void show_combined_header(struct combine_diff_path *elem,
|
||||||
}
|
}
|
||||||
|
|
||||||
static void show_patch_diff(struct combine_diff_path *elem, int num_parent,
|
static void show_patch_diff(struct combine_diff_path *elem, int num_parent,
|
||||||
int dense, int working_tree_file,
|
int working_tree_file,
|
||||||
struct rev_info *rev)
|
struct rev_info *rev)
|
||||||
{
|
{
|
||||||
struct diff_options *opt = &rev->diffopt;
|
struct diff_options *opt = &rev->diffopt;
|
||||||
|
@ -1145,7 +1145,7 @@ static void show_patch_diff(struct combine_diff_path *elem, int num_parent,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (is_binary) {
|
if (is_binary) {
|
||||||
show_combined_header(elem, num_parent, dense, rev,
|
show_combined_header(elem, num_parent, rev,
|
||||||
line_prefix, mode_differs, 0);
|
line_prefix, mode_differs, 0);
|
||||||
printf("Binary files differ\n");
|
printf("Binary files differ\n");
|
||||||
free(result);
|
free(result);
|
||||||
|
@ -1200,10 +1200,10 @@ static void show_patch_diff(struct combine_diff_path *elem, int num_parent,
|
||||||
textconv, elem->path, opt->xdl_opts);
|
textconv, elem->path, opt->xdl_opts);
|
||||||
}
|
}
|
||||||
|
|
||||||
show_hunks = make_hunks(sline, cnt, num_parent, dense);
|
show_hunks = make_hunks(sline, cnt, num_parent, rev->dense_combined_merges);
|
||||||
|
|
||||||
if (show_hunks || mode_differs || working_tree_file) {
|
if (show_hunks || mode_differs || working_tree_file) {
|
||||||
show_combined_header(elem, num_parent, dense, rev,
|
show_combined_header(elem, num_parent, rev,
|
||||||
line_prefix, mode_differs, 1);
|
line_prefix, mode_differs, 1);
|
||||||
dump_sline(sline, line_prefix, cnt, num_parent,
|
dump_sline(sline, line_prefix, cnt, num_parent,
|
||||||
opt->use_color, result_deleted);
|
opt->use_color, result_deleted);
|
||||||
|
@ -1284,7 +1284,6 @@ static void show_raw_diff(struct combine_diff_path *p, int num_parent, struct re
|
||||||
*/
|
*/
|
||||||
void show_combined_diff(struct combine_diff_path *p,
|
void show_combined_diff(struct combine_diff_path *p,
|
||||||
int num_parent,
|
int num_parent,
|
||||||
int dense,
|
|
||||||
struct rev_info *rev)
|
struct rev_info *rev)
|
||||||
{
|
{
|
||||||
struct diff_options *opt = &rev->diffopt;
|
struct diff_options *opt = &rev->diffopt;
|
||||||
|
@ -1294,7 +1293,7 @@ void show_combined_diff(struct combine_diff_path *p,
|
||||||
DIFF_FORMAT_NAME_STATUS))
|
DIFF_FORMAT_NAME_STATUS))
|
||||||
show_raw_diff(p, num_parent, rev);
|
show_raw_diff(p, num_parent, rev);
|
||||||
else if (opt->output_format & DIFF_FORMAT_PATCH)
|
else if (opt->output_format & DIFF_FORMAT_PATCH)
|
||||||
show_patch_diff(p, num_parent, dense, 1, rev);
|
show_patch_diff(p, num_parent, 1, rev);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void free_combined_pair(struct diff_filepair *pair)
|
static void free_combined_pair(struct diff_filepair *pair)
|
||||||
|
@ -1454,7 +1453,6 @@ static struct combine_diff_path *find_paths_multitree(
|
||||||
|
|
||||||
void diff_tree_combined(const struct object_id *oid,
|
void diff_tree_combined(const struct object_id *oid,
|
||||||
const struct oid_array *parents,
|
const struct oid_array *parents,
|
||||||
int dense,
|
|
||||||
struct rev_info *rev)
|
struct rev_info *rev)
|
||||||
{
|
{
|
||||||
struct diff_options *opt = &rev->diffopt;
|
struct diff_options *opt = &rev->diffopt;
|
||||||
|
@ -1581,8 +1579,7 @@ void diff_tree_combined(const struct object_id *oid,
|
||||||
printf("%s%c", diff_line_prefix(opt),
|
printf("%s%c", diff_line_prefix(opt),
|
||||||
opt->line_termination);
|
opt->line_termination);
|
||||||
for (p = paths; p; p = p->next)
|
for (p = paths; p; p = p->next)
|
||||||
show_patch_diff(p, num_parent, dense,
|
show_patch_diff(p, num_parent, 0, rev);
|
||||||
0, rev);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1600,7 +1597,7 @@ void diff_tree_combined(const struct object_id *oid,
|
||||||
clear_pathspec(&diffopts.pathspec);
|
clear_pathspec(&diffopts.pathspec);
|
||||||
}
|
}
|
||||||
|
|
||||||
void diff_tree_combined_merge(const struct commit *commit, int dense,
|
void diff_tree_combined_merge(const struct commit *commit,
|
||||||
struct rev_info *rev)
|
struct rev_info *rev)
|
||||||
{
|
{
|
||||||
struct commit_list *parent = get_saved_parents(rev, commit);
|
struct commit_list *parent = get_saved_parents(rev, commit);
|
||||||
|
@ -1610,6 +1607,6 @@ void diff_tree_combined_merge(const struct commit *commit, int dense,
|
||||||
oid_array_append(&parents, &parent->item->object.oid);
|
oid_array_append(&parents, &parent->item->object.oid);
|
||||||
parent = parent->next;
|
parent = parent->next;
|
||||||
}
|
}
|
||||||
diff_tree_combined(&commit->object.oid, &parents, dense, rev);
|
diff_tree_combined(&commit->object.oid, &parents, rev);
|
||||||
oid_array_clear(&parents);
|
oid_array_clear(&parents);
|
||||||
}
|
}
|
||||||
|
|
|
@ -177,9 +177,7 @@ int run_diff_files(struct rev_info *revs, unsigned int option)
|
||||||
i--;
|
i--;
|
||||||
|
|
||||||
if (revs->combine_merges && num_compare_stages == 2) {
|
if (revs->combine_merges && num_compare_stages == 2) {
|
||||||
show_combined_diff(dpath, 2,
|
show_combined_diff(dpath, 2, revs);
|
||||||
revs->dense_combined_merges,
|
|
||||||
revs);
|
|
||||||
free(dpath);
|
free(dpath);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -360,7 +358,7 @@ static int show_modified(struct rev_info *revs,
|
||||||
p->parent[1].status = DIFF_STATUS_MODIFIED;
|
p->parent[1].status = DIFF_STATUS_MODIFIED;
|
||||||
p->parent[1].mode = old_entry->ce_mode;
|
p->parent[1].mode = old_entry->ce_mode;
|
||||||
oidcpy(&p->parent[1].oid, &old_entry->oid);
|
oidcpy(&p->parent[1].oid, &old_entry->oid);
|
||||||
show_combined_diff(p, 2, revs->dense_combined_merges, revs);
|
show_combined_diff(p, 2, revs);
|
||||||
free(p);
|
free(p);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
6
diff.h
6
diff.h
|
@ -454,11 +454,11 @@ struct combine_diff_path {
|
||||||
st_mult(sizeof(struct combine_diff_parent), (n)))
|
st_mult(sizeof(struct combine_diff_parent), (n)))
|
||||||
|
|
||||||
void show_combined_diff(struct combine_diff_path *elem, int num_parent,
|
void show_combined_diff(struct combine_diff_path *elem, int num_parent,
|
||||||
int dense, struct rev_info *);
|
struct rev_info *);
|
||||||
|
|
||||||
void diff_tree_combined(const struct object_id *oid, const struct oid_array *parents, int dense, struct rev_info *rev);
|
void diff_tree_combined(const struct object_id *oid, const struct oid_array *parents, struct rev_info *rev);
|
||||||
|
|
||||||
void diff_tree_combined_merge(const struct commit *commit, int dense, struct rev_info *rev);
|
void diff_tree_combined_merge(const struct commit *commit, struct rev_info *rev);
|
||||||
|
|
||||||
void diff_set_mnemonic_prefix(struct diff_options *options, const char *a, const char *b);
|
void diff_set_mnemonic_prefix(struct diff_options *options, const char *a, const char *b);
|
||||||
|
|
||||||
|
|
|
@ -885,7 +885,7 @@ int log_tree_diff_flush(struct rev_info *opt)
|
||||||
|
|
||||||
static int do_diff_combined(struct rev_info *opt, struct commit *commit)
|
static int do_diff_combined(struct rev_info *opt, struct commit *commit)
|
||||||
{
|
{
|
||||||
diff_tree_combined_merge(commit, opt->dense_combined_merges, opt);
|
diff_tree_combined_merge(commit, opt);
|
||||||
return !opt->loginfo;
|
return !opt->loginfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -857,7 +857,8 @@ static void collect_changed_submodules(struct repository *r,
|
||||||
diff_rev.diffopt.output_format |= DIFF_FORMAT_CALLBACK;
|
diff_rev.diffopt.output_format |= DIFF_FORMAT_CALLBACK;
|
||||||
diff_rev.diffopt.format_callback = collect_changed_submodules_cb;
|
diff_rev.diffopt.format_callback = collect_changed_submodules_cb;
|
||||||
diff_rev.diffopt.format_callback_data = &data;
|
diff_rev.diffopt.format_callback_data = &data;
|
||||||
diff_tree_combined_merge(commit, 1, &diff_rev);
|
diff_rev.dense_combined_merges = 1;
|
||||||
|
diff_tree_combined_merge(commit, &diff_rev);
|
||||||
}
|
}
|
||||||
|
|
||||||
reset_revision_walk();
|
reset_revision_walk();
|
||||||
|
|
Загрузка…
Ссылка в новой задаче