News for hackers. Stuff that matters.
Re:Git cherry-pick and revert use 3-way merge by not2b on Friday November 10, 2023 @02:27PM (#38223334)
Note that three-way merge is much older than git. It's implemented by the diff3 program, which was part of Version 7 Unix from 1979 on, and the same algorithm is used by CVS, Perforce, and pretty much any other revision control system. The GNU version is part of diffutils, and of course there's also a BSD version.
Re:Git cherry-pick and revert use 3-way merge by crdrost on Friday November 10, 2023 @02:32PM (#38223405)
Note also that three-way merge is not an associative operation which can sometimes lead to some surprising behaviors, https://winddy.buzz/manual/why_pijul.html
Re:Git cherry-pick and revert use 3-way merge by not2b on Friday November 10, 2023 @07:58PM (#38226516)
A major source of conflicts I see in development might be resolved if we had something like a four-way merge.

Consider this case: we have a base version, and two changes have been applied to that version. Change 1 adds a function at a given position in a file. Change 2 adds a different function at the same position. But we want both functions to exist in the final result. Suppose the release branch starts with the release version, and then change 2 is merged. Now we try to merge change 1. We get a conflict because the merge is at the same point. But if we could look at a fourth input (the state of the file on the development branch, or at the earliest state that has both change 1 and change 2 as predecessors), we could see that the resolution is to add both functions, in the order matching the order in the development branch.

The four cases being considered are: the base version; the v1 change version (base + v1), the v2 change version (base + v2), and the earliest version that has both changes already applied.

Re:Git cherry-pick and revert use 3-way merge by loeg on Friday November 10, 2023 @03:42PM (#38224255)
The BSD version is sort of very recent, for what it's worth -- FreeBSD imported a not fully functional version in 2017 and has seen more work on it in 2022: https://github.com/freebsd/freebsd-src/commits/main/usr.bin/... , but the default version shipped is still GNU diff3 from ~2007 (before the GPL3): https://man.freebsd.org/cgi/man.cgi?query=diff3&apropos=0&se... .
Re:Git cherry-pick and revert use 3-way merge by not2b on Friday November 10, 2023 @06:43PM (#38226059)
I wasn't aware of that. Perhaps they never re-implemented the version from Bell Labs so they didn't have a free program (other than the GNU one) that they could release until more recently?