Skip to content

feat(config): add rename_threshold for git rename detection#9

Merged
dlyongemallo merged 1 commit intomainfrom
feat_rename_threshold
Feb 6, 2026
Merged

feat(config): add rename_threshold for git rename detection#9
dlyongemallo merged 1 commit intomainfrom
feat_rename_threshold

Conversation

@dlyongemallo
Copy link
Owner

No description provided.

Copilot AI review requested due to automatic review settings February 6, 2026 16:07
@dlyongemallo dlyongemallo merged commit c5b9200 into main Feb 6, 2026
4 checks passed
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_threshold config option with default value of nil (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%).
Copy link

Copilot AI Feb 6, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
Comment on lines +579 to +582
(function()
local t = config.get_config().rename_threshold
return t and ("-M" .. t .. "%") or nil
end)(),
Copy link

Copilot AI Feb 6, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
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%).
Copy link

Copilot AI Feb 6, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
@dlyongemallo dlyongemallo deleted the feat_rename_threshold branch February 9, 2026 07:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants