WinMerge / winmerge

WinMerge is an Open Source differencing and merging tool for Windows. WinMerge can compare both folders and files, presenting differences in a visual text format that is easy to understand and handle.
https://winmerge.org/
GNU General Public License v2.0
6.38k stars 791 forks source link

Wimerge saves changes to the wrong file #1985

Closed IainCrampton closed 1 year ago

IainCrampton commented 1 year ago

winmerge: Version 2.16.32.0 x64, OS: Windows 11 Enterprise 22H2 I compare two source code folders (large projects with many files/subfolders) I open a file (in the vvideo example p136.c) and compare the two versions of that file and leave the tab open, I open another file (bridge.cpp) and compare the two versions of that file I copy a change from the right to left file in the bridge.cpp and save using Ctrl+S or Alt+F+S Instead of saving the changes to bridge.cpp, p136.c (file in tab 1) is overwritten with a copy of bridge.cpp (file from tab2) Any subsequent file opened doesthe same thing - looks OK until you save changes, then the left file becomes the file from the first tab opened. If I restart Winmerge it behaves properly for a while then starts doing the same thing again sometime later.

Video: https://epsusllc-my.sharepoint.com/:v:/g/personal/iain_crampton_epssw_com/EfHulHXWGjlEh0XbdOnZjQ4BXvHarr3TYlPd65wvvY9_zA?e=dth5Zs

sdottaka commented 1 year ago

How did you open the file p136.c?

This can happen if you open the p136.c file with the command line option /o as follows: The command line option /o is an option to change the destination of the specified file.

"c:\program files\winmerge\winmergeu.exe" file1 file2 /o p136.c
IainCrampton commented 1 year ago

@sdottaka As far as a I recall I opened it from a taskbar shortcut. I suppose it is possible I re-used an open copy that originally started from looking at a diff in tortoise it, but it was a new folder comparison. I don't know if tortoise git uses the /o option in the background ever. I didn't use the comand line myself,.

sdottaka commented 1 year ago

If you start WinMerge from TortoiseGit to resolve conflicts, the /o option will be used, so if you reuse the WinMerge window started from TortoiseGit without closing it, the problem you pointed out will occur. Of course, this behavior is problematic and needs improvement.

IainCrampton commented 1 year ago

@sdottaka in that case I suppose it is not a bug as such and we can close this issue. My suggestion for improvement would be that if Winmerge is started with /o option, then when the user opens a new tab (or starts a new file or folder comparison) the user is warned that this option is in effect and given the option to cancel it. Thanks for your help :-)

sdottaka commented 1 year ago

With PR #1988, the /o command line option no longer affects tabs other than those opened with this option.