range-diff: publish default creation factor

The range-diff back-end allows its heuristic to be tweaked via the "creation factor". git-range-diff, the only client of the back-end, defaults the factor to 60% (hard-coded in builtin/range-diff.c), but allows the user to override it with the --creation-factor option. Publish the default range factor to allow new callers of the range-diff back-end to default to the same value without duplicating the hard-coded constant, and to avoid worrying about various callers becoming out-of-sync if the default ever needs to change. Signed-off-by: Eric Sunshine <sunshine@sunshineco.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Eric Sunshine committed Jul 22, 2018 at 05:57 UTC 25668659bfd74a71de6dd27eac437a17ad72a315
2 files changed +3 -1
builtin/range-diff.c
+1 -1
@@ -18,7 +18,7 @@ static struct strbuf *output_prefix_cb(struct diff_options *opt, void *data)
18
19 int cmd_range_diff(int argc, const char **argv, const char *prefix)
20 {
21 - int creation_factor = 60;
21 + int creation_factor = RANGE_DIFF_CREATION_FACTOR_DEFAULT;
22 struct diff_options diffopt = { NULL };
23 int simple_color = -1;
24 struct option options[] = {
range-diff.h
+2
@@ -3,6 +3,8 @@
3
4 #include "diff.h"
5
6 +#define RANGE_DIFF_CREATION_FACTOR_DEFAULT 60
7 +
8 int show_range_diff(const char *range1, const char *range2,
9 int creation_factor, struct diff_options *diffopt);
10