git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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

From
Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Date
Mar 15, 2019, 16:09 UTC
Message-ID
<87y35g9l18.fsf@evledraar.gmail.com>

I just submittted https://public-inbox.org/git/20190315155959.12390-1-avarab@gmail.com/ 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
Next: Eric Sunshine
Message 1 of 5 in “Use a higher range-diff --creation-factor for format-patch”
  1. Use a higher range-diff --creation-factor for format-patchÆvar Arnfjörð Bjarmason, Mar 15, 2019
  2. Eric SunshineMar 15, 2019
  3. Ævar Arnfjörð BjarmasonMar 15, 2019
  4. Johannes SchindelinMar 21, 2019
  5. Junio C HamanoMar 18, 2019

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.