Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't stage a hunk from file up a dir from PWD #442

Closed
mangelozzi opened this issue Feb 3, 2023 · 1 comment · Fixed by #963
Closed

Can't stage a hunk from file up a dir from PWD #442

mangelozzi opened this issue Feb 3, 2023 · 1 comment · Fixed by #963
Labels
bug Something isn't working

Comments

@mangelozzi
Copy link

mangelozzi commented Feb 3, 2023

Description

I have a project structure that looks like this (these dirs all exist in the git project):

config/
info/
install/
scripts/
src/
   |---dir1/
   |---dir2/

I generally have the PWD of VIM set to src/ for python linting and thats the dir the project starts up in.
When I review a file say in the config/ dir, and try to stage hunk it with Neogit, it shows an error message (image below). One can stage the whole file succesfully though, just not the hunk

Neovim version

NVIM v0.8.2
Build type: Release
LuaJIT 2.1.0-beta3
Compiled by runner@fv-az190-151

Operating system and version

Ubuntu 22.04

Steps to reproduce

  1. Open a git project
  2. make a change in a file higher up in the project structure
  3. CD into a lower dir
  4. Try stage the file in the higher up dir.

Expected behavior

The hunk to be staged

Actual behavior

The following error message:
image

The file is actually ../README.md, and not src/../README.md. Which it gets right if one stages the whole file.

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()
@mangelozzi mangelozzi added the bug Something isn't working label Feb 3, 2023
@dusty-phillips
Copy link

dusty-phillips commented Jul 25, 2023

This is happening for me on MacOS in a monorepo setup as well. My workaround is to stage individual hunks directly from the buffer using the git-signs plugin.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants