-
Notifications
You must be signed in to change notification settings - Fork 2
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
rocks update in bare repo with GIT_DIR and GIT_WORK_TREE env vars set can lead to loss of uncomitted local changes #78
Comments
Hey 👋 Thanks for the detailed report. |
Just commenting out rocks-git.nvim from rocks.toml and then running
However, if I first removed rocks-git.nvim completely (comment out and run |
I've pushed a release in which I unset the two env variables when invoking |
So after reporting an issue with my configuration that lead to issues with updates and syncs against git repos when using rocks-git.nvim in a bare repo it turned out to be essentially user error (see for reference)
However, I think there is potentially something still to be looked at here?
Basically AFAICT, if someone is using a bare repo setup, and has the GIT_DIR and GIT_WORK_TREE env vars set for any reason and available from within nvim they might lose changes in their worktree if all of the following applies:
:Rocks sync
initially without the GIT_DIR or GIT_WORK_TREE setup in order to get the plugins installed first:Rocks update
When this happens it seems that one can lose all uncommitted changes in the worktree (I assume related somehow to the use of "--force" checkout?)
I think this was previously noted here, but OP was unsure of how to reproduce.
Originally posted by @boydkelly in nvim-neorocks/rocks.nvim#312 (comment)
I've setup a minimal config to reproduce using a fresh NVIM_APPNAME folder and only installing rocks, rocks-config, rocks-git, a git sourced plugin baredot.nvim which simply allows me to more easily set the GIT_DIR and GIT_WORK_TREE env vars. The key, in my testing at least, was to also install telescope-fzf-native.nvim from git
with a make build command in config(edit happens with or without the build key in rocks.toml).Here's the output of the minimal files, default rocks.nvim init.lua created from pasting in register when running the install script, and a bare bones baredot.nvim config setup.
rocks.toml
init.lua
Here's the alias I use for my bare repo:
dotz is an alias for /usr/bin/git --work-tree=$HOME --git-dir=$HOME/.config/dotz/
And here's the bare bones baredot.nvim plugin setup:
On first run of nvim I can
:Rocks sync
to install all the listed plugins from rocks.toml. I sometimes have to start nvim again and rerun:Rocks sync
to make sure it installs the baredot plugin (seems like rocks-git.nvim needs to be installed first and then the git plugins can be installed subsequently?Either way, once both rocks-git and baredot and telescope-fzf have been installed sucesfully, exit nvim and make some changes in the bare repo locally, but don't commit yet.
As you can see my GIT_WORK_TREE is simply home (~). And I now have some changes within the work tree.
If I now start nvim from the GIT_WORK_TREE dir (~) as the cwd with either baredot plugin managing the GIT_WORK_TREE and GIT_DIR env vars (this also occurs when setting them manually and not using the baredot plugin) - and then run
:Rocks update
the following errors occur during the operation.`:Rocks log` after error during `:Rocks update`
Checking the status of the bare repo now shows it's lost all local changes.
The text was updated successfully, but these errors were encountered: