sindrets / diffview.nvim

Single tabpage interface for easily cycling through diffs for all modified files for any git rev.
Other
3.6k stars 101 forks source link

[Bug] Broken :DiffviewFileHistory % on macOS #379

Closed tdjordan closed 1 year ago

tdjordan commented 1 year ago

Description

After the following fix(path): Windows path madness (fixes #372) was applied, the :DiffviewFileHistory % no longer displays the file history for the opened file buffer.

I believe it might be around this code location

Expected behavior

A file history layout is displayed showing the file history of the opened file.

Actual behavior

Screen Shot 2023-06-09 at 12 58 56 Screen Shot 2023-06-09 at 12 58 36

Steps to reproduce

mkdir /tmp/diff.bug
cd /tmp/diff.bug
echo "This is just some history." > README.md
git add .
echo "Second line" >> README.md
nvim README.md

In nvim, :DiffviewFileHistory %

Health check

Output of :checkhealth diffview ``` diffview: require("diffview.health").check() Checking plugin dependencies - OK nvim-web-devicons installed. Checking VCS tools - The plugin requires at least one of the supported VCS tools to be valid. - OK Git found. - OK Git is up-to-date. (2.41.0) - WARNING Configured `hg_cmd` is not executable: 'hg' ```

Log info

Relevant info from :DiffviewLog ``` [INFO 2023-06-09 13:11:15.497 -0500] ...local/share/nvim/lazy/diffview.nvim/lua/diffview/lib.lua:74: [command call] :DiffviewFileHistory % [ERROR 2023-06-09 13:11:15.554 -0500] ...local/share/nvim/lazy/diffview.nvim/lua/diffview/job.lua:327: Job exited with a non-zero exit code: 128 [ERROR 2023-06-09 13:11:15.554 -0500] ...azy/diffview.nvim/lua/diffview/vcs/adapters/git/init.lua:672: [job-info] Exit code: 128 [ERROR 2023-06-09 13:11:15.554 -0500] ...azy/diffview.nvim/lua/diffview/vcs/adapters/git/init.lua:672: [cmd] git 'ls-files' '--' '/README.md' [ERROR 2023-06-09 13:11:15.554 -0500] ...azy/diffview.nvim/lua/diffview/vcs/adapters/git/init.lua:672: [cwd] /private/tmp/diff.bug [ERROR 2023-06-09 13:11:15.554 -0500] ...azy/diffview.nvim/lua/diffview/vcs/adapters/git/init.lua:672: [stderr] fatal: /README.md: '/README.md' is outside repository at '/private/tmp/diff.b ug' [ERROR 2023-06-09 13:11:15.574 -0500] ...local/share/nvim/lazy/diffview.nvim/lua/diffview/job.lua:327: Job exited with a non-zero exit code: 128 [ERROR 2023-06-09 13:11:15.574 -0500] ...azy/diffview.nvim/lua/diffview/vcs/adapters/git/init.lua:709: [job-info] Exit code: 128 [ERROR 2023-06-09 13:11:15.574 -0500] ...azy/diffview.nvim/lua/diffview/vcs/adapters/git/init.lua:709: [cmd] git 'log' '--pretty=format:%H' '--name-status' '-n1' '--diff-merges=combined' '--' '/README.md' [ERROR 2023-06-09 13:11:15.574 -0500] ...azy/diffview.nvim/lua/diffview/vcs/adapters/git/init.lua:709: [cwd] /private/tmp/diff.bug [ERROR 2023-06-09 13:11:15.574 -0500] ...azy/diffview.nvim/lua/diffview/vcs/adapters/git/init.lua:709: [stderr] fatal: /README.md: '/README.md' is outside repository at '/private/tmp/diff.b ug' ```

Neovim version

NVIM v0.9.1
Build type: Release
LuaJIT 2.1.0-beta3

   system vimrc file: "$VIM/sysinit.vim"
  fall-back for $VIM: "/usr/local/Cellar/neovim/0.9.1/share/nvim"

Operating system and version

Darwin 21.6.0 x86_64

Minimal config

-- #######################################
-- ### USAGE: nvim --clean -u mini.lua ###
-- #######################################

local root = vim.fn.stdpath("run") .. "/nvim/diffview.nvim"
vim.fn.mkdir(root, "p")

-- set stdpaths to use root
for _, name in ipairs({ "config", "data", "state", "cache" }) do
  vim.env[("XDG_%s_HOME"):format(name:upper())] = root .. "/" .. name
end

-- bootstrap lazy
local lazypath = root .. "/plugins/lazy.nvim"
if not vim.loop.fs_stat(lazypath) then
  vim.fn.system({ "git", "clone", "--filter=blob:none", "https://github.com/folke/lazy.nvim.git", lazypath, })
end
vim.opt.runtimepath:prepend(lazypath)

-- install plugins
local plugins = {
  {
    "sindrets/diffview.nvim",
    dependencies = { "nvim-tree/nvim-web-devicons" },
    config = function()
      require("diffview").setup({
        -- ##############################################################################
        -- ### ADD DIFFVIEW.NVIM CONFIG THAT IS _NECESSARY_ FOR REPRODUCING THE ISSUE ###
        -- ##############################################################################
      })
    end,
  },
  -- ##################################################################
  -- ### ADD PLUGINS THAT ARE _NECESSARY_ FOR REPRODUCING THE ISSUE ###
  -- ##################################################################
}
require("lazy").setup(plugins, { root = root .. "/plugins" })
require("lazy").sync({ show = false, wait = true })

vim.opt.termguicolors = true
vim.cmd("colorscheme " .. (vim.fn.has("nvim-0.8") == 1 and "habamax" or "slate"))

-- ############################################################################
-- ### ADD INIT.LUA SETTINGS THAT ARE _NECESSARY_ FOR REPRODUCING THE ISSUE ###
-- ############################################################################
sindrets commented 1 year ago

Thanks for the report.