Skip to content

Commit 1cdde29

Browse files
dschogitster
authored andcommitted
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]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 5e242e6 commit 1cdde29

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
@@ -3395,13 +3395,16 @@ static void builtin_diff(const char *name_a,
33953395
memset(&xpp, 0, sizeof(xpp));
33963396
memset(&xecfg, 0, sizeof(xecfg));
33973397
memset(&ecbdata, 0, sizeof(ecbdata));
3398+
if (o->flags.suppress_diff_headers)
3399+
lbl[0] = NULL;
33983400
ecbdata.label_path = lbl;
33993401
ecbdata.color_diff = want_color(o->use_color);
34003402
ecbdata.ws_rule = whitespace_rule(name_b);
34013403
if (ecbdata.ws_rule & WS_BLANK_AT_EOF)
34023404
check_blank_at_eof(&mf1, &mf2, &ecbdata);
34033405
ecbdata.opt = o;
3404-
ecbdata.header = header.len ? &header : NULL;
3406+
if (header.len && !o->flags.suppress_diff_headers)
3407+
ecbdata.header = &header;
34053408
xpp.flags = o->xdl_opts;
34063409
xpp.anchors = o->anchors;
34073410
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)