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
This commit is contained in:
Junio C Hamano 2018-11-18 18:23:54 +09:00
commit a517079437
3 changed files with 49 additions and 1 deletions

View file

@ -78,6 +78,23 @@ between patches", i.e. to compare the author, commit message and diff of
corresponding old/new commits. There is currently no means to tweak the corresponding old/new commits. There is currently no means to tweak the
diff options passed to `git log` when generating those patches. diff options passed to `git log` when generating those patches.
OUTPUT STABILITY
----------------
The output of the `range-diff` command is subject to change. It is
intended to be human-readable porcelain output, not something that can
be used across versions of Git to get a textually stable `range-diff`
(as opposed to something like the `--stable` option to
linkgit:git-patch-id[1]). There's also no equivalent of
linkgit:git-apply[1] for `range-diff`, the output is not intended to
be machine-readable.
This is particularly true when passing in diff options. Currently some
options like `--stat` can, as an emergent effect, produce output
that's quite useless in the context of `range-diff`. Future versions
of `range-diff` may learn to interpret such options in a manner
specific to `range-diff` (e.g. for `--stat` producing human-readable
output which summarizes how the diffstat changed).
CONFIGURATION CONFIGURATION
------------- -------------

View file

@ -461,7 +461,8 @@ int show_range_diff(const char *range1, const char *range2,
struct strbuf indent = STRBUF_INIT; struct strbuf indent = STRBUF_INIT;
memcpy(&opts, diffopt, sizeof(opts)); memcpy(&opts, diffopt, sizeof(opts));
opts.output_format = DIFF_FORMAT_PATCH; if (!opts.output_format)
opts.output_format = DIFF_FORMAT_PATCH;
opts.flags.suppress_diff_headers = 1; opts.flags.suppress_diff_headers = 1;
opts.flags.dual_color_diffed_diffs = dual_color; opts.flags.dual_color_diffed_diffs = dual_color;
opts.output_prefix = output_prefix_cb; opts.output_prefix = output_prefix_cb;

View file

@ -122,6 +122,36 @@ test_expect_success 'changed commit' '
test_cmp expected actual test_cmp expected actual
' '
test_expect_success 'changed commit with --no-patch diff option' '
git range-diff --no-color --no-patch topic...changed >actual &&
cat >expected <<-EOF &&
1: 4de457d = 1: a4b3333 s/5/A/
2: fccce22 = 2: f51d370 s/4/A/
3: 147e64e ! 3: 0559556 s/11/B/
4: a63e992 ! 4: d966c5c s/12/B/
EOF
test_cmp expected actual
'
test_expect_success 'changed commit with --stat diff option' '
git range-diff --no-color --stat topic...changed >actual &&
cat >expected <<-EOF &&
1: 4de457d = 1: a4b3333 s/5/A/
a => b | 0
1 file changed, 0 insertions(+), 0 deletions(-)
2: fccce22 = 2: f51d370 s/4/A/
a => b | 0
1 file changed, 0 insertions(+), 0 deletions(-)
3: 147e64e ! 3: 0559556 s/11/B/
a => b | 0
1 file changed, 0 insertions(+), 0 deletions(-)
4: a63e992 ! 4: d966c5c s/12/B/
a => b | 0
1 file changed, 0 insertions(+), 0 deletions(-)
EOF
test_cmp expected actual
'
test_expect_success 'changed commit with sm config' ' test_expect_success 'changed commit with sm config' '
git range-diff --no-color --submodule=log topic...changed >actual && git range-diff --no-color --submodule=log topic...changed >actual &&
cat >expected <<-EOF && cat >expected <<-EOF &&