Incorrect behaviour of plugin.bitbucket-git.diff.renames.threshold

XMLWordPrintable

    • Severity 3 - Minor
    • 0

      Issue Summary

      The documentation for plugin.bitbucket-git.diff.renames.threshold says:

      # Defines the threshold, as a percentage, for a file to be detected as a rename or a copy. This setting is only applied
      # if copy and/or rename detection is enabled. The default threshold applied is 50% similarity (defined in git itself).
      #
      # git diff and git diff-tree _do not honor_ 100 (identical files only) for the threshold. They ignore the threshold and
      # apply the default 50% threshold instead. A configured threshold of 100 will be applied as 99. Similarly, a configured
      # threshold that is 0, or negative, will be applied as 1.
      # This configuration can also be applied at repository level with `plugin.bitbucket-git.diff.renames.threshold.KEY.slug`
      # or at project level with `plugin.bitbucket-git.diff.renames.threshold.KEY`
      #plugin.bitbucket-git.diff.renames.threshold=50
      

      And this is passed to git diff --find-renames as a number, not a percentage. The documentation for git diff says:

      Detect renames. If n is specified, it is a threshold on the similarity index (i.e. amount of addition/deletions compared to the file’s size). For example, -M90% means Git should consider a delete/add pair to be a rename if more than 90% of the file hasn’t changed. Without a % sign, the number is to be read as a fraction, with a decimal point before it. I.e., -M5 becomes 0.5, and is thus the same as -M50%. Similarly, -M05 is the same as -M5%. To limit detection to exact renames, use -M100%. The default similarity index is 50%.

      This means that the default setting, 50 is fine because it is treated as 0.5 or 50%. However for a value of 1 instead of being treated as 1% it is treated as 0.1 or 10%. And 9 is treated as 90% instead of 9%, etc.

              Assignee:
              Ben Humphreys
              Reporter:
              Ben Humphreys
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

                Created:
                Updated:
                Resolved: