{"thread":{"id":"29179","subject":"[PATCH] use custom rename score during --follow","startedAt":"2011-12-16T11:27:50Z","lastAt":"2011-12-16T20:33:19Z","messageCount":2,"participants":["Jeff King","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"181288","messageId":"20111216112749.GA16314@sigill.intra.peff.net","threadId":"29179","inReplyTo":null,"subject":"[PATCH] use custom rename score during --follow","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2011-12-16T11:27:50Z","receivedAt":"2011-12-16T11:27:50Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"If you provide a custom rename score on the command line,\nlike:\n\n  git log -M50 --follow foo.c\n\nit is completely ignored, and there is no way to --follow\nwith a looser rename score. Instead, let's use the same\nrename score that will be used for generating diffs. This is\nconvenient, and mirrors what we do with the break-score.\n\nYou can see an example of it being useful in git.git:\n\n  $ git log --oneline --summary --follow \\\n\t    Documentation/technical/api-string-list.txt\n  86d4b52 string-list: Add API to remove an item from an unsorted list\n  1d2f80f string_list: Fix argument order for string_list_append\n  e242148 string-list: add unsorted_string_list_lookup()\n  0dda1d1 Fix two leftovers from path_list->string_list\n  c455c87 Rename path_list to string_list\n   create mode 100644 Documentation/technical/api-string-list.txt\n\n  $ git log --oneline --summary -M40 --follow \\\n\t  Documentation/technical/api-string-list.txt\n  86d4b52 string-list: Add API to remove an item from an unsorted list\n  1d2f80f string_list: Fix argument order for string_list_append\n  e242148 string-list: add unsorted_string_list_lookup()\n  0dda1d1 Fix two leftovers from path_list->string_list\n  c455c87 Rename path_list to string_list\n   rename Documentation/technical/{api-path-list.txt => api-string-list.txt} (47%)\n  328a475 path-list documentation: document all functions and data structures\n  530e741 Start preparing the API documents.\n   create mode 100644 Documentation/technical/api-path-list.txt\n\nYou could have two separate rename scores, one for following\nand one for diff. But almost nobody is going to want that,\nand it would just be unnecessarily confusing. Besides which,\nwe re-use the diff results from try_to_follow_renames for\nthe actual diff output, which means having them as separate\nscores is actively wrong. E.g., with the current code, you\nget:\n\n  $ git log --oneline --diff-filter=R --name-status \\\n            -M90 --follow git.spec.in\n  27dedf0 GIT 0.99.9j aka 1.0rc3\n  R084    git-core.spec.in        git.spec.in\n  f85639c Rename the RPM from \"git\" to \"git-core\"\n  R098    git.spec.in     git-core.spec.in\n\nThe first one should not be considered a rename by the -M\nscore we gave, but we print it anyway, since we blindly\nre-use the diff information from the follow (which uses the\ndefault score). So this could also be considered simply a\nbug-fix, as with the current code \"-M\" is completely ignored\nwhen using \"--follow\".\n\nSigned-off-by: Jeff King <peff@peff.net>\n---\nI posted this a long time ago as a \"you could do it like this\" patch:\n\n  http://thread.gmane.org/gmane.comp.version-control.git/160681\n\nbut never actually dug more to make sure it wasn't having any weird\neffects on the diff output. As it turns out, I think it is not only not\nhaving a bad effect, but is actively fixing a bug. :)\n\n tree-diff.c |    1 +\n 1 files changed, 1 insertions(+), 0 deletions(-)\n\ndiff --git a/tree-diff.c b/tree-diff.c\nindex 7a51d09..28ad6db 100644\n--- a/tree-diff.c\n+++ b/tree-diff.c\n@@ -209,6 +209,7 @@ static void try_to_follow_renames(struct tree_desc *t1, struct tree_desc *t2, co\n \tdiff_opts.output_format = DIFF_FORMAT_NO_OUTPUT;\n \tdiff_opts.single_follow = opt->pathspec.raw[0];\n \tdiff_opts.break_opt = opt->break_opt;\n+\tdiff_opts.rename_score = opt->rename_score;\n \tpaths[0] = NULL;\n \tdiff_tree_setup_paths(paths, &diff_opts);\n \tif (diff_setup_done(&diff_opts) < 0)\n-- \n1.7.7.4.13.g57bf4\n"},{"id":"181332","messageId":"7v39cki7e8.fsf@alter.siamese.dyndns.org","threadId":"29179","inReplyTo":"20111216112749.GA16314@sigill.intra.peff.net","subject":"Re: [PATCH] use custom rename score during --follow","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2011-12-16T20:33:19Z","receivedAt":"2011-12-16T20:33:19Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Makes sense; thanks.\n"}]}