microsoft / vscode

Visual Studio Code
https://code.visualstudio.com
MIT License
163.61k stars 29.03k forks source link

merge-conflict cannot resolve binary files #134785

Open zWingz opened 3 years ago

zWingz commented 3 years ago

Does this issue occur when all extensions are disabled?: Yes/No

Steps to Reproduce:

  1. make a merge conflict with some binary files image

  2. merge branch

  3. click accept-current or accept-income

It doesn't work

MarkSchuckParadigm commented 2 years ago

I've been using vscode for merge conflict resolution for a while and it works great... except for binary conflicts. Would be great if we could select 'accept-incoming' or 'accept-current'.

Too bad it doesn't work.. are there any workarounds beyond manually running one of these?

git checkout --theirs -- \<path> git checkout --ours -- \<path>

Drulikar commented 1 year ago

I was really surprised to find this is not supported in VSC, and this issue has existed for as long as it has. I would have assumed the issue was with git lens but found https://github.com/gitkraken/vscode-gitlens/issues/1050 and I eventually found this. This is basically mandatory functionality for any project that has any assets so you must either use a different client, or resolve these manually in CLI. Its pretty absurd VSC doesn't even spit out a message when the user attempts the dialogue options on a binary file even though there's numerous caught exceptions thrown when you attempt either accept current or accept incoming.

If someone wanted to finally tackle this, it looks like refactoring would be need to be done to remove most/all acceptTextOnly checks for resolve methods related to this, and refactor acceptAllResources to not rely on conflict markers and instead just replace the entire file rather than the conflict blocks. Relevant files probably are commandHandler and maybe mergeConflictParser.

If there's an edge case where you might be attempting to call acceptAllResources on a non-conflicting file somehow, checking for whether a file is conflicted shouldn't depend on whether it has the markers (like the current call to containsConflict) and instead probably use the states in the file's SourceControlResourceState.

I just am not currently sure how in this codebase you would go about getting a reference to the relevant SourceControlResourceState to confirm the file is conflicting, or grab the unmodified local/remote file other than just explicitly performing the git commands like you would in CLI.