Skip to content

Commit a517079

Browse files
committed
Merge branch 'ab/range-diff-no-patch'
The "--no-patch" option, which can be used to get a high-level overview without the actual line-by-line patch difference shown, of the "range-diff" command was earlier broken, which has been corrected. * ab/range-diff-no-patch: range-diff: make diff option behavior (e.g. --stat) consistent range-diff: fix regression in passing along diff options range-diff doc: add a section about output stability
2 parents 6d2035e + a48e12e commit a517079

File tree

3 files changed

+49
-1
lines changed

3 files changed

+49
-1
lines changed

Documentation/git-range-diff.txt

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,23 @@ between patches", i.e. to compare the author, commit message and diff of
7878
corresponding old/new commits. There is currently no means to tweak the
7979
diff options passed to `git log` when generating those patches.
8080

81+
OUTPUT STABILITY
82+
----------------
83+
84+
The output of the `range-diff` command is subject to change. It is
85+
intended to be human-readable porcelain output, not something that can
86+
be used across versions of Git to get a textually stable `range-diff`
87+
(as opposed to something like the `--stable` option to
88+
linkgit:git-patch-id[1]). There's also no equivalent of
89+
linkgit:git-apply[1] for `range-diff`, the output is not intended to
90+
be machine-readable.
91+
92+
This is particularly true when passing in diff options. Currently some
93+
options like `--stat` can, as an emergent effect, produce output
94+
that's quite useless in the context of `range-diff`. Future versions
95+
of `range-diff` may learn to interpret such options in a manner
96+
specific to `range-diff` (e.g. for `--stat` producing human-readable
97+
output which summarizes how the diffstat changed).
8198

8299
CONFIGURATION
83100
-------------

range-diff.c

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

463463
memcpy(&opts, diffopt, sizeof(opts));
464-
opts.output_format = DIFF_FORMAT_PATCH;
464+
if (!opts.output_format)
465+
opts.output_format = DIFF_FORMAT_PATCH;
465466
opts.flags.suppress_diff_headers = 1;
466467
opts.flags.dual_color_diffed_diffs = dual_color;
467468
opts.output_prefix = output_prefix_cb;

t/t3206-range-diff.sh

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,36 @@ test_expect_success 'changed commit' '
122122
test_cmp expected actual
123123
'
124124

125+
test_expect_success 'changed commit with --no-patch diff option' '
126+
git range-diff --no-color --no-patch topic...changed >actual &&
127+
cat >expected <<-EOF &&
128+
1: 4de457d = 1: a4b3333 s/5/A/
129+
2: fccce22 = 2: f51d370 s/4/A/
130+
3: 147e64e ! 3: 0559556 s/11/B/
131+
4: a63e992 ! 4: d966c5c s/12/B/
132+
EOF
133+
test_cmp expected actual
134+
'
135+
136+
test_expect_success 'changed commit with --stat diff option' '
137+
git range-diff --no-color --stat topic...changed >actual &&
138+
cat >expected <<-EOF &&
139+
1: 4de457d = 1: a4b3333 s/5/A/
140+
a => b | 0
141+
1 file changed, 0 insertions(+), 0 deletions(-)
142+
2: fccce22 = 2: f51d370 s/4/A/
143+
a => b | 0
144+
1 file changed, 0 insertions(+), 0 deletions(-)
145+
3: 147e64e ! 3: 0559556 s/11/B/
146+
a => b | 0
147+
1 file changed, 0 insertions(+), 0 deletions(-)
148+
4: a63e992 ! 4: d966c5c s/12/B/
149+
a => b | 0
150+
1 file changed, 0 insertions(+), 0 deletions(-)
151+
EOF
152+
test_cmp expected actual
153+
'
154+
125155
test_expect_success 'changed commit with sm config' '
126156
git range-diff --no-color --submodule=log topic...changed >actual &&
127157
cat >expected <<-EOF &&

0 commit comments

Comments
 (0)