Open erhhung opened 3 years ago
(Experimental duplicate detection) Thanks for submitting this issue. Please also check if it is already covered by an existing one, like:
I experienced this error as well today. Steps to reproduce: create git repository with any text file in it. I used this python file, which I named test.py:
import sys
print("Hello world, this is python version " + sys.version)
for x in range(1, 6):
print(x)
print('Goodbye!')
Create a new branch based on HEAD, I named mine new_for_merge. In test.py on the new branch, I added a line between lines 4 and 5. So the file looked like this:
import sys
print("Hello world, this is python version " + sys.version)
for x in range(1, 6):
print(x)
print('Goodbye!')
Then I made a similar change in the master
branch, but added some text on that line:
import sys
print("Hello world, this is python version " + sys.version)
sys
for x in range(1, 6):
print(x)
print('Goodbye!')
Then from new_for_merge
, I attempted to merge master
into the current branch. This results in a merge conflict:
import sys
print("Hello world, this is python version " + sys.version)
<<<<<<< HEAD
=======
sys
>>>>>>> master
for x in range(1, 6):
print(x)
print('Goodbye!')
And within VSCode, it presents me with the options "Accept Current Change", "Accept Incoming Change", "Accept Both Changes", "Compare Changes". Hitting "Accept Current Changes" should keep the file the way it currently is, which in this case would mean adding a blank line after line 4. But when I hit "Accept Current Changes" in VSCode currently, the line gets removed entirely, keeping neither the current nor incoming changes! (So my file now looks like the first code block, when the expected behavior would be looking like the second)
VSCode version info:
This issue does still occur even when all extensions are disabled, and other git GUI programs do not have this problem, and can properly handle accepting the changes.
It seems to happen with both Accept Current Change
or Accept Incoming Change
, but not Accept Both Changes
. Example file with git merge conflict markers:
Example 1: Clicking on "Accept Current Change" should preserve the current empty line, but does not.
(but it works when clicking "Accept Both Changes" or if there are multiple empty lines)
<<<<<<< HEAD
=======
>>>>>>> other_branch
trailing line
Example 2: Clicking on "Accept Incoming Change" should preserve the incoming empty line, but does not.
(but it works when clicking "Accept Both Changes" or if there are multiple empty lines)
<<<<<<< HEAD
=======
>>>>>>> other_branch
trailing line
(VSCode 1.79.2, no extensions loaded)
I'm resolving a merge conflict where the last diff is the following (I had already resolved a couple successfully earlier in the file):
Current Change ↔ Incoming Changes
Basically, just an empty line inserted by the current change.
Add I see this in the merge interface:
If I click on Accept Current Change, the empty line was not preserved—in fact, if I undo and click Accept Incoming Change instead, the result is the same!
Does this issue occur when all extensions are disabled?: not tested
Originally reported under and possibly related to: https://github.com/microsoft/vscode/issues/107821#issuecomment-831657432