neogit
neogit copied to clipboard
staging is not 100% robust
Description
It's a bit of an unusual use-case, but I've been tracking diffs in source control, and staging them bit by bit. This works fine in emacs magit, but I think neogit's hunk parsing is getting confused by the hunks in the git operation itself and the hunks in the diff that we are source controlling and which are unrelated.
Neovim version
NVIM v0.5.1 Build type: RelWithDebInfo LuaJIT 2.1.0-beta3
Operating system and version
fedora 34
Steps to reproduce
first version, s.diff
diff --git a/lua/neogit/buffers/common.lua b/lua/neogit/buffers/common.lua
index 504ed37..cfa8a2d 100644
--- a/lua/neogit/buffers/common.lua
+++ b/lua/neogit/buffers/common.lua
@@ -22,6 +22,7 @@ M.Diff = Component.new(function(diff)
local content = map(range(hunk.diff_from + 1, hunk.diff_to), function(i)
return diff.lines[i]
end)
+ -- test
return {
header = header,
second version, s2.diff
diff --git a/lua/neogit/buffers/common.lua b/lua/neogit/buffers/common.lua
index 504ed37..96bc74f 100644
--- a/lua/neogit/buffers/common.lua
+++ b/lua/neogit/buffers/common.lua
@@ -10,6 +10,7 @@ local filter = util.filter
local intersperse = util.intersperse
local range = util.range
+-- test3
local M = {}
local diff_add_matcher = vim.regex('^+')
@@ -31,6 +32,7 @@ M.Diff = Component.new(function(diff)
return col.tag("Diff") {
text(diff.kind .. " " .. diff.file),
+ -- test2
col.tag("HunkList")(map(hunk_props, M.Hunk))
}
end)
We want to track these files in source control.
If you save both these files on disk, as /tmp/s.diff and /tmp/s2.diff, then do...
git init
cp /tmp/s.diff s.diff
git add s.diff
git commit -m "first version"
cp /tmp/s2.diff s.diff
nvim -nu minimal.lua
:Neogit
Then in neogit go over Unstaged changes->Modified s.diff, press tab, go over the line that says "--- add/lua/neogit..." then press s
to stage the hunk.
Expected behavior
The hunk gets staged. Doing the same thing in magit in emacs stages without problem.
Actual behavior
Neogit displays Git error (128)
.
Minimal config
vim.cmd([[set runtimepath=$VIMRUNTIME]])
vim.cmd([[set packpath=/tmp/nvim/site]])
local package_root = "/tmp/nvim/site/pack"
local install_path = package_root .. "/packer/start/packer.nvim"
local function load_plugins()
require("packer").startup({
{
"wbthomason/packer.nvim",
{
"TimUntersberger/neogit",
requires = {
{ "nvim-lua/plenary.nvim" },
{ "sindrets/diffview.nvim" },
},
config = function()
print("loaded neogit")
require("neogit").setup()
end,
},
},
config = {
package_root = package_root,
compile_path = install_path .. "/plugin/packer_compiled.lua",
display = { non_interactive = true },
},
})
end
if vim.fn.isdirectory(install_path) == 0 then
print("Installing neogit and dependencies.")
vim.fn.system({ "git", "clone", "--depth=1", "https://github.com/wbthomason/packer.nvim", install_path })
end
load_plugins()
require("packer").sync()
I also use fine grained staging bit by bit and magit
indeed is very very useful for this.
Do you mean line wise staging? You can visually (v-line, press capital V) select some limited within junk and stage them with s
.