Skip to content

Commit c22d41d

Browse files
committed
format-patch: run range-diff with larger creation-factor
We see too often that a range-diff added to format-patch output shows too many "unmatched" patches. This is because the default value for creation-factor is set to a relatively low value. It may be justified for other uses (like you have a yet-to-be-sent new iteration of your series, and compare it against the 'seen' branch that has an older iteration, probably with the '--left-only' option, to pick out only your patches while ignoring the others) of "range-diff" command, but when the command is run as part of the format-patch, the user _knows_ and expects that the patches in the old and the new iterations roughly correspond to each other, so we can and should use a much higher default. Signed-off-by: Junio C Hamano <[email protected]>
1 parent 786a3e4 commit c22d41d

File tree

3 files changed

+12
-1
lines changed

3 files changed

+12
-1
lines changed

Documentation/git-format-patch.txt

+5
Original file line numberDiff line numberDiff line change
@@ -346,6 +346,11 @@ material (this may change in the future).
346346
between the previous and current series of patches by adjusting the
347347
creation/deletion cost fudge factor. See linkgit:git-range-diff[1])
348348
for details.
349+
+
350+
Defaults to 999 (the linkgit:git-range-diff[1] uses 60), as the use
351+
case is to show comparison with an older iteration of the same
352+
topic and the tool should find more correspondence between the two
353+
sets of patches.
349354

350355
--notes[=<ref>]::
351356
--no-notes::

builtin/log.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -2274,7 +2274,7 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
22742274
}
22752275

22762276
if (creation_factor < 0)
2277-
creation_factor = RANGE_DIFF_CREATION_FACTOR_DEFAULT;
2277+
creation_factor = CREATION_FACTOR_FOR_THE_SAME_SERIES;
22782278
else if (!rdiff_prev)
22792279
die(_("the option '%s' requires '%s'"), "--creation-factor", "--range-diff");
22802280

range-diff.h

+6
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,12 @@
66

77
#define RANGE_DIFF_CREATION_FACTOR_DEFAULT 60
88

9+
/*
10+
* A much higher value than the default, when we KNOW we are comparing
11+
* the same series (e.g., used when format-patch calls range-diff).
12+
*/
13+
#define CREATION_FACTOR_FOR_THE_SAME_SERIES 999
14+
915
struct range_diff_options {
1016
int creation_factor;
1117
unsigned dual_color:1;

0 commit comments

Comments
 (0)