{"thread":{"id":"28187","subject":"[PATCH v3 0/5] Support threshold in copy/rename detection","startedAt":"2011-08-22T08:33:04Z","lastAt":"2011-08-22T12:44:54Z","messageCount":8,"participants":["Vitor Antunes","Pete Wyckoff"],"isPatch":true,"patchVersion":3,"patchTotal":5},"messages":[{"id":"173998","messageId":"1314001989-29017-1-git-send-email-vitor.hda@gmail.com","threadId":"28187","inReplyTo":null,"subject":"[PATCH v3 0/5] Support threshold in copy/rename detection","fromName":"Vitor Antunes","fromEmail":"vitor.hda@gmail.com","sentAt":"2011-08-22T08:33:04Z","receivedAt":"2011-08-22T08:33:04Z","isPatch":true,"sender":{"key":"vitor.hda@gmail.com","avatar":"https://avatars.githubusercontent.com/u/606876?v=4"},"body":"Make detectCopiesHarder use \"git config --bool\".\nInclude Pete Wyckoff's patches to test cases.\n\nVitor Antunes (5):\n  git-p4: Allow setting rename/copy detection threshold\n  git-p4: Add description of rename/copy detection options\n  git-p4: Add test case for rename detection\n  git-p4: Add test case for copy detection\n  git-p4: Process detectCopiesHarder with --bool\n\n contrib/fast-import/git-p4     |   15 +++--\n contrib/fast-import/git-p4.txt |   25 +++++++\n t/t9800-git-p4.sh              |  136 ++++++++++++++++++++++++++++++++++++++++\n 3 files changed, 171 insertions(+), 5 deletions(-)\n\n-- \n1.7.5.4\n"},{"id":"173999","messageId":"1314001989-29017-2-git-send-email-vitor.hda@gmail.com","threadId":"28187","inReplyTo":"1314001989-29017-1-git-send-email-vitor.hda@gmail.com","subject":"[PATCH v3 1/5] git-p4: Allow setting rename/copy detection threshold","fromName":"Vitor Antunes","fromEmail":"vitor.hda@gmail.com","sentAt":"2011-08-22T08:33:05Z","receivedAt":"2011-08-22T08:33:05Z","isPatch":true,"sender":{"key":"vitor.hda@gmail.com","avatar":"https://avatars.githubusercontent.com/u/606876?v=4"},"body":"Copy and rename detection arguments (-C and -M) allow setting a threshold value\nfor the similarity ratio. If the similarity is below this threshold the rename\nor copy is ignored and the file is added as new.\nThis patch allows setting git-p4.detectRenames and git-p4.detectCopies options\nto an integer value to set the respective threshold.\n\nSigned-off-by: Vitor Antunes <vitor.hda@gmail.com>\n---\n contrib/fast-import/git-p4 |   13 +++++++++----\n 1 files changed, 9 insertions(+), 4 deletions(-)\n\ndiff --git a/contrib/fast-import/git-p4 b/contrib/fast-import/git-p4\nindex 6b9de9e..29a5390f 100755\n--- a/contrib/fast-import/git-p4\n+++ b/contrib/fast-import/git-p4\n@@ -774,15 +774,20 @@ class P4Submit(Command, P4UserMap):\n \n         if not self.detectRenames:\n             # If not explicitly set check the config variable\n-            self.detectRenames = gitConfig(\"git-p4.detectRenames\").lower() == \"true\"\n+            self.detectRenames = gitConfig(\"git-p4.detectRenames\")\n \n-        if self.detectRenames:\n+        if self.detectRenames.lower() == \"false\" or self.detectRenames == \"\":\n+            diffOpts = \"\"\n+        elif self.detectRenames.lower() == \"true\":\n             diffOpts = \"-M\"\n         else:\n-            diffOpts = \"\"\n+            diffOpts = \"-M%s\" % self.detectRenames\n \n-        if gitConfig(\"git-p4.detectCopies\").lower() == \"true\":\n+        detectCopies = gitConfig(\"git-p4.detectCopies\")\n+        if detectCopies.lower() == \"true\":\n             diffOpts += \" -C\"\n+        elif detectCopies != \"\" and detectCopies.lower() != \"false\":\n+            diffOpts += \" -C%s\" % detectCopies\n \n         if gitConfig(\"git-p4.detectCopiesHarder\").lower() == \"true\":\n             diffOpts += \" --find-copies-harder\"\n-- \n1.7.5.4\n"},{"id":"174000","messageId":"1314001989-29017-3-git-send-email-vitor.hda@gmail.com","threadId":"28187","inReplyTo":"1314001989-29017-1-git-send-email-vitor.hda@gmail.com","subject":"[PATCH v3 2/5] git-p4: Add description of rename/copy detection options","fromName":"Vitor Antunes","fromEmail":"vitor.hda@gmail.com","sentAt":"2011-08-22T08:33:06Z","receivedAt":"2011-08-22T08:33:06Z","isPatch":true,"sender":{"key":"vitor.hda@gmail.com","avatar":"https://avatars.githubusercontent.com/u/606876?v=4"},"body":"Signed-off-by: Vitor Antunes <vitor.hda@gmail.com>\n---\n contrib/fast-import/git-p4.txt |   25 +++++++++++++++++++++++++\n 1 files changed, 25 insertions(+), 0 deletions(-)\n\ndiff --git a/contrib/fast-import/git-p4.txt b/contrib/fast-import/git-p4.txt\nindex caa4bb3..2ffbccc 100644\n--- a/contrib/fast-import/git-p4.txt\n+++ b/contrib/fast-import/git-p4.txt\n@@ -232,6 +232,31 @@ git-p4.skipUserNameCheck\n When submitting, git-p4 checks that the git commits are authored by the current\n p4 user, and warns if they are not. This disables the check.\n \n+git-p4.detectRenames\n+\n+Detect renames when submitting changes to Perforce server. Will enable -M git\n+argument. Can be optionally set to a number representing the threshold\n+percentage value of the rename detection.\n+\n+  git config [--global] git-p4.detectRenames true\n+  git config [--global] git-p4.detectRenames 50\n+\n+git-p4.detectCopies\n+\n+Detect copies when submitting changes to Perforce server. Will enable -C git\n+argument. Can be optionally set to a number representing the threshold\n+percentage value of the copy detection.\n+\n+  git config [--global] git-p4.detectCopies true\n+  git config [--global] git-p4.detectCopies 80\n+\n+git-p4.detectCopiesHarder\n+\n+Detect copies even between files that did not change when submitting changes to\n+Perforce server. Will enable --find-copies-harder git argument.\n+\n+  git config [--global] git-p4.detectCopies true\n+\n Implementation Details...\n =========================\n \n-- \n1.7.5.4\n"},{"id":"174001","messageId":"1314001989-29017-4-git-send-email-vitor.hda@gmail.com","threadId":"28187","inReplyTo":"1314001989-29017-1-git-send-email-vitor.hda@gmail.com","subject":"[PATCH v3 3/5] git-p4: Add test case for rename detection","fromName":"Vitor Antunes","fromEmail":"vitor.hda@gmail.com","sentAt":"2011-08-22T08:33:07Z","receivedAt":"2011-08-22T08:33:07Z","isPatch":true,"sender":{"key":"vitor.hda@gmail.com","avatar":"https://avatars.githubusercontent.com/u/606876?v=4"},"body":"Signed-off-by: Vitor Antunes <vitor.hda@gmail.com>\nSigned-off-by: Pete Wyckoff <pw@padd.com>\n---\n t/t9800-git-p4.sh |   53 +++++++++++++++++++++++++++++++++++++++++++++++++++++\n 1 files changed, 53 insertions(+), 0 deletions(-)\n\ndiff --git a/t/t9800-git-p4.sh b/t/t9800-git-p4.sh\nindex 97ec975..5a5fd0f 100755\n--- a/t/t9800-git-p4.sh\n+++ b/t/t9800-git-p4.sh\n@@ -269,6 +269,59 @@ test_expect_success 'initial import time from top change time' '\n \ttest $p4time = $gittime\n '\n \n+# Rename a file and confirm that rename is not detected in P4.\n+# Rename the new file again with detectRenames option enabled and confirm that\n+# this is detected in P4.\n+# Rename the new file again adding an extra line, configure a big threshold in\n+# detectRenames and confirm that rename is not detected in P4.\n+# Repeat, this time with a smaller threshold and confirm that the rename is\n+# detected in P4.\n+test_expect_success 'detect renames' '\n+\t\"$GITP4\" clone --dest=\"$git\" //depot@all &&\n+\ttest_when_finished cleanup_git &&\n+\tcd \"$git\" &&\n+\tgit config git-p4.skipSubmitEditCheck true &&\n+\n+\tgit mv file1 file4 &&\n+\tgit commit -a -m \"Rename file1 to file4\" &&\n+\tgit diff-tree -r -M HEAD &&\n+\t\"$GITP4\" submit &&\n+\tp4 filelog //depot/file4 &&\n+\t! p4 filelog //depot/file4 | grep -q \"branch from\" &&\n+\n+\tgit mv file4 file5 &&\n+\tgit commit -a -m \"Rename file4 to file5\" &&\n+\tgit diff-tree -r -M HEAD &&\n+\tgit config git-p4.detectRenames true &&\n+\t\"$GITP4\" submit &&\n+\tp4 filelog //depot/file5 &&\n+\tp4 filelog //depot/file5 | grep -q \"branch from //depot/file4\" &&\n+\n+\tgit mv file5 file6 &&\n+\techo update >>file6 &&\n+\tgit add file6 &&\n+\tgit commit -a -m \"Rename file5 to file6 with changes\" &&\n+\tgit diff-tree -r -M HEAD &&\n+\tlevel=$(git diff-tree -r -M HEAD | sed 1d | cut -f1 | cut -d\" \" -f5 | sed \"s/R0*//\") &&\n+\ttest -n \"$level\" && test \"$level\" -gt 0 && test \"$level\" -lt 98 &&\n+\tgit config git-p4.detectRenames $((level + 2)) &&\n+\t\"$GITP4\" submit &&\n+\tp4 filelog //depot/file6 &&\n+\t! p4 filelog //depot/file6 | grep -q \"branch from\" &&\n+\n+\tgit mv file6 file7 &&\n+\techo update >>file7 &&\n+\tgit add file7 &&\n+\tgit commit -a -m \"Rename file6 to file7 with changes\" &&\n+\tgit diff-tree -r -M HEAD &&\n+\tlevel=$(git diff-tree -r -M HEAD | sed 1d | cut -f1 | cut -d\" \" -f5 | sed \"s/R0*//\") &&\n+\ttest -n \"$level\" && test \"$level\" -gt 2 && test \"$level\" -lt 100 &&\n+\tgit config git-p4.detectRenames $((level - 2)) &&\n+\t\"$GITP4\" submit &&\n+\tp4 filelog //depot/file7 &&\n+\tp4 filelog //depot/file7 | grep -q \"branch from //depot/file6\"\n+'\n+\n test_expect_success 'shutdown' '\n \tpid=`pgrep -f p4d` &&\n \ttest -n \"$pid\" &&\n-- \n1.7.5.4\n"},{"id":"174002","messageId":"1314001989-29017-5-git-send-email-vitor.hda@gmail.com","threadId":"28187","inReplyTo":"1314001989-29017-1-git-send-email-vitor.hda@gmail.com","subject":"[PATCH v3 4/5] git-p4: Add test case for copy detection","fromName":"Vitor Antunes","fromEmail":"vitor.hda@gmail.com","sentAt":"2011-08-22T08:33:08Z","receivedAt":"2011-08-22T08:33:08Z","isPatch":true,"sender":{"key":"vitor.hda@gmail.com","avatar":"https://avatars.githubusercontent.com/u/606876?v=4"},"body":"Signed-off-by: Vitor Antunes <vitor.hda@gmail.com>\nSigned-off-by: Pete Wyckoff <pw@padd.com>\n---\n t/t9800-git-p4.sh |   83 +++++++++++++++++++++++++++++++++++++++++++++++++++++\n 1 files changed, 83 insertions(+), 0 deletions(-)\n\ndiff --git a/t/t9800-git-p4.sh b/t/t9800-git-p4.sh\nindex 5a5fd0f..9d4d4bf 100755\n--- a/t/t9800-git-p4.sh\n+++ b/t/t9800-git-p4.sh\n@@ -322,6 +322,89 @@ test_expect_success 'detect renames' '\n \tp4 filelog //depot/file7 | grep -q \"branch from //depot/file6\"\n '\n \n+# Copy a file and confirm that copy is not detected in P4.\n+# Copy a file with detectCopies option enabled and confirm that copy is not\n+# detected in P4.\n+# Modify and copy a file with detectCopies option enabled and confirm that copy\n+# is detected in P4.\n+# Copy a file with detectCopies and detectCopiesHarder options enabled and\n+# confirm that copy is detected in P4.\n+# Modify and copy a file, configure a bigger threshold in detectCopies and\n+# confirm that copy is not detected in P4.\n+# Modify and copy a file, configure a smaller threshold in detectCopies and\n+# confirm that copy is detected in P4.\n+test_expect_success 'detect copies' '\n+\t\"$GITP4\" clone --dest=\"$git\" //depot@all &&\n+\ttest_when_finished cleanup_git &&\n+\tcd \"$git\" &&\n+\tgit config git-p4.skipSubmitEditCheck true &&\n+\n+\tcp file2 file8 &&\n+\tgit add file8 &&\n+\tgit commit -a -m \"Copy file2 to file8\" &&\n+\tgit diff-tree -r -C HEAD &&\n+\t\"$GITP4\" submit &&\n+\tp4 filelog //depot/file8 &&\n+\t! p4 filelog //depot/file8 | grep -q \"branch from\" &&\n+\n+\tcp file2 file9 &&\n+\tgit add file9 &&\n+\tgit commit -a -m \"Copy file2 to file9\" &&\n+\tgit diff-tree -r -C HEAD &&\n+\tgit config git-p4.detectCopies true &&\n+\t\"$GITP4\" submit &&\n+\tp4 filelog //depot/file9 &&\n+\t! p4 filelog //depot/file9 | grep -q \"branch from\" &&\n+\n+\techo \"file2\" >>file2 &&\n+\tcp file2 file10 &&\n+\tgit add file2 file10 &&\n+\tgit commit -a -m \"Modify and copy file2 to file10\" &&\n+\tgit diff-tree -r -C HEAD &&\n+\t\"$GITP4\" submit &&\n+\tp4 filelog //depot/file10 &&\n+\tp4 filelog //depot/file10 | grep -q \"branch from //depot/file\" &&\n+\n+\tcp file2 file11 &&\n+\tgit add file11 &&\n+\tgit commit -a -m \"Copy file2 to file11\" &&\n+\tgit diff-tree -r -C --find-copies-harder HEAD &&\n+\tsrc=$(git diff-tree -r -C --find-copies-harder HEAD | sed 1d | cut -f2) &&\n+\ttest \"$src\" = file10 &&\n+\tgit config git-p4.detectCopiesHarder true &&\n+\t\"$GITP4\" submit &&\n+\tp4 filelog //depot/file11 &&\n+\tp4 filelog //depot/file11 | grep -q \"branch from //depot/file\" &&\n+\n+\tcp file2 file12 &&\n+\techo \"some text\" >>file12 &&\n+\tgit add file12 &&\n+\tgit commit -a -m \"Copy file2 to file12 with changes\" &&\n+\tgit diff-tree -r -C --find-copies-harder HEAD &&\n+\tlevel=$(git diff-tree -r -C --find-copies-harder HEAD | sed 1d | cut -f1 | cut -d\" \" -f5 | sed \"s/C0*//\") &&\n+\ttest -n \"$level\" && test \"$level\" -gt 0 && test \"$level\" -lt 98 &&\n+\tsrc=$(git diff-tree -r -C --find-copies-harder HEAD | sed 1d | cut -f2) &&\n+\ttest \"$src\" = file10 &&\n+\tgit config git-p4.detectCopies $((level + 2)) &&\n+\t\"$GITP4\" submit &&\n+\tp4 filelog //depot/file12 &&\n+\t! p4 filelog //depot/file12 | grep -q \"branch from\" &&\n+\n+\tcp file2 file13 &&\n+\techo \"different text\" >>file13 &&\n+\tgit add file13 &&\n+\tgit commit -a -m \"Copy file2 to file13 with changes\" &&\n+\tgit diff-tree -r -C --find-copies-harder HEAD &&\n+\tlevel=$(git diff-tree -r -C --find-copies-harder HEAD | sed 1d | cut -f1 | cut -d\" \" -f5 | sed \"s/C0*//\") &&\n+\ttest -n \"$level\" && test \"$level\" -gt 2 && test \"$level\" -lt 100 &&\n+\tsrc=$(git diff-tree -r -C --find-copies-harder HEAD | sed 1d | cut -f2) &&\n+\ttest \"$src\" = file10 &&\n+\tgit config git-p4.detectCopies $((level - 2)) &&\n+\t\"$GITP4\" submit &&\n+\tp4 filelog //depot/file13 &&\n+\tp4 filelog //depot/file13 | grep -q \"branch from //depot/file\"\n+'\n+\n test_expect_success 'shutdown' '\n \tpid=`pgrep -f p4d` &&\n \ttest -n \"$pid\" &&\n-- \n1.7.5.4\n"},{"id":"174003","messageId":"1314001989-29017-6-git-send-email-vitor.hda@gmail.com","threadId":"28187","inReplyTo":"1314001989-29017-1-git-send-email-vitor.hda@gmail.com","subject":"[PATCH v3 5/5] git-p4: Process detectCopiesHarder with --bool","fromName":"Vitor Antunes","fromEmail":"vitor.hda@gmail.com","sentAt":"2011-08-22T08:33:09Z","receivedAt":"2011-08-22T08:33:09Z","isPatch":true,"sender":{"key":"vitor.hda@gmail.com","avatar":"https://avatars.githubusercontent.com/u/606876?v=4"},"body":"Signed-off-by: Vitor Antunes <vitor.hda@gmail.com>\n---\n contrib/fast-import/git-p4 |    2 +-\n 1 files changed, 1 insertions(+), 1 deletions(-)\n\ndiff --git a/contrib/fast-import/git-p4 b/contrib/fast-import/git-p4\nindex 29a5390f..0db3e72 100755\n--- a/contrib/fast-import/git-p4\n+++ b/contrib/fast-import/git-p4\n@@ -789,7 +789,7 @@ class P4Submit(Command, P4UserMap):\n         elif detectCopies != \"\" and detectCopies.lower() != \"false\":\n             diffOpts += \" -C%s\" % detectCopies\n \n-        if gitConfig(\"git-p4.detectCopiesHarder\").lower() == \"true\":\n+        if gitConfig(\"git-p4.detectCopiesHarder\", \"--bool\") == \"true\":\n             diffOpts += \" --find-copies-harder\"\n \n         diff = read_pipe_lines(\"git diff-tree -r %s \\\"%s^\\\" \\\"%s\\\"\" % (diffOpts, id, id))\n-- \n1.7.5.4\n"},{"id":"174013","messageId":"20110822121837.GA3761@arf.padd.com","threadId":"28187","inReplyTo":"1314001989-29017-2-git-send-email-vitor.hda@gmail.com","subject":"Re: [PATCH v3 1/5] git-p4: Allow setting rename/copy detection threshold","fromName":"Pete Wyckoff","fromEmail":"pw@padd.com","sentAt":"2011-08-22T12:18:37Z","receivedAt":"2011-08-22T12:18:37Z","isPatch":true,"sender":{"key":"pw@padd.com","avatar":null},"body":"vitor.hda@gmail.com wrote on Mon, 22 Aug 2011 09:33 +0100:\n> Copy and rename detection arguments (-C and -M) allow setting a threshold value\n> for the similarity ratio. If the similarity is below this threshold the rename\n> or copy is ignored and the file is added as new.\n> This patch allows setting git-p4.detectRenames and git-p4.detectCopies options\n> to an integer value to set the respective threshold.\n> \n> Signed-off-by: Vitor Antunes <vitor.hda@gmail.com>\n\nThis series looks great.  Thanks for fixing the --bool issue and\nthe tests.\n\nAcked-by: Pete Wyckoff <pw@padd.com>\n\n\t\t-- Pete\n"},{"id":"174015","messageId":"CAOpHH-X7D4SCCTuqu_DxY4F6N3kY0x7pb_qS+5D6+1bwGK_60w@mail.gmail.com","threadId":"28187","inReplyTo":"20110822121837.GA3761@arf.padd.com","subject":"Re: [PATCH v3 1/5] git-p4: Allow setting rename/copy detection threshold","fromName":"Vitor Antunes","fromEmail":"vitor.hda@gmail.com","sentAt":"2011-08-22T12:44:54Z","receivedAt":"2011-08-22T12:44:54Z","isPatch":true,"sender":{"key":"vitor.hda@gmail.com","avatar":"https://avatars.githubusercontent.com/u/606876?v=4"},"body":"On Mon, Aug 22, 2011 at 1:18 PM, Pete Wyckoff <pw@padd.com> wrote:\n> This series looks great.  Thanks for fixing the --bool issue and\n> the tests.\n\nThank *you* for the help and suggestions.\n-- \nVitor Antunes\n"}]}