Skip to content

Commit db65170

Browse files
committed
Merge branch 'jk/color-diff-plain-is-context'
"color.diff.plain" was a misnomer; give it 'color.diff.context' as a more logical synonym. * jk/color-diff-plain-is-context: diff.h: rename DIFF_PLAIN color slot to DIFF_CONTEXT diff: accept color.diff.context as a synonym for "plain"
2 parents 82b416e + 8dbf3eb commit db65170

File tree

5 files changed

+24
-23
lines changed

5 files changed

+24
-23
lines changed

Documentation/config.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -914,7 +914,8 @@ command line with the `--color[=<when>]` option.
914914
color.diff.<slot>::
915915
Use customized color for diff colorization. `<slot>` specifies
916916
which part of the patch to use the specified color, and is one
917-
of `plain` (context text), `meta` (metainformation), `frag`
917+
of `context` (context text - `plain` is a historical synonym),
918+
`meta` (metainformation), `frag`
918919
(hunk header), 'func' (function in hunk header), `old` (removed lines),
919920
`new` (added lines), `commit` (commit headers), or `whitespace`
920921
(highlighting whitespace errors).

combine-diff.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -730,7 +730,7 @@ static void dump_sline(struct sline *sline, const char *line_prefix,
730730
const char *c_func = diff_get_color(use_color, DIFF_FUNCINFO);
731731
const char *c_new = diff_get_color(use_color, DIFF_FILE_NEW);
732732
const char *c_old = diff_get_color(use_color, DIFF_FILE_OLD);
733-
const char *c_plain = diff_get_color(use_color, DIFF_PLAIN);
733+
const char *c_context = diff_get_color(use_color, DIFF_CONTEXT);
734734
const char *c_reset = diff_get_color(use_color, DIFF_RESET);
735735

736736
if (result_deleted)
@@ -793,7 +793,7 @@ static void dump_sline(struct sline *sline, const char *line_prefix,
793793
}
794794
if (comment_end)
795795
printf("%s%s %s%s", c_reset,
796-
c_plain, c_reset,
796+
c_context, c_reset,
797797
c_func);
798798
for (i = 0; i < comment_end; i++)
799799
putchar(hunk_comment[i]);
@@ -828,7 +828,7 @@ static void dump_sline(struct sline *sline, const char *line_prefix,
828828
*/
829829
if (!context)
830830
continue;
831-
fputs(c_plain, stdout);
831+
fputs(c_context, stdout);
832832
}
833833
else
834834
fputs(c_new, stdout);

diff.c

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ static long diff_algorithm;
4242

4343
static char diff_colors[][COLOR_MAXLEN] = {
4444
GIT_COLOR_RESET,
45-
GIT_COLOR_NORMAL, /* PLAIN */
45+
GIT_COLOR_NORMAL, /* CONTEXT */
4646
GIT_COLOR_BOLD, /* METAINFO */
4747
GIT_COLOR_CYAN, /* FRAGINFO */
4848
GIT_COLOR_RED, /* OLD */
@@ -54,8 +54,8 @@ static char diff_colors[][COLOR_MAXLEN] = {
5454

5555
static int parse_diff_color_slot(const char *var)
5656
{
57-
if (!strcasecmp(var, "plain"))
58-
return DIFF_PLAIN;
57+
if (!strcasecmp(var, "context") || !strcasecmp(var, "plain"))
58+
return DIFF_CONTEXT;
5959
if (!strcasecmp(var, "meta"))
6060
return DIFF_METAINFO;
6161
if (!strcasecmp(var, "frag"))
@@ -528,13 +528,13 @@ static void emit_context_line(const char *reset,
528528
const char *line, int len)
529529
{
530530
emit_line_checked(reset, ecbdata, line, len,
531-
DIFF_PLAIN, WSEH_CONTEXT, ' ');
531+
DIFF_CONTEXT, WSEH_CONTEXT, ' ');
532532
}
533533

534534
static void emit_hunk_header(struct emit_callback *ecbdata,
535535
const char *line, int len)
536536
{
537-
const char *plain = diff_get_color(ecbdata->color_diff, DIFF_PLAIN);
537+
const char *context = diff_get_color(ecbdata->color_diff, DIFF_CONTEXT);
538538
const char *frag = diff_get_color(ecbdata->color_diff, DIFF_FRAGINFO);
539539
const char *func = diff_get_color(ecbdata->color_diff, DIFF_FUNCINFO);
540540
const char *reset = diff_get_color(ecbdata->color_diff, DIFF_RESET);
@@ -551,7 +551,7 @@ static void emit_hunk_header(struct emit_callback *ecbdata,
551551
if (len < 10 ||
552552
memcmp(line, atat, 2) ||
553553
!(ep = memmem(line + 2, len - 2, atat, 2))) {
554-
emit_line(ecbdata->opt, plain, reset, line, len);
554+
emit_line(ecbdata->opt, context, reset, line, len);
555555
return;
556556
}
557557
ep += 2; /* skip over @@ */
@@ -573,7 +573,7 @@ static void emit_hunk_header(struct emit_callback *ecbdata,
573573
if (*ep != ' ' && *ep != '\t')
574574
break;
575575
if (ep != cp) {
576-
strbuf_addstr(&msgbuf, plain);
576+
strbuf_addstr(&msgbuf, context);
577577
strbuf_add(&msgbuf, cp, ep - cp);
578578
strbuf_addstr(&msgbuf, reset);
579579
}
@@ -654,10 +654,10 @@ static void emit_rewrite_lines(struct emit_callback *ecb,
654654
data += len;
655655
}
656656
if (!endp) {
657-
const char *plain = diff_get_color(ecb->color_diff,
658-
DIFF_PLAIN);
657+
const char *context = diff_get_color(ecb->color_diff,
658+
DIFF_CONTEXT);
659659
putc('\n', ecb->opt->file);
660-
emit_line_0(ecb->opt, plain, reset, '\\',
660+
emit_line_0(ecb->opt, context, reset, '\\',
661661
nneof, strlen(nneof));
662662
}
663663
}
@@ -1117,7 +1117,7 @@ static void init_diff_words_data(struct emit_callback *ecbdata,
11171117
struct diff_words_style *st = ecbdata->diff_words->style;
11181118
st->old.color = diff_get_color_opt(o, DIFF_FILE_OLD);
11191119
st->new.color = diff_get_color_opt(o, DIFF_FILE_NEW);
1120-
st->ctx.color = diff_get_color_opt(o, DIFF_PLAIN);
1120+
st->ctx.color = diff_get_color_opt(o, DIFF_CONTEXT);
11211121
}
11221122
}
11231123

@@ -1193,7 +1193,7 @@ static void fn_out_consume(void *priv, char *line, unsigned long len)
11931193
{
11941194
struct emit_callback *ecbdata = priv;
11951195
const char *meta = diff_get_color(ecbdata->color_diff, DIFF_METAINFO);
1196-
const char *plain = diff_get_color(ecbdata->color_diff, DIFF_PLAIN);
1196+
const char *context = diff_get_color(ecbdata->color_diff, DIFF_CONTEXT);
11971197
const char *reset = diff_get_color(ecbdata->color_diff, DIFF_RESET);
11981198
struct diff_options *o = ecbdata->opt;
11991199
const char *line_prefix = diff_line_prefix(o);
@@ -1264,7 +1264,7 @@ static void fn_out_consume(void *priv, char *line, unsigned long len)
12641264
}
12651265
diff_words_flush(ecbdata);
12661266
if (ecbdata->diff_words->type == DIFF_WORDS_PORCELAIN) {
1267-
emit_line(ecbdata->opt, plain, reset, line, len);
1267+
emit_line(ecbdata->opt, context, reset, line, len);
12681268
fputs("~\n", ecbdata->opt->file);
12691269
} else {
12701270
/*
@@ -1276,7 +1276,7 @@ static void fn_out_consume(void *priv, char *line, unsigned long len)
12761276
line++;
12771277
len--;
12781278
}
1279-
emit_line(ecbdata->opt, plain, reset, line, len);
1279+
emit_line(ecbdata->opt, context, reset, line, len);
12801280
}
12811281
return;
12821282
}
@@ -1299,7 +1299,7 @@ static void fn_out_consume(void *priv, char *line, unsigned long len)
12991299
/* incomplete line at the end */
13001300
ecbdata->lno_in_preimage++;
13011301
emit_line(ecbdata->opt,
1302-
diff_get_color(ecbdata->color_diff, DIFF_PLAIN),
1302+
diff_get_color(ecbdata->color_diff, DIFF_CONTEXT),
13031303
reset, line, len);
13041304
break;
13051305
}

diff.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ struct diff_options {
181181

182182
enum color_diff {
183183
DIFF_RESET = 0,
184-
DIFF_PLAIN = 1,
184+
DIFF_CONTEXT = 1,
185185
DIFF_METAINFO = 2,
186186
DIFF_FRAGINFO = 3,
187187
DIFF_FILE_OLD = 4,

line-log.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -893,7 +893,7 @@ static void dump_diff_hacky_one(struct rev_info *rev, struct line_log_data *rang
893893
const char *c_meta = diff_get_color(opt->use_color, DIFF_METAINFO);
894894
const char *c_old = diff_get_color(opt->use_color, DIFF_FILE_OLD);
895895
const char *c_new = diff_get_color(opt->use_color, DIFF_FILE_NEW);
896-
const char *c_plain = diff_get_color(opt->use_color, DIFF_PLAIN);
896+
const char *c_context = diff_get_color(opt->use_color, DIFF_CONTEXT);
897897

898898
if (!pair || !diff)
899899
return;
@@ -957,7 +957,7 @@ static void dump_diff_hacky_one(struct rev_info *rev, struct line_log_data *rang
957957
int k;
958958
for (; t_cur < diff->target.ranges[j].start; t_cur++)
959959
print_line(prefix, ' ', t_cur, t_ends, pair->two->data,
960-
c_plain, c_reset);
960+
c_context, c_reset);
961961
for (k = diff->parent.ranges[j].start; k < diff->parent.ranges[j].end; k++)
962962
print_line(prefix, '-', k, p_ends, pair->one->data,
963963
c_old, c_reset);
@@ -968,7 +968,7 @@ static void dump_diff_hacky_one(struct rev_info *rev, struct line_log_data *rang
968968
}
969969
for (; t_cur < t_end; t_cur++)
970970
print_line(prefix, ' ', t_cur, t_ends, pair->two->data,
971-
c_plain, c_reset);
971+
c_context, c_reset);
972972
}
973973

974974
free(p_ends);

0 commit comments

Comments
 (0)