{"thread":{"id":"28157","subject":"[PATCH v2 0/4] Support threshold in copy/rename detection","startedAt":"2011-08-18T22:20:50Z","lastAt":"2011-08-22T00:09:22Z","messageCount":12,"participants":["Vitor Antunes","Junio C Hamano","Pete Wyckoff"],"isPatch":true,"patchVersion":2,"patchTotal":4},"messages":[{"id":"173793","messageId":"1313706054-11740-1-git-send-email-vitor.hda@gmail.com","threadId":"28157","inReplyTo":null,"subject":"[PATCH v2 0/4] Support threshold in copy/rename detection","fromName":"Vitor Antunes","fromEmail":"vitor.hda@gmail.com","sentAt":"2011-08-18T22:20:50Z","receivedAt":"2011-08-18T22:20:50Z","isPatch":true,"sender":{"key":"vitor.hda@gmail.com","avatar":"https://avatars.githubusercontent.com/u/606876?v=4"},"body":"Second version that includes updates recommended by Pete Wyckoff.\nNow only \"true\" and \"false\" arguments are processed, any other argument\nthat is no \"\" is passed directly.\n\nVitor Antunes (4):\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\n contrib/fast-import/git-p4     |   18 ++++--\n contrib/fast-import/git-p4.txt |   25 ++++++++\n t/t9800-git-p4.sh              |  121 ++++++++++++++++++++++++++++++++++++++++\n 3 files changed, 159 insertions(+), 5 deletions(-)\n\n-- \n1.7.5.4\n"},{"id":"173794","messageId":"1313706054-11740-2-git-send-email-vitor.hda@gmail.com","threadId":"28157","inReplyTo":"1313706054-11740-1-git-send-email-vitor.hda@gmail.com","subject":"[PATCH v2 1/4] git-p4: Allow setting rename/copy detection threshold.","fromName":"Vitor Antunes","fromEmail":"vitor.hda@gmail.com","sentAt":"2011-08-18T22:20:51Z","receivedAt":"2011-08-18T22:20:51Z","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 |   18 +++++++++++++-----\n 1 files changed, 13 insertions(+), 5 deletions(-)\n\ndiff --git a/contrib/fast-import/git-p4 b/contrib/fast-import/git-p4\nindex 6b9de9e..cf719be 100755\n--- a/contrib/fast-import/git-p4\n+++ b/contrib/fast-import/git-p4\n@@ -774,15 +774,23 @@ 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+        diffOpts = \"\"\n+        if self.detectRenames.lower() == \"true\":\n             diffOpts = \"-M\"\n-        else:\n-            diffOpts = \"\"\n+        elif self.detectRenames != \"\":\n+            self.detectRenames = int(self.detectRenames)\n+            if self.detectRenames >= 0 and self.detectRenames <= 100:\n+                diffOpts = \"-M%d\" % 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 != \"\":\n+            detectCopies = int(detectCopies)\n+            if detectCopies >= 0 and detectCopies <= 100:\n+                diffOpts += \" -C%d\" % detectCopies\n \n         if gitConfig(\"git-p4.detectCopiesHarder\").lower() == \"true\":\n             diffOpts += \" --find-copies-harder\"\n-- \n1.7.5.4\n"},{"id":"173795","messageId":"1313706054-11740-3-git-send-email-vitor.hda@gmail.com","threadId":"28157","inReplyTo":"1313706054-11740-1-git-send-email-vitor.hda@gmail.com","subject":"[PATCH v2 2/4] git-p4: Add description of rename/copy detection options.","fromName":"Vitor Antunes","fromEmail":"vitor.hda@gmail.com","sentAt":"2011-08-18T22:20:52Z","receivedAt":"2011-08-18T22:20:52Z","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":"173796","messageId":"1313706054-11740-4-git-send-email-vitor.hda@gmail.com","threadId":"28157","inReplyTo":"1313706054-11740-1-git-send-email-vitor.hda@gmail.com","subject":"[PATCH v2 3/4] git-p4: Add test case for rename detection.","fromName":"Vitor Antunes","fromEmail":"vitor.hda@gmail.com","sentAt":"2011-08-18T22:20:53Z","receivedAt":"2011-08-18T22:20:53Z","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 t/t9800-git-p4.sh |   50 ++++++++++++++++++++++++++++++++++++++++++++++++++\n 1 files changed, 50 insertions(+), 0 deletions(-)\n\ndiff --git a/t/t9800-git-p4.sh b/t/t9800-git-p4.sh\nindex 97ec975..d01a1cb 100755\n--- a/t/t9800-git-p4.sh\n+++ b/t/t9800-git-p4.sh\n@@ -269,6 +269,56 @@ 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 blank line, configure a big\n+# threshold in detectRenames and confirm that rename is not detected in P4.\n+# Rename the new file again adding another extra blank line, configure a small\n+# threshold in detectRenames and confirm that rename is not detected in P4.\n+test_expect_success 'detect renames' '\n+\tgit init \"$git\" &&\n+\tcd \"$git\" &&\n+\tcd \"$TRASH_DIRECTORY\" &&\n+\t\"$GITP4\" clone --dest=\"$git\" //depot@all &&\n+\tp4 files //depot/* &&\n+\tcd \"$git\" &&\n+\tgit mv file1 file4 &&\n+\tgit commit -a -m \"Rename file1 to file4\" &&\n+\tgit diff-tree -r -M HEAD &&\n+\tgit config git-p4.skipSubmitEditCheck true &&\n+\t\"$GITP4\" submit &&\n+\tp4 filelog //depot/file4 &&\n+\t! p4 filelog //depot/file4 | grep -q \"branch from //depot/file1\" &&\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+\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+\tgit config git-p4.detectRenames 95 &&\n+\t\"$GITP4\" submit &&\n+\tp4 filelog //depot/file6 &&\n+\t! p4 filelog //depot/file6 | grep -q \"branch from //depot/file5\" &&\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+\tgit config git-p4.detectRenames 80 &&\n+\t\"$GITP4\" submit &&\n+\tp4 filelog //depot/file7 &&\n+\tp4 filelog //depot/file7 | grep -q \"branch from //depot/file6\" &&\n+\tcd \"$TRASH_DIRECTORY\" &&\n+\trm -rf \"$git\" && mkdir \"$git\"\n+'\n+\n test_expect_success 'shutdown' '\n \tpid=`pgrep -f p4d` &&\n \ttest -n \"$pid\" &&\n-- \n1.7.5.4\n"},{"id":"173797","messageId":"1313706054-11740-5-git-send-email-vitor.hda@gmail.com","threadId":"28157","inReplyTo":"1313706054-11740-1-git-send-email-vitor.hda@gmail.com","subject":"[PATCH v2 4/4] git-p4: Add test case for copy detection.","fromName":"Vitor Antunes","fromEmail":"vitor.hda@gmail.com","sentAt":"2011-08-18T22:20:54Z","receivedAt":"2011-08-18T22:20:54Z","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 t/t9800-git-p4.sh |   71 +++++++++++++++++++++++++++++++++++++++++++++++++++++\n 1 files changed, 71 insertions(+), 0 deletions(-)\n\ndiff --git a/t/t9800-git-p4.sh b/t/t9800-git-p4.sh\nindex d01a1cb..a4f3d66 100755\n--- a/t/t9800-git-p4.sh\n+++ b/t/t9800-git-p4.sh\n@@ -319,6 +319,77 @@ test_expect_success 'detect renames' '\n \trm -rf \"$git\" && mkdir \"$git\"\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 big threshold in detectCopies and confirm\n+# that copy is not detected in P4.\n+# Modify and copy a file, configure a small threshold in detectCopies and\n+# confirm that copy is detected in P4.\n+test_expect_success 'detect copies' '\n+\tgit init \"$git\" &&\n+\tcd \"$git\" &&\n+\tcd \"$TRASH_DIRECTORY\" &&\n+\t\"$GITP4\" clone --dest=\"$git\" //depot@all &&\n+\tcd \"$git\" &&\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+\tgit config git-p4.skipSubmitEditCheck true &&\n+\t\"$GITP4\" submit &&\n+\tp4 filelog //depot/file8 &&\n+\t! p4 filelog //depot/file8 | grep -q \"branch from //depot/file\" &&\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 //depot/file\" &&\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+\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+\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+\tcp file2 file12 &&\n+\techo >> 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+\tgit config git-p4.detectCopies 98 &&\n+\t\"$GITP4\" submit &&\n+\tp4 filelog //depot/file12 &&\n+\t! p4 filelog //depot/file12 | grep -q \"branch from //depot/file\" &&\n+\tcp file2 file13 &&\n+\techo >> 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+\tgit config git-p4.detectCopies 80 &&\n+\t\"$GITP4\" submit &&\n+\tp4 filelog //depot/file13 &&\n+\tp4 filelog //depot/file13 | grep -q \"branch from //depot/file\" &&\n+\tcd \"$TRASH_DIRECTORY\" &&\n+\trm -rf \"$git\" && mkdir \"$git\"\n+'\n+\n test_expect_success 'shutdown' '\n \tpid=`pgrep -f p4d` &&\n \ttest -n \"$pid\" &&\n-- \n1.7.5.4\n"},{"id":"173812","messageId":"7vy5yq5nkb.fsf@alter.siamese.dyndns.org","threadId":"28157","inReplyTo":"1313706054-11740-2-git-send-email-vitor.hda@gmail.com","subject":"Re: [PATCH v2 1/4] git-p4: Allow setting rename/copy detection threshold.","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2011-08-18T23:04:20Z","receivedAt":"2011-08-18T23:04:20Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Vitor Antunes <vitor.hda@gmail.com> writes:\n\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> ---\n>  contrib/fast-import/git-p4 |   18 +++++++++++++-----\n>  1 files changed, 13 insertions(+), 5 deletions(-)\n>\n> diff --git a/contrib/fast-import/git-p4 b/contrib/fast-import/git-p4\n> index 6b9de9e..cf719be 100755\n> --- a/contrib/fast-import/git-p4\n> +++ b/contrib/fast-import/git-p4\n> @@ -774,15 +774,23 @@ 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> +        diffOpts = \"\"\n> +        if self.detectRenames.lower() == \"true\":\n\nThis is not a new problem you introduced with this patch, but unless you\nare invoking \"git config --bool\" in your gitConfig() (I didn't bother to\ncheck), you will misunderstand different ways to say \"Yes\", e.g.\n\n\t[git-p4]\n                detectRenames\n                detectRenames = on\n                detectRenames = yes\n                detectRenames = 1\n\nIf you use --bool, you can rely on the values being either true or false,\nand do not have to do the .lower() thing.\n"},{"id":"173814","messageId":"CAOpHH-VsoOSOH6ym2exCH=W4NmuKRw+f53HrwB47YD3u-iDe2w@mail.gmail.com","threadId":"28157","inReplyTo":"7vy5yq5nkb.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH v2 1/4] git-p4: Allow setting rename/copy detection threshold.","fromName":"Vitor Antunes","fromEmail":"vitor.hda@gmail.com","sentAt":"2011-08-18T23:43:12Z","receivedAt":"2011-08-18T23:43:12Z","isPatch":true,"sender":{"key":"vitor.hda@gmail.com","avatar":"https://avatars.githubusercontent.com/u/606876?v=4"},"body":"On Fri, Aug 19, 2011 at 12:04 AM, Junio C Hamano <gitster@pobox.com> wrote:\n> This is not a new problem you introduced with this patch, but unless you\n> are invoking \"git config --bool\" in your gitConfig() (I didn't bother to\n> check), you will misunderstand different ways to say \"Yes\", e.g.\n>\n>        [git-p4]\n>                detectRenames\n>                detectRenames = on\n>                detectRenames = yes\n>                detectRenames = 1\n>\n> If you use --bool, you can rely on the values being either true or false,\n> and do not have to do the .lower() thing.\n>\n\nNow that I look at this carefully, Tor added the possibility to add arguments to\ngitConfig() exactly for that purpose. This is helpful for processing the\ndetectCopiesHarder option I added.\n\nFor detectRenames and detectCopies it is a bit more complex. I think that if I\nuse --bool or --bool-or-int then it is possible that certain values will fail to\nbe processed. Let me give you some examples:\n\n        [git-p4]\n                detectRenames = true\n                detectRenames = 80%\n                detectRenames = 80\n                detectRenames = 1%\n                detectRenames = 1\n\nIt will be difficult for me to, for example, to understand if a 1 represents 1%\nor true. Or am I overcomplicating this? :)\n\nThanks,\n\n-- \nVitor Antunes\n"},{"id":"173850","messageId":"20110819114719.GB15639@padd.com","threadId":"28157","inReplyTo":"CAOpHH-VsoOSOH6ym2exCH=W4NmuKRw+f53HrwB47YD3u-iDe2w@mail.gmail.com","subject":"Re: [PATCH v2 1/4] git-p4: Allow setting rename/copy detection threshold.","fromName":"Pete Wyckoff","fromEmail":"pw@padd.com","sentAt":"2011-08-19T11:47:19Z","receivedAt":"2011-08-19T11:47:19Z","isPatch":true,"sender":{"key":"pw@padd.com","avatar":null},"body":"vitor.hda@gmail.com wrote on Fri, 19 Aug 2011 00:43 +0100:\n> On Fri, Aug 19, 2011 at 12:04 AM, Junio C Hamano <gitster@pobox.com> wrote:\n> > This is not a new problem you introduced with this patch, but unless you\n> > are invoking \"git config --bool\" in your gitConfig() (I didn't bother to\n> > check), you will misunderstand different ways to say \"Yes\", e.g.\n> >\n> >        [git-p4]\n> >                detectRenames\n> >                detectRenames = on\n> >                detectRenames = yes\n> >                detectRenames = 1\n> >\n> > If you use --bool, you can rely on the values being either true or false,\n> > and do not have to do the .lower() thing.\n> >\n> \n> Now that I look at this carefully, Tor added the possibility to add arguments to\n> gitConfig() exactly for that purpose. This is helpful for processing the\n> detectCopiesHarder option I added.\n> \n> For detectRenames and detectCopies it is a bit more complex. I think that if I\n> use --bool or --bool-or-int then it is possible that certain values will fail to\n> be processed. Let me give you some examples:\n> \n>         [git-p4]\n>                 detectRenames = true\n>                 detectRenames = 80%\n>                 detectRenames = 80\n>                 detectRenames = 1%\n>                 detectRenames = 1\n> \n> It will be difficult for me to, for example, to understand if a 1 represents 1%\n> or true. Or am I overcomplicating this? :)\n\nI think you have to decide that 1 means 1 in this case.\nEverything else can mean true.  That may suggest that using\n--bool or --bool-or-int isn't possible in this case.\n\n\t\t-- Pete\n"},{"id":"173858","messageId":"CAOpHH-WJWxeTSO5Dy6UR9pJh3w9hQSBuE7O1mY2KDAEsS9OAPw@mail.gmail.com","threadId":"28157","inReplyTo":"20110819114719.GB15639@padd.com","subject":"Re: [PATCH v2 1/4] git-p4: Allow setting rename/copy detection threshold.","fromName":"Vitor Antunes","fromEmail":"vitor.hda@gmail.com","sentAt":"2011-08-19T13:51:06Z","receivedAt":"2011-08-19T13:51:06Z","isPatch":true,"sender":{"key":"vitor.hda@gmail.com","avatar":"https://avatars.githubusercontent.com/u/606876?v=4"},"body":"On Fri, Aug 19, 2011 at 12:47 PM, Pete Wyckoff <pw@padd.com> wrote:\n> I think you have to decide that 1 means 1 in this case.\n> Everything else can mean true.  That may suggest that using\n> --bool or --bool-or-int isn't possible in this case.\n\nBut doing that kind of post-processing would require me to call\ngit-config (at least) twice: first to check if it is a number with a\npossible \".\" in the middle or \"%\" at the end and a second time with\nthe --bool option. I have no problem in doing this, but I think it\nincreases the complexity without bringing major advantages.\n\nI will use --bool for detectCopiesHarder and will send you the new set\nof patches tonight, unless we decide to also start using it for\ndetectCopies and detectRenames.\n\n-- \nVitor Antunes\n"},{"id":"173917","messageId":"20110820111956.GA5893@arf.padd.com","threadId":"28157","inReplyTo":"CAOpHH-WJWxeTSO5Dy6UR9pJh3w9hQSBuE7O1mY2KDAEsS9OAPw@mail.gmail.com","subject":"Re: [PATCH v2 1/4] git-p4: Allow setting rename/copy detection threshold.","fromName":"Pete Wyckoff","fromEmail":"pw@padd.com","sentAt":"2011-08-20T11:19:56Z","receivedAt":"2011-08-20T11:19:56Z","isPatch":true,"sender":{"key":"pw@padd.com","avatar":null},"body":"vitor.hda@gmail.com wrote on Fri, 19 Aug 2011 14:51 +0100:\n> On Fri, Aug 19, 2011 at 12:47 PM, Pete Wyckoff <pw@padd.com> wrote:\n> > I think you have to decide that 1 means 1 in this case.\n> > Everything else can mean true.  That may suggest that using\n> > --bool or --bool-or-int isn't possible in this case.\n> \n> But doing that kind of post-processing would require me to call\n> git-config (at least) twice: first to check if it is a number with a\n> possible \".\" in the middle or \"%\" at the end and a second time with\n> the --bool option. I have no problem in doing this, but I think it\n> increases the complexity without bringing major advantages.\n> \n> I will use --bool for detectCopiesHarder and will send you the new set\n> of patches tonight, unless we decide to also start using it for\n> detectCopies and detectRenames.\n\nI was imagining you would not use \"--bool\", and parse everything\nyourself.  But I see your point, and letting \"1\" mean \"-M1\" as\nopposed to \"-M\" is probably okay too.  I'm not particularly\nworked up about which way that goes.\n\n\t\t-- Pete\n"},{"id":"173932","messageId":"20110820190957.GA7135@arf.padd.com","threadId":"28157","inReplyTo":"1313706054-11740-1-git-send-email-vitor.hda@gmail.com","subject":"Re: [PATCH v2 0/4] Support threshold in copy/rename detection","fromName":"Pete Wyckoff","fromEmail":"pw@padd.com","sentAt":"2011-08-20T19:09:57Z","receivedAt":"2011-08-20T19:09:57Z","isPatch":true,"sender":{"key":"pw@padd.com","avatar":null},"body":"vitor.hda@gmail.com wrote on Thu, 18 Aug 2011 23:20 +0100:\n> Second version that includes updates recommended by Pete Wyckoff.\n> Now only \"true\" and \"false\" arguments are processed, any other argument\n> that is no \"\" is passed directly.\n> \n> Vitor Antunes (4):\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\nHere is a patch of review comments.  Some of these are style\nand correctness fixes.  Others are my annotations to understand\nwhat's going on in the test.  You might take the good ones and\nsend them to Junio.\n\n\t\t-- Pete\n\n-----------------------8<--------------------\n\n>From e8c627b08248bc17e8c4e6ca246099b0431a4bfb Mon Sep 17 00:00:00 2001\nFrom: Pete Wyckoff <pw@padd.com>\nDate: Sat, 20 Aug 2011 14:10:18 -0400\nSubject: [PATCH 1/4] git-p4: copy/rename test case edits\n\nSome review comments.  Take the ones in here you like.\n\nSigned-off-by: Pete Wyckoff <pw@padd.com>\n---\n t/t9800-git-p4.sh |   88 ++++++++++++++++++++++++++++++----------------------\n 1 files changed, 51 insertions(+), 37 deletions(-)\n\ndiff --git a/t/t9800-git-p4.sh b/t/t9800-git-p4.sh\nindex 2a872bc..bbf1485 100755\n--- a/t/t9800-git-p4.sh\n+++ b/t/t9800-git-p4.sh\n@@ -272,24 +272,22 @@ test_expect_success 'initial import time from top change time' '\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 blank line, configure a big\n-# threshold in detectRenames and confirm that rename is not detected in P4.\n-# Rename the new file again adding another extra blank line, configure a small\n+# Rename the new file again adding an extra line, configure a big\n # threshold in detectRenames and confirm that rename is not detected in P4.\n+# Repeat, this time with a smaller threshold.\n test_expect_success 'detect renames' '\n-\tgit init \"$git\" &&\n-\tcd \"$git\" &&\n-\tcd \"$TRASH_DIRECTORY\" &&\n \t\"$GITP4\" clone --dest=\"$git\" //depot@all &&\n-\tp4 files //depot/* &&\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-\tgit config git-p4.skipSubmitEditCheck true &&\n \t\"$GITP4\" submit &&\n \tp4 filelog //depot/file4 &&\n \t! p4 filelog //depot/file4 | grep -q \"branch from //depot/file1\" &&\n+\n \tgit mv file4 file5 &&\n \tgit commit -a -m \"Rename file4 to file5\" &&\n \tgit diff-tree -r -M HEAD &&\n@@ -297,26 +295,30 @@ test_expect_success 'detect renames' '\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+\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-\tgit config git-p4.detectRenames 95 &&\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 //depot/file5\" &&\n+\n \tgit mv file6 file7 &&\n-\techo update >> 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-\tgit config git-p4.detectRenames 80 &&\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-\tcd \"$TRASH_DIRECTORY\" &&\n-\trm -rf \"$git\" && mkdir \"$git\"\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@@ -326,68 +328,80 @@ test_expect_success 'detect renames' '\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 big threshold in detectCopies and confirm\n-# that copy is not detected in P4.\n-# Modify and copy a file, configure a small threshold in detectCopies and\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-\tgit init \"$git\" &&\n-\tcd \"$git\" &&\n-\tcd \"$TRASH_DIRECTORY\" &&\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-\tgit config git-p4.skipSubmitEditCheck true &&\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 //depot/file\" &&\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 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 //depot/file\" &&\n-\techo file2 >> file2 &&\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+\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+\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 >> 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-\tgit config git-p4.detectCopies 98 &&\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 //depot/file\" &&\n+\n \tcp file2 file13 &&\n-\techo >> 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-\tgit config git-p4.detectCopies 80 &&\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-\tcd \"$TRASH_DIRECTORY\" &&\n-\trm -rf \"$git\" && mkdir \"$git\"\n+\tp4 filelog //depot/file13 | grep -q \"branch from //depot/file\"\n '\n \n # Create a simple branch structure in P4 depot to check if it is correctly\n-- \n1.7.5.4\n"},{"id":"173981","messageId":"20110822010922.3b5b573f@fenix.utopia.dhis.org","threadId":"28157","inReplyTo":"20110820111956.GA5893@arf.padd.com","subject":"Re: [PATCH v2 1/4] git-p4: Allow setting rename/copy detection threshold.","fromName":"Vitor Antunes","fromEmail":"vitor.hda@gmail.com","sentAt":"2011-08-22T00:09:22Z","receivedAt":"2011-08-22T00:09:22Z","isPatch":true,"sender":{"key":"vitor.hda@gmail.com","avatar":"https://avatars.githubusercontent.com/u/606876?v=4"},"body":"On Sat, 20 Aug 2011 07:19:56 -0400\nPete Wyckoff <pw@padd.com> wrote:\n\n> I was imagining you would not use \"--bool\", and parse everything\n> yourself.  But I see your point, and letting \"1\" mean \"-M1\" as\n> opposed to \"-M\" is probably okay too.  I'm not particularly\n> worked up about which way that goes.\n\nI decided to only add --bool to detectCopiesHarder, at least for now.\nWill send a new set of patches shortly.\n\n-- \nVitor Antunes\n"}]}