diff --git a/diff.c b/diff.c index 1ee04e321b..4146993010 100644 --- a/diff.c +++ b/diff.c @@ -1673,7 +1673,10 @@ static void emit_hunk_header(struct emit_callback *ecbdata, if (ecbdata->opt->flags.dual_color_diffed_diffs) strbuf_addstr(&msgbuf, reverse); strbuf_addstr(&msgbuf, frag); - strbuf_add(&msgbuf, line, ep - line); + if (ecbdata->opt->flags.suppress_hunk_header_line_count) + strbuf_add(&msgbuf, atat, sizeof(atat)); + else + strbuf_add(&msgbuf, line, ep - line); strbuf_addstr(&msgbuf, reset); /* diff --git a/diff.h b/diff.h index b680b377b2..c2c3056810 100644 --- a/diff.h +++ b/diff.h @@ -98,6 +98,7 @@ struct diff_flags { unsigned stat_with_summary; unsigned suppress_diff_headers; unsigned dual_color_diffed_diffs; + unsigned suppress_hunk_header_line_count; }; static inline void diff_flags_or(struct diff_flags *a, diff --git a/range-diff.c b/range-diff.c index a5202d8b6c..f4a90b33b8 100644 --- a/range-diff.c +++ b/range-diff.c @@ -486,6 +486,7 @@ int show_range_diff(const char *range1, const char *range2, opts.output_format = DIFF_FORMAT_PATCH; opts.flags.suppress_diff_headers = 1; opts.flags.dual_color_diffed_diffs = dual_color; + opts.flags.suppress_hunk_header_line_count = 1; opts.output_prefix = output_prefix_cb; strbuf_addstr(&indent, " "); opts.output_prefix_data = &indent; diff --git a/t/t3206-range-diff.sh b/t/t3206-range-diff.sh index aebd4e3693..9f89af7178 100755 --- a/t/t3206-range-diff.sh +++ b/t/t3206-range-diff.sh @@ -99,7 +99,7 @@ test_expect_success 'changed commit' ' 1: 4de457d = 1: a4b3333 s/5/A/ 2: fccce22 = 2: f51d370 s/4/A/ 3: 147e64e ! 3: 0559556 s/11/B/ - @@ -10,7 +10,7 @@ + @@ 9 10 -11 @@ -109,7 +109,7 @@ test_expect_success 'changed commit' ' 13 14 4: a63e992 ! 4: d966c5c s/12/B/ - @@ -8,7 +8,7 @@ + @@ @@ A 9 10 @@ -158,7 +158,7 @@ test_expect_success 'changed commit with sm config' ' 1: 4de457d = 1: a4b3333 s/5/A/ 2: fccce22 = 2: f51d370 s/4/A/ 3: 147e64e ! 3: 0559556 s/11/B/ - @@ -10,7 +10,7 @@ + @@ 9 10 -11 @@ -168,7 +168,7 @@ test_expect_success 'changed commit with sm config' ' 13 14 4: a63e992 ! 4: d966c5c s/12/B/ - @@ -8,7 +8,7 @@ + @@ @@ A 9 10 @@ -191,7 +191,7 @@ test_expect_success 'changed message' ' sed s/Z/\ /g >expected <<-EOF && 1: 4de457d = 1: f686024 s/5/A/ 2: fccce22 ! 2: 4ab067d s/4/A/ - @@ -2,6 +2,8 @@ + @@ Z Z s/4/A/ Z @@ -210,7 +210,7 @@ test_expect_success 'dual-coloring' ' sed -e "s|^:||" >expect <<-\EOF && :1: a4b3333 = 1: f686024 s/5/A/ :2: f51d370 ! 2: 4ab067d s/4/A/ - : @@ -2,6 +2,8 @@ + : @@ : : s/4/A/ : @@ -220,7 +220,7 @@ test_expect_success 'dual-coloring' ' : --- a/file : +++ b/file :3: 0559556 ! 3: b9cb956 s/11/B/ - : @@ -10,7 +10,7 @@ + : @@ : 9 : 10 : -11 @@ -230,7 +230,7 @@ test_expect_success 'dual-coloring' ' : 13 : 14 :4: d966c5c ! 4: 8add5f1 s/12/B/ - : @@ -8,7 +8,7 @@ + : @@ : @@ A : 9 : 10