sindrets / diffview.nvim

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

GitAdapter:get_merge_context assert fails if conflict is from git stash apply #331

Closed gotgenes closed 1 year ago

gotgenes commented 1 year ago

The assert(their_head) in GitAdapter:get_merge_context will fail with the following error when running :DiffviewOpen on a file with conflict markers created via a git stash apply:

Error executing vim.schedule lua callback: ...share/nvim/lazy/plenary.nvim/lua/plenary/async/async.lua:18: The coroutine failed with this message: ...azy/diffview.nvim/lua/diffview/vcs/adapters/git/init.lua:294: assertion failed!
stack traceback:
        [C]: in function 'error'
        ...share/nvim/lazy/plenary.nvim/lua/plenary/async/async.lua:18: in function 'callback_or_next'
        ...share/nvim/lazy/plenary.nvim/lua/plenary/async/async.lua:45: in function <...share/nvim/lazy/plenary.nvim/lua/plenary/async/async.lua:44>

Steps to reproduce:

  1. Create some change on a line of a file tracked by Git and use git stash to stash the change.
  2. Create a different change on the same line of the same file, and commit the change.
  3. Run git stash apply to get a conflict, with conflict markers applied to the working copy of the file.
  4. Open the file in Neovim.
  5. Run :DiffviewOpen.