Skip to content

Commit b2a5a04

Browse files
committed
range-diff: suppress the diff headers
When showing the diff between corresponding patches of the two branch versions, we have to make up a fake filename to run the diff machinery. That filename does not carry any meaningful information, hence tbdiff suppresses it. So we should, too. Signed-off-by: Johannes Schindelin <[email protected]>
1 parent aedfa93 commit b2a5a04

File tree

3 files changed

+6
-1
lines changed

3 files changed

+6
-1
lines changed

builtin/range-diff.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ int cmd_range_diff(int argc, const char **argv, const char *prefix)
3333

3434
diff_setup(&diffopt);
3535
diffopt.output_format = DIFF_FORMAT_PATCH;
36+
diffopt.flags.suppress_diff_headers = 1;
3637
diffopt.output_prefix = output_prefix_cb;
3738
strbuf_addstr(&four_spaces, " ");
3839
diffopt.output_prefix_data = &four_spaces;

diff.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3197,13 +3197,16 @@ static void builtin_diff(const char *name_a,
31973197
memset(&xpp, 0, sizeof(xpp));
31983198
memset(&xecfg, 0, sizeof(xecfg));
31993199
memset(&ecbdata, 0, sizeof(ecbdata));
3200+
if (o->flags.suppress_diff_headers)
3201+
lbl[0] = NULL;
32003202
ecbdata.label_path = lbl;
32013203
ecbdata.color_diff = want_color(o->use_color);
32023204
ecbdata.ws_rule = whitespace_rule(name_b);
32033205
if (ecbdata.ws_rule & WS_BLANK_AT_EOF)
32043206
check_blank_at_eof(&mf1, &mf2, &ecbdata);
32053207
ecbdata.opt = o;
3206-
ecbdata.header = header.len ? &header : NULL;
3208+
if (header.len && !o->flags.suppress_diff_headers)
3209+
ecbdata.header = &header;
32073210
xpp.flags = o->xdl_opts;
32083211
xpp.anchors = o->anchors;
32093212
xpp.anchors_nr = o->anchors_nr;

diff.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ struct diff_flags {
9494
unsigned funccontext:1;
9595
unsigned default_follow_renames:1;
9696
unsigned stat_with_summary:1;
97+
unsigned suppress_diff_headers:1;
9798
};
9899

99100
static inline void diff_flags_or(struct diff_flags *a,

0 commit comments

Comments
 (0)