aboutsummaryrefslogtreecommitdiffstats
path: root/builtin
diff options
context:
space:
mode:
authorJohannes Schindelin <johannes.schindelin@gmx.de>2021-02-05 14:46:11 +0000
committerJunio C Hamano <gitster@pobox.com>2021-02-06 21:14:31 -0800
commitf1ce6c191e9d15ce78041d8b6496c246b10d9b2d (patch)
treebd2e245ebc24622e25b7b1f0c1fbe821719ab4dc /builtin
parent5189bb87249434fba3a82f17b2bc6c93025ba88d (diff)
downloadgit-f1ce6c191e9d15ce78041d8b6496c246b10d9b2d.tar.gz
range-diff: combine all options in a single data structure
This will make it easier to implement the `--left-only` and `--right-only` options. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin')
-rw-r--r--builtin/log.c10
-rw-r--r--builtin/range-diff.c13
2 files changed, 17 insertions, 6 deletions
diff --git a/builtin/log.c b/builtin/log.c
index f23ccdbec3..300b1648d7 100644
--- a/builtin/log.c
+++ b/builtin/log.c
@@ -1231,14 +1231,20 @@ static void make_cover_letter(struct rev_info *rev, int use_separate_file,
*/
struct diff_options opts;
struct strvec other_arg = STRVEC_INIT;
+ struct range_diff_options range_diff_opts = {
+ .creation_factor = rev->creation_factor,
+ .dual_color = 1,
+ .diffopt = &opts,
+ .other_arg = &other_arg
+ };
+
diff_setup(&opts);
opts.file = rev->diffopt.file;
opts.use_color = rev->diffopt.use_color;
diff_setup_done(&opts);
fprintf_ln(rev->diffopt.file, "%s", rev->rdiff_title);
get_notes_args(&other_arg, rev);
- show_range_diff(rev->rdiff1, rev->rdiff2,
- rev->creation_factor, 1, &opts, &other_arg);
+ show_range_diff(rev->rdiff1, rev->rdiff2, &range_diff_opts);
strvec_clear(&other_arg);
}
}
diff --git a/builtin/range-diff.c b/builtin/range-diff.c
index 24c4162f74..73fea79601 100644
--- a/builtin/range-diff.c
+++ b/builtin/range-diff.c
@@ -13,12 +13,17 @@ NULL
int cmd_range_diff(int argc, const char **argv, const char *prefix)
{
- int creation_factor = RANGE_DIFF_CREATION_FACTOR_DEFAULT;
struct diff_options diffopt = { NULL };
struct strvec other_arg = STRVEC_INIT;
+ struct range_diff_options range_diff_opts = {
+ .creation_factor = RANGE_DIFF_CREATION_FACTOR_DEFAULT,
+ .diffopt = &diffopt,
+ .other_arg = &other_arg
+ };
int simple_color = -1;
struct option range_diff_options[] = {
- OPT_INTEGER(0, "creation-factor", &creation_factor,
+ OPT_INTEGER(0, "creation-factor",
+ &range_diff_opts.creation_factor,
N_("Percentage by which creation is weighted")),
OPT_BOOL(0, "no-dual-color", &simple_color,
N_("use simple diff colors")),
@@ -81,8 +86,8 @@ int cmd_range_diff(int argc, const char **argv, const char *prefix)
}
FREE_AND_NULL(options);
- res = show_range_diff(range1.buf, range2.buf, creation_factor,
- simple_color < 1, &diffopt, &other_arg);
+ range_diff_opts.dual_color = simple_color < 1;
+ res = show_range_diff(range1.buf, range2.buf, &range_diff_opts);
strvec_clear(&other_arg);
strbuf_release(&range1);