edamagit icon indicating copy to clipboard operation
edamagit copied to clipboard

File diffs can't be expanded in status view when diff.external is set in git config

Open zmwangx opened this issue 5 months ago • 4 comments

This is really a continuation of https://github.com/kahole/edamagit/issues/228. A fix was provided there in the form of https://github.com/kahole/edamagit/pull/293 but unfortunately doesn't fix the problem, at least not in the status view.

The reason is that the fix is in the diff function in diffingCommands.ts but the status view doesn't use that for diffing. Instead, the diff is obtained with repository.diffWithHEAD using VSCode's builtin vscode.git extension API, with doesn't supply --no-ext-diff. I'm hesitant to call that a bug in vscode.git since I don't think it promises to give a parseable vanilla diff in the first place?

The best solution might be switching to the ext-diff aware diff implementation.

Barring that users who want to use this feature while keeping difft will have to disable diff.external and rely on shell aliases for git -c diff.external=difft ... to use it.

zmwangx avatar Jul 29 '25 03:07 zmwangx

I'm seeing the same issue since a few days. It used to work, I'm quite sure I did not changed by .gitconfig meanwhile.

The TAB key does not expand e.g. the files listed under the Unstaged changes section, while the magit.toggle-fold command works.

It works if I map that command using e.g. Shift+TAB, but that's a bit annoying.

My keybinding's JSON has the suggested settings:

	{
		"key": "tab",
		"command": "extension.vim_tab",
		"when": "editorTextFocus && vim.active && !inDebugRepl && vim.mode != 'Insert' && editorLangId != 'magit'"
	},
	{
		"key": "tab",
		"command": "-extension.vim_tab",
		"when": "editorTextFocus && vim.active && !inDebugRepl && vim.mode != 'Insert'"
	},

thus, it seems that the when conditions are somehow not properly working?

derkling avatar Jul 29 '25 12:07 derkling

The TAB key does not expand e.g. the files listed under the Unstaged changes section, while the magit.toggle-fold command works.

Pretty sure yours is an unrelated issue. My issue is about magit.toggle-fold not working, and I pinpointed the root cause of that; so yours can't be it if magit.toggle-fold actually works.

Anyway, you may use "Developer: Toggle Keyboard Shortcuts Troubleshooting" to see how keyboard shortcuts are triggered.

zmwangx avatar Jul 30 '25 01:07 zmwangx

I'm experiencing the exact same issue. Thanks for tracking it down @zmwangx, it's definitely unrelated to the tab key issue. In my case I'm using vscode-neovim and added magit as a languageId to ignore neovim keybinds in and I can use tab to collapse some stuff, just no diffs as I am using difft as an external diff formatter for git.

starcraft66 avatar Sep 15 '25 22:09 starcraft66

I've side-stepped this by setting git.path in my vscode settings.json to the path to the following wrapper script which injects --no-ext-diff to any git diff command and confirmed that this restores edamagit functionality. I prefer this method as I don't ever use any of the git features in vscode itself and mostly operate from the command-line. This way I don't have to hack in difft via shell aliases.

#!/usr/bin/env sh

if [ "$1" = "diff" ]; then
    # Insert --no-ext-diff before forwarding the rest
    command git diff --no-ext-diff "${@:2}"
else
    # Forward everything else untouched
    command git "$@"
fi

starcraft66 avatar Sep 16 '25 09:09 starcraft66