Subject: [WIP PATCH/RFC] Use a higher range-diff --creation-factor for format-patch

From: Ævar Arnfjörð Bjarmason <[email-masked]>
Date: Fri, 15 Mar 2019 17:09:39 +0100

I just submittted
https://public-inbox.org/git/[email-masked]/
and for 8/8 had to tweak the creation factor to 80% due to having added
a large comment. Maybe something like the below makes more sense for
format-patch?

Also, the "Algorithm" section of git-range-diff describes how we'll try
to find a percentage similarity in the *diff*, but in this case I'm
fairly sure that e.g. a creation factor of 50 would do if it also
considered the commit message.

Maybe I'm just wrong and it does that already, but assuming I'm right in
my reading and it doesn't, was that ever considered? That should result
in fewer false "not the same patch" positives, but maybe if patches are
split up it'll screw things up in other ways.

diff --git a/Documentation/git-format-patch.txt b/Documentation/git-format-patch.txt
index 1af85d404f5..67a4881a20f 100644
--- a/Documentation/git-format-patch.txt
+++ b/Documentation/git-format-patch.txt
@@ -261,6 +261,10 @@ 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 90, whereas the linkgit:git-range-diff[1] default is
+60. It's assumed that you're submitting a new patch series & that we
+should try harder than normal to find similarities.

 --notes[=<ref>]::
 	Append the notes (see linkgit:git-notes[1]) for the commit
diff --git a/builtin/log.c b/builtin/log.c
index ab859f59041..ff340130826 100644
--- a/builtin/log.c
+++ b/builtin/log.c
@@ -1843,7 +1843,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 = RANGE_DIFF_CREATION_FACTOR_FORMAT_PATCH_DEFAULT;
 	else if (!rdiff_prev)
 		die(_("--creation-factor requires --range-diff"));

diff --git a/range-diff.h b/range-diff.h
index 08a50b6e98f..634112396d3 100644
--- a/range-diff.h
+++ b/range-diff.h
@@ -4,6 +4,7 @@
 #include "diff.h"

 #define RANGE_DIFF_CREATION_FACTOR_DEFAULT 60
+#define RANGE_DIFF_CREATION_FACTOR_FORMAT_PATCH_DEFAULT 90

 /*
  * Compare series of commmits in RANGE1 and RANGE2, and emit to the