{"thread":{"id":"23549","subject":"[PATCH] Make git log --follow support --find-copies-harder.","startedAt":"2010-04-21T14:37:21Z","lastAt":"2010-04-22T05:54:55Z","messageCount":4,"participants":["Bo Yang","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"140032","messageId":"1271860641-29305-1-git-send-email-struggleyb.nku@gmail.com","threadId":"23549","inReplyTo":null,"subject":"[PATCH] Make git log --follow support --find-copies-harder.","fromName":"Bo Yang","fromEmail":"struggleyb.nku@gmail.com","sentAt":"2010-04-21T14:37:21Z","receivedAt":"2010-04-21T14:37:21Z","isPatch":true,"sender":{"key":"struggleyb.nku@gmail.com","avatar":"https://avatars.githubusercontent.com/u/233030?v=4"},"body":"'git log --follow --find-copies-harder <path>' don't track copies\nfrom unmodified files, and this patch fix it.\n\nSigned-off-by: Bo Yang <struggleyb.nku@gmail.com>\n---\n t/t4205-log-follow-harder-copies.sh |   56 +++++++++++++++++++++++++++++++++++\n tree-diff.c                         |    2 +\n 2 files changed, 58 insertions(+), 0 deletions(-)\n create mode 100755 t/t4205-log-follow-harder-copies.sh\n\ndiff --git a/t/t4205-log-follow-harder-copies.sh b/t/t4205-log-follow-harder-copies.sh\nnew file mode 100755\nindex 0000000..11e85f4\n--- /dev/null\n+++ b/t/t4205-log-follow-harder-copies.sh\n@@ -0,0 +1,56 @@\n+#!/bin/sh\n+#\n+# Copyright (c) 2010 Bo Yang\n+#\n+\n+test_description='Test --follow with --find-copies-harder in git log.\n+\n+'\n+. ./test-lib.sh\n+. \"$TEST_DIRECTORY\"/diff-lib.sh\n+\n+echo >path0 'Line 1\n+Line 2\n+Line 3\n+'\n+\n+test_expect_success \\\n+    'add a file path0 and commit.' \\\n+    'git add path0 &&\n+     git commit -m \"Add path0\"'\n+\n+echo >path0 'New line 1\n+New line 2\n+New line 3\n+'\n+test_expect_success \\\n+    'Change path0.' \\\n+    'git add path0 &&\n+     git commit -m \"Change path0\"'\n+\n+cat <path0 >path1\n+test_expect_success \\\n+    'copy path0 to path1.' \\\n+    'git add path1 &&\n+     git commit -m \"Copy path1 from path0\"'\n+\n+test_expect_success \\\n+    'find the copy path0 -> path1 harder' \\\n+    'git log --follow --find-copies-harder --name-status --pretty=\"format:%s\"  path1 > current'\n+\n+cat >expected <<\\EOF\n+Copy path1 from path0\n+C100\tpath0\tpath1\n+\n+Change path0\n+M\tpath0\n+\n+Add path0\n+A\tpath0\n+EOF\n+\n+test_expect_success \\\n+    'validate the output.' \\\n+    'compare_diff_patch current expected'\n+\n+test_done\ndiff --git a/tree-diff.c b/tree-diff.c\nindex fe9f52c..0dea53e 100644\n--- a/tree-diff.c\n+++ b/tree-diff.c\n@@ -346,6 +346,8 @@ static void try_to_follow_renames(struct tree_desc *t1, struct tree_desc *t2, co\n \n \tdiff_setup(&diff_opts);\n \tDIFF_OPT_SET(&diff_opts, RECURSIVE);\n+\tif (DIFF_OPT_TST(opt, FIND_COPIES_HARDER))\n+\t\tDIFF_OPT_SET(&diff_opts, FIND_COPIES_HARDER);\n \tdiff_opts.detect_rename = DIFF_DETECT_RENAME;\n \tdiff_opts.output_format = DIFF_FORMAT_NO_OUTPUT;\n \tdiff_opts.single_follow = opt->paths[0];\n-- \n1.7.0.2.273.gc2413.dirty\n"},{"id":"140042","messageId":"7v8w8gbv75.fsf@alter.siamese.dyndns.org","threadId":"23549","inReplyTo":"1271860641-29305-1-git-send-email-struggleyb.nku@gmail.com","subject":"Re: [PATCH] Make git log --follow support --find-copies-harder.","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2010-04-21T16:56:46Z","receivedAt":"2010-04-21T16:56:46Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Bo Yang <struggleyb.nku@gmail.com> writes:\n\n> 'git log --follow --find-copies-harder <path>' don't track copies\n> from unmodified files, and this patch fix it.\n\nWhat does the command do when given a single -C instead of --f-c-h, with\nor without your patch?  What should it do?\n\nBecause try_to_follow_renames() is supposed to be a rare-event (it only\nhappens when a path we have been following disappears), I am having this\nfeeling that it would make more sense to do this change unconditionally.\n\nTwo possible outcomes that this patch allows the users to have by giving\nthem a choice to give (or not to give) --f-c-h are:\n\n (1) the path is judged to be new in a commit and traversal finishes\n     there; or \n\n (2) the path is found to be a copy from another path from one of the\n     parents and traversal continues.\n\nBut I think using --follow is a sure sign of the user wanting the latter\nand never the former, no?\n"},{"id":"140093","messageId":"m2p41f08ee11004211927w88506198sfd740da672b5c6f7@mail.gmail.com","threadId":"23549","inReplyTo":"7v8w8gbv75.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH] Make git log --follow support --find-copies-harder.","fromName":"Bo Yang","fromEmail":"struggleyb.nku@gmail.com","sentAt":"2010-04-22T02:27:55Z","receivedAt":"2010-04-22T02:27:55Z","isPatch":true,"sender":{"key":"struggleyb.nku@gmail.com","avatar":"https://avatars.githubusercontent.com/u/233030?v=4"},"body":"On Thu, Apr 22, 2010 at 12:56 AM, Junio C Hamano <gitster@pobox.com> wrote:\n> What does the command do when given a single -C instead of --f-c-h, with\n> or without your patch?  What should it do?\n\nI have found that two days ago, all '-M/-C/-C -C' with some <path>\nspecified will fail.\nbyang@byang-laptop:~/git/git$ git diff --name-status -M  maint master\nbuiltin/add.c\nA       builtin/add.c\n\nbyang@byang-laptop:~/git/git$ git log -M -C -C --name-status\n--pretty=oneline t/t4013/diff.show_--first-parent_master\n2bf6587349e31b582dae47954b1a334052230e28 show --first-parent/-m: do\nnot default to --cc\nA       t/t4013/diff.show_--first-parent_master\n\nwithout <path>\nbyang@byang-laptop:~/git/git$ git diff --name-status -M  maint master\n| grep  'builtin/add.c'\nR100\tbuiltin-add.c\tbuiltin/add.c\n\nbyang@byang-laptop:~/git/git$ git log -M -C -C --name-status\n--pretty=oneline | grep -- 't/t4013/diff.show_--first-parent_master'\nC050\tt/t4013/diff.show_master\tt/t4013/diff.show_--first-parent_master\n\nBoth of above files are copied/renamed.\n\nThis because in diff_tree,\n\n              if (opt->nr_paths) {\n                        skip_uninteresting(t1, base, baselen, opt);\n                        skip_uninteresting(t2, base, baselen, opt);\n                }\n\nAnd this give no chance for later rename/copy detection. I have been\ntrying to figure out a patch for this, but the logic is complex and it\nwill take more time...\n\n> Because try_to_follow_renames() is supposed to be a rare-event (it only\n> happens when a path we have been following disappears), I am having this\n> feeling that it would make more sense to do this change unconditionally.\n>\n> Two possible outcomes that this patch allows the users to have by giving\n> them a choice to give (or not to give) --f-c-h are:\n>\n>  (1) the path is judged to be new in a commit and traversal finishes\n>     there; or\n>\n>  (2) the path is found to be a copy from another path from one of the\n>     parents and traversal continues.\n>\n> But I think using --follow is a sure sign of the user wanting the latter\n> and never the former, no?\n\nHmm, that makes sense. So, --follow always means --f-c-h.\n\nRegards!\nBo\n"},{"id":"140101","messageId":"7vbpdc6ngw.fsf@alter.siamese.dyndns.org","threadId":"23549","inReplyTo":"m2p41f08ee11004211927w88506198sfd740da672b5c6f7@mail.gmail.com","subject":"Re: [PATCH] Make git log --follow support --find-copies-harder.","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2010-04-22T05:54:55Z","receivedAt":"2010-04-22T05:54:55Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Bo Yang <struggleyb.nku@gmail.com> writes:\n\n> This because in diff_tree,\n>\n>               if (opt->nr_paths) {\n>                         skip_uninteresting(t1, base, baselen, opt);\n>                         skip_uninteresting(t2, base, baselen, opt);\n>                 }\n>\n> And this give no chance for later rename/copy detection.\n\nThat is rather an old news.  This thread may help to avoid rehashing the\nsame issues:\n\n    http://thread.gmane.org/gmane.comp.version-control.git/10225/focus=10259\n"}]}