Skip to content

Commit ea5a749

Browse files
committed
fix(git): Bad file existence assertion in file_restore() (fixes sindrets#381)
Problem: The method incorrectly asserts that the given file didn't exist in history. Solution: Actually use the provided commit SHA to make the correct assertion.
1 parent c915504 commit ea5a749

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

lua/diffview/vcs/adapters/git/init.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1360,7 +1360,7 @@ GitAdapter.file_restore = async.wrap(function(self, path, kind, commit, callback
13601360

13611361
-- Check if file exists in history
13621362
_, code = self:exec_sync(
1363-
{ "cat-file", "-e", fmt("%s:%s", kind == "staged" and "HEAD" or "", path) },
1363+
{ "cat-file", "-e", fmt("%s:%s", commit or (kind == "staged" and "HEAD") or "", path) },
13641364
self.ctx.toplevel
13651365
)
13661366
local exists_git = code == 0

0 commit comments

Comments
 (0)