{"thread":{"id":"896","subject":"[PATCH] diff-tree: --find-copies-harder","startedAt":"2005-06-11T01:31:02Z","lastAt":"2005-06-11T01:31:02Z","messageCount":1,"participants":["Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"4841","messageId":"7vpsut7k89.fsf@assigned-by-dhcp.cox.net","threadId":"896","inReplyTo":null,"subject":"[PATCH] diff-tree: --find-copies-harder","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2005-06-11T01:31:02Z","receivedAt":"2005-06-11T01:31:02Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Normally, diff-tree does not feed unchanged filepair to diffcore\nfor performance reasons, so copies are detected only when the\nsource file of the copy happens to be modified in the same\nchangeset.  This adds --find-copies-harder flag to tell\ndiff-tree to sacrifice the performance in order to find copies\nthe same way as other commands in diff-* family.\n\nSigned-off-by: Junio C Hamano <junkio@cox.net>\n---\n\n*** Linus I am submitting this one because some patches on\n*** read-tree I am going to send you will need this for\n*** formatting into a form that is easier to review.  Also this\n*** feature came up during the recent discussion on \"what to do\n*** with merging rename/copy in the longer term\".\n\n diff-tree.c |   13 ++++++++++---\n 1 files changed, 10 insertions(+), 3 deletions(-)\n\ndiff --git a/diff-tree.c b/diff-tree.c\n--- a/diff-tree.c\n+++ b/diff-tree.c\n@@ -11,6 +11,7 @@ static int show_tree_entry_in_recursive \n static int read_stdin = 0;\n static int diff_output_format = DIFF_FORMAT_HUMAN;\n static int detect_rename = 0;\n+static int find_copies_harder = 0;\n static int diff_setup_opt = 0;\n static int diff_score_opt = 0;\n static const char *pickaxe = NULL;\n@@ -115,7 +116,7 @@ static int compare_tree_entry(void *tree\n \t\tshow_file(\"+\", tree2, size2, base);\n \t\treturn 1;\n \t}\n-\tif (!memcmp(sha1, sha2, 20) && mode1 == mode2)\n+\tif (!find_copies_harder && !memcmp(sha1, sha2, 20) && mode1 == mode2)\n \t\treturn 0;\n \n \t/*\n@@ -199,7 +200,7 @@ static int interesting(void *tree, unsig\n static void show_tree(const char *prefix, void *tree, unsigned long size, const char *base)\n {\n \twhile (size) {\n-\t\tif (interesting(tree, size, base))\n+\t\tif (find_copies_harder || interesting(tree, size, base))\n \t\t\tshow_file(prefix, tree, size, base);\n \t\tupdate_tree_entry(&tree, &size);\n \t}\n@@ -267,7 +268,7 @@ static void call_diff_setup(void)\n \n static int call_diff_flush(void)\n {\n-\tdiffcore_std(0,\n+\tdiffcore_std(find_copies_harder ? paths : 0,\n \t\t     detect_rename, diff_score_opt,\n \t\t     pickaxe, pickaxe_opts,\n \t\t     diff_break_opt,\n@@ -475,6 +476,10 @@ int main(int argc, const char **argv)\n \t\t\t\tusage(diff_tree_usage);\n \t\t\tcontinue;\n \t\t}\n+\t\tif (!strcmp(arg, \"--find-copies-harder\")) {\n+\t\t\tfind_copies_harder = 1;\n+\t\t\tcontinue;\n+\t\t}\n \t\tif (!strcmp(arg, \"-z\")) {\n \t\t\tdiff_output_format = DIFF_FORMAT_MACHINE;\n \t\t\tcontinue;\n@@ -502,6 +507,8 @@ int main(int argc, const char **argv)\n \t\t}\n \t\tusage(diff_tree_usage);\n \t}\n+\tif (find_copies_harder && detect_rename != DIFF_DETECT_COPY)\n+\t\tusage(diff_tree_usage);\n \n \tif (argc > 0) {\n \t\tint i;\n------------\n\n"}]}