feat(config): add rename_threshold for git rename detection#9
feat(config): add rename_threshold for git rename detection#9dlyongemallo merged 1 commit intomainfrom
Conversation
There was a problem hiding this comment.
Pull request overview
This pull request adds a new configuration option rename_threshold to customize git's rename detection sensitivity. The feature allows users to control the similarity threshold (as a percentage) that git uses when detecting file renames during diff and log operations.
Changes:
- Added
rename_thresholdconfig option with default value ofnil(uses git's default of 50%) - Integrated the rename flag (
-M<n>%) into git log commands for file history operations - Applied the rename flag to git diff commands for tracking file changes
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| lua/diffview/config.lua | Added rename_threshold config field with inline documentation |
| lua/diffview/vcs/adapters/git/init.lua | Integrated rename threshold into git log and diff commands at three locations |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| enhanced_diff_hl = false, | ||
| git_cmd = { "git" }, | ||
| hg_cmd = { "hg" }, | ||
| rename_threshold = nil, -- Similarity threshold for rename detection (e.g. 40 for 40%). Nil uses git default (50%). |
There was a problem hiding this comment.
Add a type annotation for the rename_threshold field in the DiffviewConfig class definition. Following the pattern in this file, add a comment like ---@field rename_threshold? number before the M.defaults table to document that this field is optional and should be a number.
| (function() | ||
| local t = config.get_config().rename_threshold | ||
| return t and ("-M" .. t .. "%") or nil | ||
| end)(), |
There was a problem hiding this comment.
The inline function pattern here is inconsistent with the approach used in tracked_files function (lines 1837-1838) where the same logic is extracted to local variables. For consistency and readability, consider extracting this to local variables before the Job construction, similar to the pattern used in tracked_files.
| enhanced_diff_hl = false, | ||
| git_cmd = { "git" }, | ||
| hg_cmd = { "hg" }, | ||
| rename_threshold = nil, -- Similarity threshold for rename detection (e.g. 40 for 40%). Nil uses git default (50%). |
There was a problem hiding this comment.
The rename_threshold field lacks input validation. Invalid values (negative numbers, values > 100, or non-numeric types) could be passed by users and would result in malformed git commands. Consider adding validation in the M.setup function to ensure the value is either nil or a number between 0 and 100, similar to how layout values are validated.
No description provided.