feat(git): add --rename-threshold option to DiffviewOpen and DiffviewFileHistory (#301) - #304
Merged
Merged
Conversation
…fviewFileHistory` (#301)
There was a problem hiding this comment.
Pull request overview
This PR adds a --rename-threshold={n} CLI option to :DiffviewOpen and :DiffviewFileHistory, letting users override the global rename_threshold config on a per-view basis for git's rename detection (-M<n>%). I traced the full data flow end-to-end for both entry points and it is wired correctly and backward compatible (the new value always falls back to the global config when absent).
Changes:
- Adds
parse_rename_threshold_flag(git adapter) that validates the flag via the sharedconfig.validate.integerhelper (accepts40/40%, range 0–100, warns and falls back on invalid input), wires it intodiffview_options/file_history_options, and threads it throughtracked_filesandstream_fh_data; registers completion. - Forwards the value per-view via
DiffViewOptions.rename_threshold→LayoutOpt.rename_threshold→tracked_files, and viaGitLogOptions.rename_threshold→ file-history stream. - Emits a warning for Jujutsu (unsupported), exports
config.validate, and documents the option; adds functional tests.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
lua/diffview/vcs/adapters/git/init.lua |
Parses/validates the flag and applies -M<n>% in file-listing and history paths; adds completion. |
lua/diffview/vcs/utils.lua |
Forwards dv_opt.rename_threshold into the per-view opt for tracked_files. |
lua/diffview/vcs/adapter.lua |
Adds rename_threshold to LayoutOpt type. |
lua/diffview/scene/views/diff/diff_view.lua |
Adds rename_threshold to DiffViewOptions type. |
lua/diffview/config.lua |
Adds rename_threshold to git log-option schema/defaults; exports validate. |
lua/diffview/vcs/adapters/jj/init.lua |
Warns that the option is unsupported for Jujutsu. |
lua/diffview/tests/functional/git_adapter_spec.lua |
Tests parsing for open and file-history options. |
doc/diffview.txt |
Documents the new option for both commands. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #301.