Skip to content

Customizing similarity index for renamed files #559

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
jakubbortlik opened this issue Mar 7, 2025 · 0 comments
Open

Customizing similarity index for renamed files #559

jakubbortlik opened this issue Mar 7, 2025 · 0 comments

Comments

@jakubbortlik
Copy link

In gitlab.nvim we are using diffview.nvim as the "reviewer" for Gitlab merge requests. I've noticed that Gitlab must be using a non-default threshold for similarity index for finding renames (git docs), I've got a file that was renamed and modified and Gitlab shows it as such, while Diffview shows the original file as deleted and a new file added. This is because the similarity index for the given file was 41, so I'm able to force Diffview into the same behaviour as Gitlab with this modification:

diff --git a/lua/diffview/vcs/adapters/git/init.lua b/lua/diffview/vcs/adapters/git/init.lua
index 3a137bc..65ff4a3 100644
--- a/lua/diffview/vcs/adapters/git/init.lua
+++ b/lua/diffview/vcs/adapters/git/init.lua
@@ -1707,6 +1707,7 @@ GitAdapter.tracked_files = async.wrap(function(self, left, right, args, kind, op
       "-c",
       "core.quotePath=false",
       "diff",
+      "-M40%",
       "--ignore-submodules",
       "--name-status",
       args
@@ -1721,6 +1722,7 @@ GitAdapter.tracked_files = async.wrap(function(self, left, right, args, kind, op
       "-c",
       "core.quotePath=false",
       "diff",
+      "-M40%",
       "--ignore-submodules",
       "--numstat",
       args

It would be nice if this option to Git would be configurable in Diffview, so that we could make gitlab.nvim behave as close to Gitlab as possible.

Note: There's already the possibility to configure the git_cmd in Diffview, but obviously, this cannot be set to something like git_cmd = {"git", "-M40%"}, because the -M40% option only makes sense for the diff subcommand.

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

No branches or pull requests

1 participant