-
-
Notifications
You must be signed in to change notification settings - Fork 190
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
Support for detached work trees #397
Comments
I don't think customizing arguments passed to git is the way to go. Gitsigns works quite differently to gitgutter and issues several git commands, one of them is to determine the gitdir which is then use for all subsequent git commands. We just need to improve that to accommodate what is essentially "detached gitdirs". Proposal 1Modify local home = vim.fn.expand('$HOME')
require('gitsigns').setup{
...
on_attach = function()
if vim.fn.getcwd() == home then
return {
gitdir = home..'/.cfg'
}
end
end
} Proposal 2Add local home = vim.fn.expand('$HOME')
require('gitsigns').setup{
...
detached_trees = {
-- working tree -> gitdir
[home] = home..'/.cfg'
}
} Personally I think proposal 2 is the way to go, but we may end up doing proposal 1 if we ever need to prepopulate other fields. |
Both proposals seem reasonable to me. -- working tree -> { gitdir, otherFields }
[home] = { gitdir = home..'/.cfg' , possiblefield = '' , ... } I'm fairly new to Lua so excuse me if this is a dumb question... |
Yes we could do that. What kind of fields could we possibly have? Also, it is possible to support both in a polymorphic way. With that said I like the specific |
I don't have anything specific on mind regarding other fields. |
Ok sure, we can go with that then. |
Hi, I too manage my dotfiles with a bare git repository and was looking to implement this with gitsigns.
I first check if git finds a git repository on it's own and if not, I set the enviroment variables. These variables get later used when gitsigns spawns it's git subprocesses. (I haven't tried if we can change the enviroment variables after setting up gitsigns, but this way is probably safer.) I used the "old" neovim job controll feature, instead of the "newer" event loop, since it is easier to work with in this case. (Mainly because the event loop doesn't have a On another note: if you still want to implement a feature to do this, I think your first proposal would be preferable. This is because, the second proposal would not work with subdirectories. (E.g. when I edit a file like Anyway, I hope my workaround is helpful to you all! |
Thanks this is really useful to know. |
Added config.worktrees. Array of tables with the keys 'gitdir' and 'toplevel'. If attaching normally fails, then each entry in the table is attempted. Example: worktrees = { { toplevel = vim.env.HOME, gitdir = vim.env.HOME .. '/projects/dotfiles/.git' } } Resolves #397
Added config.worktrees. Array of tables with the keys 'gitdir' and 'toplevel'. If attaching normally fails, then each entry in the table is attempted. Example: worktrees = { { toplevel = vim.env.HOME, gitdir = vim.env.HOME .. '/projects/dotfiles/.git' } } Resolves #397
Added config.worktrees. Array of tables with the keys 'gitdir' and 'toplevel'. If attaching normally fails, then each entry in the table is attempted. Example: worktrees = { { toplevel = vim.env.HOME, gitdir = vim.env.HOME .. '/projects/dotfiles/.git' } } Resolves #397
Implemented a form of proposal 2. Feedback welcome 😄 |
Added config.worktrees. Array of tables with the keys 'gitdir' and 'toplevel'. If attaching normally fails, then each entry in the table is attempted. Example: worktrees = { { toplevel = vim.env.HOME, gitdir = vim.env.HOME .. '/projects/dotfiles/.git' } } Resolves #397
Hi,
You can see in the debug log above that you currently don't pass |
Whoops, my local fix has the side effect that the every file I open outside the toplevel dir now shows up as all new lines (probably because git's cwd is |
Well from my testing this works.
Adding
Also, just to check is |
If I run the
The same happens when I pass
And
From this alias I know that all git operations work as expected when I add |
Hmm, I've gone ahead and added the |
Added config.worktrees. Array of tables with the keys 'gitdir' and 'toplevel'. If attaching normally fails, then each entry in the table is attempted. Example: worktrees = { { toplevel = vim.env.HOME, gitdir = vim.env.HOME .. '/projects/dotfiles/.git' } } Resolves #397
With 9b09c55 (the latest) I now get an error when launching neovim in a situation in which a worktree is tried (e.g. outside a 'normal' git repository):
with this debug_log (after defining signs):
|
Added config.worktrees. Array of tables with the keys 'gitdir' and 'toplevel'. If attaching normally fails, then each entry in the table is attempted. Example: worktrees = { { toplevel = vim.env.HOME, gitdir = vim.env.HOME .. '/projects/dotfiles/.git' } } Resolves #397
Yes, probably best to wait for a CI pass before testing yourself. Should be ok now. Maybe best move this discussion to the PR as well. |
Added config.worktrees. Array of tables with the keys 'gitdir' and 'toplevel'. If attaching normally fails, then each entry in the table is attempted. Example: worktrees = { { toplevel = vim.env.HOME, gitdir = vim.env.HOME .. '/projects/dotfiles/.git' } } Resolves #397
Is your feature request related to a problem? Please describe.
I manage my dotfiles with a bare git repo setting --work-tree to $HOME but --git-dir to a different directory.
I interact with the repo with this command:
git --git-dir=$HOME/.cfg/ --work-tree=$HOME
Gitsigns does not work on my dotfiles ( it doesn't detect that $HOME is git repository).
Describe the solution you'd like
Expose a variable that allows providing extra arguments to the git command used by gitsigns.
Gitgutter does this, and I'm able to do something like:
The text was updated successfully, but these errors were encountered: