Skip to content
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

Git show is empty if cwd is not the repository root #361

Closed
notEvil opened this issue Jun 6, 2024 · 0 comments · Fixed by #362
Closed

Git show is empty if cwd is not the repository root #361

notEvil opened this issue Jun 6, 2024 · 0 comments · Fixed by #362
Labels
bug Something isn't working

Comments

@notEvil
Copy link

notEvil commented Jun 6, 2024

Description

When cwd is not the repository root, buffer_history_preview shows the list of commits but no diffs. The reason is that git show isn't called correctly in this case. The following change fixes the issue with buffer_history_preview for me:

diff --git a/lua/vgit/git/cli/Git.lua b/lua/vgit/git/cli/Git.lua
index d3df46d..2638f07 100644
--- a/lua/vgit/git/cli/Git.lua
+++ b/lua/vgit/git/cli/Git.lua
@@ -634,7 +634,7 @@ Git.show = loop.suspend(function(self, tracked_filename, commit_hash, spec, call
       '-C',
       self.cwd,
       'show',
-      string.format('%s:%s%s', commit_hash, self.cwd, tracked_filename),
+      string.format('%s:./%s', commit_hash, tracked_filename),
     }),
     on_stdout = function(line) result[#result + 1] = line end,
     on_stderr = function(line) err[#err + 1] = line end,
@@ -658,7 +658,7 @@ Git.is_in_remote = loop.suspend(function(self, tracked_filename, commit_hash, sp
       '-C',
       self.cwd,
       'show',
-      string.format('%s:%s%s', commit_hash, self.cwd, tracked_filename),
+      string.format('%s:./%s', commit_hash, tracked_filename),
     }),
     on_stderr = function(line)
       if line then
  • nvim --version output:

NVIM v0.10.0
Build type: Release
LuaJIT 2.1.1716656478
Run "nvim -V1 -v" for more info

  • Operating system:

Arch Linux

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
1 participant