mirror of
https://github.com/git/git
synced 2024-08-28 03:59:25 +00:00
Merge branch 'sb/diff-cleanup'
Code cleanup. * sb/diff-cleanup: diff: remove dead code diff: omit found pointer from emit_callback diff.c: use diff_options directly
This commit is contained in:
commit
a0d9b7f015
31
diff.c
31
diff.c
|
@ -357,7 +357,6 @@ struct emit_callback {
|
||||||
const char **label_path;
|
const char **label_path;
|
||||||
struct diff_words_data *diff_words;
|
struct diff_words_data *diff_words;
|
||||||
struct diff_options *opt;
|
struct diff_options *opt;
|
||||||
int *found_changesp;
|
|
||||||
struct strbuf *header;
|
struct strbuf *header;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -725,7 +724,6 @@ static void emit_rewrite_diff(const char *name_a,
|
||||||
|
|
||||||
memset(&ecbdata, 0, sizeof(ecbdata));
|
memset(&ecbdata, 0, sizeof(ecbdata));
|
||||||
ecbdata.color_diff = want_color(o->use_color);
|
ecbdata.color_diff = want_color(o->use_color);
|
||||||
ecbdata.found_changesp = &o->found_changes;
|
|
||||||
ecbdata.ws_rule = whitespace_rule(name_b);
|
ecbdata.ws_rule = whitespace_rule(name_b);
|
||||||
ecbdata.opt = o;
|
ecbdata.opt = o;
|
||||||
if (ecbdata.ws_rule & WS_BLANK_AT_EOF) {
|
if (ecbdata.ws_rule & WS_BLANK_AT_EOF) {
|
||||||
|
@ -1219,12 +1217,13 @@ static void fn_out_consume(void *priv, char *line, unsigned long len)
|
||||||
struct diff_options *o = ecbdata->opt;
|
struct diff_options *o = ecbdata->opt;
|
||||||
const char *line_prefix = diff_line_prefix(o);
|
const char *line_prefix = diff_line_prefix(o);
|
||||||
|
|
||||||
|
o->found_changes = 1;
|
||||||
|
|
||||||
if (ecbdata->header) {
|
if (ecbdata->header) {
|
||||||
fprintf(ecbdata->opt->file, "%s", ecbdata->header->buf);
|
fprintf(o->file, "%s", ecbdata->header->buf);
|
||||||
strbuf_reset(ecbdata->header);
|
strbuf_reset(ecbdata->header);
|
||||||
ecbdata->header = NULL;
|
ecbdata->header = NULL;
|
||||||
}
|
}
|
||||||
*(ecbdata->found_changesp) = 1;
|
|
||||||
|
|
||||||
if (ecbdata->label_path[0]) {
|
if (ecbdata->label_path[0]) {
|
||||||
const char *name_a_tab, *name_b_tab;
|
const char *name_a_tab, *name_b_tab;
|
||||||
|
@ -1232,9 +1231,9 @@ static void fn_out_consume(void *priv, char *line, unsigned long len)
|
||||||
name_a_tab = strchr(ecbdata->label_path[0], ' ') ? "\t" : "";
|
name_a_tab = strchr(ecbdata->label_path[0], ' ') ? "\t" : "";
|
||||||
name_b_tab = strchr(ecbdata->label_path[1], ' ') ? "\t" : "";
|
name_b_tab = strchr(ecbdata->label_path[1], ' ') ? "\t" : "";
|
||||||
|
|
||||||
fprintf(ecbdata->opt->file, "%s%s--- %s%s%s\n",
|
fprintf(o->file, "%s%s--- %s%s%s\n",
|
||||||
line_prefix, meta, ecbdata->label_path[0], reset, name_a_tab);
|
line_prefix, meta, ecbdata->label_path[0], reset, name_a_tab);
|
||||||
fprintf(ecbdata->opt->file, "%s%s+++ %s%s%s\n",
|
fprintf(o->file, "%s%s+++ %s%s%s\n",
|
||||||
line_prefix, meta, ecbdata->label_path[1], reset, name_b_tab);
|
line_prefix, meta, ecbdata->label_path[1], reset, name_b_tab);
|
||||||
ecbdata->label_path[0] = ecbdata->label_path[1] = NULL;
|
ecbdata->label_path[0] = ecbdata->label_path[1] = NULL;
|
||||||
}
|
}
|
||||||
|
@ -1252,15 +1251,7 @@ static void fn_out_consume(void *priv, char *line, unsigned long len)
|
||||||
find_lno(line, ecbdata);
|
find_lno(line, ecbdata);
|
||||||
emit_hunk_header(ecbdata, line, len);
|
emit_hunk_header(ecbdata, line, len);
|
||||||
if (line[len-1] != '\n')
|
if (line[len-1] != '\n')
|
||||||
putc('\n', ecbdata->opt->file);
|
putc('\n', o->file);
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (len < 1) {
|
|
||||||
emit_line(ecbdata->opt, reset, reset, line, len);
|
|
||||||
if (ecbdata->diff_words
|
|
||||||
&& ecbdata->diff_words->type == DIFF_WORDS_PORCELAIN)
|
|
||||||
fputs("~\n", ecbdata->opt->file);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1285,8 +1276,8 @@ static void fn_out_consume(void *priv, char *line, unsigned long len)
|
||||||
}
|
}
|
||||||
diff_words_flush(ecbdata);
|
diff_words_flush(ecbdata);
|
||||||
if (ecbdata->diff_words->type == DIFF_WORDS_PORCELAIN) {
|
if (ecbdata->diff_words->type == DIFF_WORDS_PORCELAIN) {
|
||||||
emit_line(ecbdata->opt, context, reset, line, len);
|
emit_line(o, context, reset, line, len);
|
||||||
fputs("~\n", ecbdata->opt->file);
|
fputs("~\n", o->file);
|
||||||
} else {
|
} else {
|
||||||
/*
|
/*
|
||||||
* Skip the prefix character, if any. With
|
* Skip the prefix character, if any. With
|
||||||
|
@ -1297,7 +1288,7 @@ static void fn_out_consume(void *priv, char *line, unsigned long len)
|
||||||
line++;
|
line++;
|
||||||
len--;
|
len--;
|
||||||
}
|
}
|
||||||
emit_line(ecbdata->opt, context, reset, line, len);
|
emit_line(o, context, reset, line, len);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -1319,8 +1310,7 @@ static void fn_out_consume(void *priv, char *line, unsigned long len)
|
||||||
default:
|
default:
|
||||||
/* incomplete line at the end */
|
/* incomplete line at the end */
|
||||||
ecbdata->lno_in_preimage++;
|
ecbdata->lno_in_preimage++;
|
||||||
emit_line(ecbdata->opt,
|
emit_line(o, diff_get_color(ecbdata->color_diff, DIFF_CONTEXT),
|
||||||
diff_get_color(ecbdata->color_diff, DIFF_CONTEXT),
|
|
||||||
reset, line, len);
|
reset, line, len);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -2452,7 +2442,6 @@ static void builtin_diff(const char *name_a,
|
||||||
memset(&ecbdata, 0, sizeof(ecbdata));
|
memset(&ecbdata, 0, sizeof(ecbdata));
|
||||||
ecbdata.label_path = lbl;
|
ecbdata.label_path = lbl;
|
||||||
ecbdata.color_diff = want_color(o->use_color);
|
ecbdata.color_diff = want_color(o->use_color);
|
||||||
ecbdata.found_changesp = &o->found_changes;
|
|
||||||
ecbdata.ws_rule = whitespace_rule(name_b);
|
ecbdata.ws_rule = whitespace_rule(name_b);
|
||||||
if (ecbdata.ws_rule & WS_BLANK_AT_EOF)
|
if (ecbdata.ws_rule & WS_BLANK_AT_EOF)
|
||||||
check_blank_at_eof(&mf1, &mf2, &ecbdata);
|
check_blank_at_eof(&mf1, &mf2, &ecbdata);
|
||||||
|
|
Loading…
Reference in a new issue