Skip to content

Commit a48e12e

Browse files
avargitster
authored andcommitted
range-diff: make diff option behavior (e.g. --stat) consistent
Make the behavior when diff options (e.g. "--stat") are passed consistent with how "diff" behaves. Before 73a834e ("range-diff: relieve callers of low-level configuration burden", 2018-07-22) running range-diff with "--stat" would produce stat output and the diff output, as opposed to how "diff" behaves where once "--stat" is specified "--patch" also needs to be provided to emit the patch output. As noted in a previous change ("range-diff doc: add a section about output stability", 2018-11-07) the "--stat" output with "range-diff" is useless at the moment. But we should behave consistently with "diff" in anticipation of such output being useful in the future, because it would make for confusing UI if "diff" and "range-diff" behaved differently when it came to how they interpret diff options. The new behavior is also consistent with the existing documentation added in ba931ed ("range-diff: populate the man page", 2018-08-13). See "[...]also accepts the regular diff options[...]" in git-range-diff(1). Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent 4624185 commit a48e12e

File tree

2 files changed

+2
-24
lines changed

2 files changed

+2
-24
lines changed

range-diff.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -433,7 +433,8 @@ int show_range_diff(const char *range1, const char *range2,
433433
struct strbuf indent = STRBUF_INIT;
434434

435435
memcpy(&opts, diffopt, sizeof(opts));
436-
opts.output_format |= DIFF_FORMAT_PATCH;
436+
if (!opts.output_format)
437+
opts.output_format = DIFF_FORMAT_PATCH;
437438
opts.flags.suppress_diff_headers = 1;
438439
opts.flags.dual_color_diffed_diffs = dual_color;
439440
opts.output_prefix = output_prefix_cb;

t/t3206-range-diff.sh

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -134,43 +134,20 @@ test_expect_success 'changed commit with --no-patch diff option' '
134134
'
135135

136136
test_expect_success 'changed commit with --stat diff option' '
137-
four_spaces=" " &&
138137
git range-diff --no-color --stat topic...changed >actual &&
139138
cat >expected <<-EOF &&
140139
1: 4de457d = 1: a4b3333 s/5/A/
141140
a => b | 0
142141
1 file changed, 0 insertions(+), 0 deletions(-)
143-
$four_spaces
144142
2: fccce22 = 2: f51d370 s/4/A/
145143
a => b | 0
146144
1 file changed, 0 insertions(+), 0 deletions(-)
147-
$four_spaces
148145
3: 147e64e ! 3: 0559556 s/11/B/
149146
a => b | 0
150147
1 file changed, 0 insertions(+), 0 deletions(-)
151-
$four_spaces
152-
@@ -10,7 +10,7 @@
153-
9
154-
10
155-
-11
156-
-+B
157-
++BB
158-
12
159-
13
160-
14
161148
4: a63e992 ! 4: d966c5c s/12/B/
162149
a => b | 0
163150
1 file changed, 0 insertions(+), 0 deletions(-)
164-
$four_spaces
165-
@@ -8,7 +8,7 @@
166-
@@
167-
9
168-
10
169-
- B
170-
+ BB
171-
-12
172-
+B
173-
13
174151
EOF
175152
test_cmp expected actual
176153
'

0 commit comments

Comments
 (0)