]> git.ipfire.org Git - thirdparty/git.git/commitdiff
format-patch: run range-diff with larger creation-factor
authorJunio C Hamano <gitster@pobox.com>
Mon, 6 May 2024 16:40:31 +0000 (09:40 -0700)
committerJunio C Hamano <gitster@pobox.com>
Mon, 6 May 2024 18:57:22 +0000 (11:57 -0700)
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 <gitster@pobox.com>
Documentation/git-format-patch.txt
builtin/log.c
range-diff.h

index 728bb3821c1729dffe7565fa812570c315d0f878..b72f87b114c8074122d7c5550de2c063246f47e3 100644 (file)
@@ -346,6 +346,11 @@ material (this may change in the future).
        between the previous and current series of patches by adjusting the
        creation/deletion cost fudge factor. See linkgit:git-range-diff[1])
        for details.
++
+Defaults to 999 (the linkgit:git-range-diff[1] uses 60), as the use
+case is to show comparison with an older iteration of the same
+topic and the tool should find more correspondence between the two
+sets of patches.
 
 --notes[=<ref>]::
 --no-notes::
index c0a8bb95e9830b655c8de71521764c59b73c6ea0..73608ffef9639929d2138c400b92b65a20ecf9ee 100644 (file)
@@ -2274,7 +2274,7 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
        }
 
        if (creation_factor < 0)
-               creation_factor = RANGE_DIFF_CREATION_FACTOR_DEFAULT;
+               creation_factor = CREATION_FACTOR_FOR_THE_SAME_SERIES;
        else if (!rdiff_prev)
                die(_("the option '%s' requires '%s'"), "--creation-factor", "--range-diff");
 
index 04ffe217be67c32d378a94f90094b70b01e55548..2f69f6a434d7d05877ebf8d181475cb6848aee28 100644 (file)
@@ -6,6 +6,12 @@
 
 #define RANGE_DIFF_CREATION_FACTOR_DEFAULT 60
 
+/*
+ * A much higher value than the default, when we KNOW we are comparing
+ * the same series (e.g., used when format-patch calls range-diff).
+ */
+#define CREATION_FACTOR_FOR_THE_SAME_SERIES 999
+
 struct range_diff_options {
        int creation_factor;
        unsigned dual_color:1;