Re: [PATCH v3 2/2] range-diff: fix regression in passing along diff options
From: Eric Sunshine <hidden>
Date: 2018-11-08 17:08:50
On Wed, Nov 7, 2018 at 7:22 AM Ævar Arnfjörð Bjarmason [off-list ref] wrote:
In 73a834e9e2 ("range-diff: relieve callers of low-level configuration
burden", 2018-07-22) we broke passing down options like --no-patch,
--stat etc. Fix that regression, and add a test for some of these
options being passed down.Thanks both (Ævar and Dscho) for cleaning up my mess, and sorry for not responding sooner; I only just found time to read the discussion thread. One comment below...
quoted hunk ↗ jump to hunk
Signed-off-by: Ævar Arnfjörð Bjarmason <redacted> ---diff --git a/range-diff.c b/range-diff.c@@ -453,7 +453,8 @@ int show_range_diff(const char *range1, const char *range2, memcpy(&opts, diffopt, sizeof(opts)); - opts.output_format = DIFF_FORMAT_PATCH; + if (!opts.output_format) + opts.output_format = DIFF_FORMAT_PATCH;
Looking at diff.c:parse_diff_opt() and enable_patch_output(), rather
than introducing this new conditional, I'm thinking that a more
correct fix would be:
opts.output_format |= DIFF_FORMAT_PATCH;
(note the '|=' operator). This would result in 'opts.output_format'
containing (DIFF_FORMAT_PATCH | DIFF_FORMAT_NO_OUTPUT), just as it did
prior to 73a834e9e2 when --no-patch was specified.