sindrets / diffview.nvim

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

[Bug] coroutine failed when diffviewing on rebase #454

Closed LamprosPitsillos closed 6 months ago

LamprosPitsillos commented 6 months ago

Description

I have branch A and Master I checkout to branch A and git rebase master Open neovim ( works with minimal config ) and open DiffviewOpen Get the below error.

Expected behavior

Open the Diffview so that i can solve the conflicts

Actual behavior

Error executing vim.schedule lua callback: ...cal/share/nvim/lazy/diffview.nvim/lua/diffview/async.lua:187: The coroutine failed with this message:
        context: cur_thread=main co_thread=<thread 0x7f4a6c5d4ed0> co_func=...iffview.nvim/lua/diffview/scene/views/diff/diff_view.lua:327
...azy/diffview.nvim/lua/diffview/vcs/adapters/git/init.lua:329: assertion failed!
stack traceback:
        [C]: in function 'assert'
        ...azy/diffview.nvim/lua/diffview/vcs/adapters/git/init.lua:329: in function 'get_merge_context'
        ...iffview.nvim/lua/diffview/scene/views/diff/diff_view.lua:445: in function 'func'
        ...cal/share/nvim/lazy/diffview.nvim/lua/diffview/async.lua:373: in function <...cal/share/nvim/lazy/diffview.nvim/lua/diffview/async.lua:358>
stack traceback:
        [C]: in function 'error'
        ...cal/share/nvim/lazy/diffview.nvim/lua/diffview/async.lua:187: in function 'raise'
        ...cal/share/nvim/lazy/diffview.nvim/lua/diffview/async.lua:215: in function 'step'
        ...cal/share/nvim/lazy/diffview.nvim/lua/diffview/async.lua:247: in function 'notify_all'
        ...cal/share/nvim/lazy/diffview.nvim/lua/diffview/async.lua:222: in function 'step'
        ...cal/share/nvim/lazy/diffview.nvim/lua/diffview/async.lua:399: in function <...cal/share/nvim/lazy/diffview.nvim/lua/diffview/async.lua:391>

Steps to reproduce

  1. git clone git@github.com:LamprosPitsillos/neovim.git --depth 1
  2. git fetch origin ve_buf_set_text:ve_buf_set_text --depth=1
  3. git switch ve_buf_set_text
  4. git rebase master
  5. nvim --clean -u mini.lua
  6. :DiffviewOpen

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.42.0) - WARNING Configured `hg_cmd` is not executable: 'hg' ```

Log info

Relevant info from :DiffviewLog ``` [INFO 2024-01-09 11:14:52.645 +0200] ...local/share/nvim/lazy/diffview.nvim/lua/diffview/lib.lua:24: [command call] :DiffviewOpen [ERROR 2024-01-09 11:14:53.914 +0200] ...local/share/nvim/lazy/diffview.nvim/lua/diffview/job.lua:329: Job exited with a non-zero exit code: 1 [ERROR 2024-01-09 11:14:53.914 +0200] ...azy/diffview.nvim/lua/diffview/vcs/adapters/git/init.lua:328: [job-info] Exit code: 1 [ERROR 2024-01-09 11:14:53.914 +0200] ...azy/diffview.nvim/lua/diffview/vcs/adapters/git/init.lua:328: [cmd] git 'merge-base' 'HEAD' 'REBASE_HEAD' [ERROR 2024-01-09 11:14:53.914 +0200] ...azy/diffview.nvim/lua/diffview/vcs/adapters/git/init.lua:328: [cwd] /home/inferno/docs/Programming/NEOVIM/neovim ```

Neovim version

❯ nv --version
NVIM v0.10.0-dev-bdfea2a
Build type: Release
LuaJIT 2.1.1693350652
Run "nvim -V1 -v" for more info

Operating system and version

OS: NixOS 24.05.20240102.bd645e8 (Uakari) 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 6 months ago

Why does git merge-base HEAD REBASE_HEAD fail in your repo? Are HEAD and REBASE_HEAD unrelated histories?

LamprosPitsillos commented 6 months ago

Why does git merge-base HEAD REBASE_HEAD fail in your repo? Are HEAD and REBASE_HEAD unrelated histories?

From what i understand they shouldn't , branch master

sindrets commented 6 months ago

Works fine on my end using the branches and reproduction steps you provided.

Are you able to reproduce the error on your own system, or was the error a one time thing?

LamprosPitsillos commented 6 months ago

Manages to reproduce the issue everytime

sindrets commented 6 months ago

--depth=1 there's your problem.

You should never merge or rebase branches when you don't give Git enough history to work out the merge base. You will get ridiculous conflicts (as you do here). With sufficient history your example rebase introduces only one conflict. With --depth=1 you get >1000.

I understand the desire to use --depth in order to reduce size on the FS. However, to correctly do a merge/rebase you should make sure that the two branches have all history dating back to at least the merge base. You can use i.e. --shallow-since='1 year' with both git-fetch and git-clone.

LamprosPitsillos commented 6 months ago

Thank you very much for the insights on git and your time on this issue, properly cloning did solve the issue (along with many other issues i had) ! Thank you also for this amazing plugin, closing the issue