THIS IS A TEST INSTANCE ONLY! REPOSITORIES CAN BE DELETED AT ANY TIME!

Преглед на файлове

range-diff: suppress line count in outer diff

The line count in the outer diff's hunk headers of a range diff is not
all that interesting.  It merely shows how far along the inner diff
are on both sides.  That number is of no use for human readers, and
range-diffs are not meant to be machine readable.

In a subsequent commit we're going to add some more contextual
information such as the filename corresponding to the diff to the hunk
headers.  Remove the unnecessary information, and just keep the "@@"
to indicate that a new hunk of the outer diff is starting.

Signed-off-by: Thomas Gummerer <t.gummerer@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
tags/v2.23.0-rc0
Thomas Gummerer Junio C Hamano преди 5 месеца
родител
ревизия
430be36eb5
променени са 4 файла, в които са добавени 14 реда и са изтрити 9 реда
  1. +4
    -1
      diff.c
  2. +1
    -0
      diff.h
  3. +1
    -0
      range-diff.c
  4. +8
    -8
      t/t3206-range-diff.sh

+ 4
- 1
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);

/*


+ 1
- 0
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,


+ 1
- 0
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;


+ 8
- 8
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 &&
:<YELLOW>1: a4b3333 = 1: f686024 s/5/A/<RESET>
:<RED>2: f51d370 <RESET><YELLOW>!<RESET><GREEN> 2: 4ab067d<RESET><YELLOW> s/4/A/<RESET>
: <REVERSE><CYAN>@@ -2,6 +2,8 @@<RESET>
: <REVERSE><CYAN>@@<RESET>
: <RESET>
: s/4/A/<RESET>
: <RESET>
@@ -220,7 +220,7 @@ test_expect_success 'dual-coloring' '
: --- a/file<RESET>
: +++ b/file<RESET>
:<RED>3: 0559556 <RESET><YELLOW>!<RESET><GREEN> 3: b9cb956<RESET><YELLOW> s/11/B/<RESET>
: <REVERSE><CYAN>@@ -10,7 +10,7 @@<RESET>
: <REVERSE><CYAN>@@<RESET>
: 9<RESET>
: 10<RESET>
: <RED> -11<RESET>
@@ -230,7 +230,7 @@ test_expect_success 'dual-coloring' '
: 13<RESET>
: 14<RESET>
:<RED>4: d966c5c <RESET><YELLOW>!<RESET><GREEN> 4: 8add5f1<RESET><YELLOW> s/12/B/<RESET>
: <REVERSE><CYAN>@@ -8,7 +8,7 @@<RESET>
: <REVERSE><CYAN>@@<RESET>
: <CYAN> @@ A<RESET>
: 9<RESET>
: 10<RESET>


Loading…
Отказ
Запис