Skip to content

Commit 0a9feff

Browse files
vhdagitster
authored andcommitted
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 <[email protected]> Acked-by: Pete Wyckoff <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 4e2e6ce commit 0a9feff

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

contrib/fast-import/git-p4

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -774,15 +774,20 @@ class P4Submit(Command, P4UserMap):
774774

775775
if not self.detectRenames:
776776
# If not explicitly set check the config variable
777-
self.detectRenames = gitConfig("git-p4.detectRenames").lower() == "true"
777+
self.detectRenames = gitConfig("git-p4.detectRenames")
778778

779-
if self.detectRenames:
779+
if self.detectRenames.lower() == "false" or self.detectRenames == "":
780+
diffOpts = ""
781+
elif self.detectRenames.lower() == "true":
780782
diffOpts = "-M"
781783
else:
782-
diffOpts = ""
784+
diffOpts = "-M%s" % self.detectRenames
783785

784-
if gitConfig("git-p4.detectCopies").lower() == "true":
786+
detectCopies = gitConfig("git-p4.detectCopies")
787+
if detectCopies.lower() == "true":
785788
diffOpts += " -C"
789+
elif detectCopies != "" and detectCopies.lower() != "false":
790+
diffOpts += " -C%s" % detectCopies
786791

787792
if gitConfig("git-p4.detectCopiesHarder").lower() == "true":
788793
diffOpts += " --find-copies-harder"

0 commit comments

Comments
 (0)