https://bugs.kde.org/show_bug.cgi?id=437570
Bug ID: 437570 Summary: KDiff3 3-way merge injects newlines and strips trailing newlines Product: kdiff3 Version: 1.9.2 Platform: Archlinux Packages OS: Linux Status: REPORTED Severity: normal Priority: NOR Component: application Assignee: reeves...@gmail.com Reporter: nyanpas...@tuta.io Target Milestone: --- Created attachment 138712 --> https://bugs.kde.org/attachment.cgi?id=138712&action=edit Three files that when kdiff3 tries to merge, it produces an incorrect result. SUMMARY When merging complex files and resolving conflicts by hand, KDiff3 1.9.0+ saves an incorrect output file with extraneous newlines inserted, and the trailing newline removed. STEPS TO REPRODUCE 1. Download and extract the attached "kdiff3 merge error.zip". 2. kdiff3 RtAudio_BASE_452948.h RtAudio_LOCAL_452948.h RtAudio_REMOTE_452948.h -o out.h (or open these 3 files in the GUI). 3. You'll get a merge conflict. Click (optionally double-click) closeStream on the left and press Ctrl+Y. That should fix the conflict. Then save the file. 4. To check the results, run diff RtAudio_LOCAL_452948.h out.h (or kdiff3). OBSERVED RESULT Comparing out.h to the local file, there are extraneous newlines introduced within the file, as well as the final newline (present in all 3 input files) being stripped from the written file. (I think this is not caused by inconsistent line endings, and that all 3 files contain LF only.) The first extraneous newline is introduced after the line containing `RtAudioFormat nativeFormats{};`. After that line, the original KDiff3 (3-way merge) window's output pane says "B <No src line>", but upon saving, writes out an empty line anyway. The second extraneous newline is introduced after the line containing `RtAudioFormat nativeFormats{};`, with the same "B <No src line>" behavior that writes a newline anyway. If you navigate to either diff, deselect B, and reselect B, then the "B <No src line>" line disappears from the output panel, and the extraneous newline is no longer present when you save. EXPECTED RESULT Comparing out.h to the local file, kdiff3 should output exactly 2 added lines of text and no newline changes. And kdiff3 1.8.5 and prior do exactly that. SOFTWARE/OS VERSIONS Tested on KDiff3 1.9.0 on Windows 10 x64, and KDiff3 1.9.0 and 1.9.2 on Arch Linux x64. I get the same results on both. Another person tested KDiff3 1.9.2 on Windows 10 x64, and got only the missing newline on the end, no injected newlines in the middle. I tried bisecting KDiff3's commit history, it seems 1.9.0 has this bug, `git merge-base 1.9.2 master` pops up a "Severe Internal Error" dialog when trying to merge, and `git merge-base 1.8.5 master` does not have this bug, as does 1.8.5. ADDITIONAL INFORMATION When trying to bisect this bug, I've noticed that the Git commit log of KDiff3 has divergent feature branches for 1.8.5 and 1.9.2 and master. My efforts to bisect each of these branches were hampered by occasional commits that failed to compile, and stretches of history that popped up a "Severe Internal Error" dialog instead of merging. Was there a major long-term refactor between 1.8.5 and 1.9.0 that resulted in non-functional intermediate states, and introduced subtle functional issues like this bug? -- You are receiving this mail because: You are watching all bug changes.