`git difftool` clobbers working tree, wreaking havoc
Hi there!
First, thanks for the wonderful library.
So I've been dealing with an interesting issue, and it took me a while to track it down to Mason.
I'm using Neovim v0.11.0 with the Mason plugin to install elixir_ls. This is all fine and good.
...until I run a git difftool, at which point all hell breaks loose. For context, I'm using Neovim as my difftool:
[diff]
tool = nvimdiff
[merge]
tool = nvimdiff
[difftool "nvimdiff"]
cmd = nvim -f -d \"$LOCAL\" \"$REMOTE\"
[difftool]
prompt = false
It seems that the temporary file opened in the left pane of the split is causing Mason to try and reinstall elixir-ls. When I exit the diff, git status then shows nearly all of my other working tree files to be deleted.
Here is the problematic line Mason adds to my project's .git/config after running a git difftool:
worktree = /Users/jamil/Library/Caches/mix/installs/elixir-1.18.1-erts-15.2/ddb73e4bb2c1e299782eef0365f019f3/deps/elixir_ls
I think one solution could be to disable elixir-ls LSP in diff mode, but I wanted to be sure that this isn't already supposed to be the case.
More context:
[ERROR][2025-04-28 06:51:21] ...p/_transport.lua:36 "rpc" "elixir-ls" "stderr" "Running /Users/jamil/.local/share/nvim/mason/packages/elixir-ls/launch.sh\n"
[ERROR][2025-04-28 06:51:21] ...p/_transport.lua:36 "rpc" "elixir-ls" "stderr" "Preferred shell is zsh, relaunching\nLooking for asdf install\n"
[ERROR][2025-04-28 06:51:21] ...p/_transport.lua:36 "rpc" "elixir-ls" "stderr" "asdf executable found at /opt/homebrew/bin/asdf. Using ASDF_DIR=, ASDF_DATA_DIR=.\n"
[ERROR][2025-04-28 06:51:21] ...p/_transport.lua:36 "rpc" "elixir-ls" "stderr" "Installing ElixirLS release v0.27.2\n"
[ERROR][2025-04-28 06:51:21] ...p/_transport.lua:36 "rpc" "elixir-ls" "stderr" "Running in /private/var/folders/02/4nz6gzkx5wj81dkc4pf9jyyh0000gn/T/git-blob-yYPPjQ\n"
[ERROR][2025-04-28 06:51:21] ...p/_transport.lua:36 "rpc" "elixir-ls" "stderr" "* Getting elixir_ls (https://github.com/elixir-lsp/elixir-ls.git - v0.27.2)\n"
[ERROR][2025-04-28 06:51:21] ...p/_transport.lua:36 "rpc" "elixir-ls" "stderr" "Mix.install failed with ** (Mix.Error) Command \"git --git-dir=.git remote add origin https://github.com/elixir-lsp/elixir-ls.git\" failed with reason: fatal: not a git repository: '.git'\n\n (mix 1.18.1) lib/mix.ex:613: Mix.raise/2\n (mix 1.18.1) lib/mix/scm/git.ex:110: anonymous fn/2 in Mix.SCM.Git.checkout/1\n (elixir 1.18.1) lib/file.ex:1665: File.cd!/2\n (mix 1.18.1) lib/mix/dep/fetcher.ex:68: Mix.Dep.Fetcher.do_fetch/3\n (mix 1.18.1) lib/mix/dep/converger.ex:238: Mix.Dep.Converger.all/9\n (mix 1.18.1) lib/mix/dep/converger.ex:170: Mix.Dep.Converger.init_all/8\n (mix 1.18.1) lib/mix/dep/converger.ex:110: Mix.Dep.Converger.all/4\n (mix 1.18.1) lib/mix/dep/converger.ex:89: Mix.Dep.Converger.converge/4\n\nRetrying Mix.install with force: true\n"
[ERROR][2025-04-28 06:51:21] ...p/_transport.lua:36 "rpc" "elixir-ls" "stderr" "Installing ElixirLS release v0.27.2\n"
[ERROR][2025-04-28 06:51:21] ...p/_transport.lua:36 "rpc" "elixir-ls" "stderr" "Running in /private/var/folders/02/4nz6gzkx5wj81dkc4pf9jyyh0000gn/T/git-blob-yYPPjQ\n"
[ERROR][2025-04-28 06:51:21] ...p/_transport.lua:36 "rpc" "elixir-ls" "stderr" "* Getting elixir_ls (https://github.com/elixir-lsp/elixir-ls.git - v0.27.2)\n"
[ERROR][2025-04-28 06:51:21] ...p/_transport.lua:36 "rpc" "elixir-ls" "stderr" "** (Mix.Error) Command \"git --git-dir=.git remote add origin https://github.com/elixir-lsp/elixir-ls.git\" failed with reason: fatal: not a git repository: '.git'\n\n (mix 1.18.1) lib/mix.ex:613: Mix.raise/2\n (mix 1.18.1) lib/mix/scm/git.ex:110: anonymous fn/2 in Mix.SCM.Git.checkout/1\n (elixir 1.18.1) lib/file.ex:1665: File.cd!/2\n (mix 1.18.1) lib/mix/dep/fetcher.ex:68: Mix.Dep.Fetcher.do_fetch/3\n (mix 1.18.1) lib/mix/dep/converger.ex:238: Mix.Dep.Converger.all/9\n (mix 1.18.1) lib/mix/dep/converger.ex:170: Mix.Dep.Converger.init_all/8\n (mix 1.18.1) lib/mix/dep/converger.ex:110: Mix.Dep.Converger.all/4\n (mix 1.18.1) lib/mix/dep/converger.ex:89: Mix.Dep.Converger.converge/4\n"