git-p4: Allow setting rename/copy detection threshold

Copy and rename detection arguments (-C and -M) allow setting a threshold value for the similarity ratio. If the similarity is below this threshold the rename or copy is ignored and the file is added as new. This patch allows setting git-p4.detectRenames and git-p4.detectCopies options to an integer value to set the respective threshold. Signed-off-by: Vitor Antunes <vitor.hda@gmail.com> Acked-by: Pete Wyckoff <pw@padd.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Vitor Antunes committed Aug 22, 2011 at 09:33 UTC 0a9feffc47b19b81aba7ee5a93473b4c91f44ea9
1 file changed +9 -4
contrib/fast-import/git-p4
+9 -4
@@ -774,15 +774,20 @@ class P4Submit(Command, P4UserMap):
774
775 if not self.detectRenames:
776 # If not explicitly set check the config variable
777 - self.detectRenames = gitConfig("git-p4.detectRenames").lower() == "true"
777 + self.detectRenames = gitConfig("git-p4.detectRenames")
778
779 - if self.detectRenames:
779 + if self.detectRenames.lower() == "false" or self.detectRenames == "":
780 + diffOpts = ""
781 + elif self.detectRenames.lower() == "true":
782 diffOpts = "-M"
783 else:
782 - diffOpts = ""
784 + diffOpts = "-M%s" % self.detectRenames
785
784 - if gitConfig("git-p4.detectCopies").lower() == "true":
786 + detectCopies = gitConfig("git-p4.detectCopies")
787 + if detectCopies.lower() == "true":
788 diffOpts += " -C"
789 + elif detectCopies != "" and detectCopies.lower() != "false":
790 + diffOpts += " -C%s" % detectCopies
791
792 if gitConfig("git-p4.detectCopiesHarder").lower() == "true":
793 diffOpts += " --find-copies-harder"