For research purposes, I'm currently trying to benchmark Git's three-way merge algorithm. Ideally, I would want to do the following:
First, create a local Git repository with some file original.txt
. Suppose it contains the following:
This is line 1.
This is line 2.
This is line 3.
Second, create two branches A
and B
that each modify original.txt
. Suppose A
modifies the file to be
This is line 2.
This is line 4.
This is line 6.
(i.e. a change on each line) and B
modifies the document to be
This is line 1.
This is line 6.
This is line 9.
(no change on the first line, changes on the last two lines).
Third, I would want to merge the branches locally (i.e. I don't want to involve Github). I'm not particularly interested in resolving the merge conflicts. Rather, I am interested in which lines conflict themselves. So ideally, I would want to be able to run some command that could produce a dump of which lines had conflicts. So for the running example, I would want some sort of utility that could produce something like the following:
Number of lines in conflict: 2
Lines in conflict: 2, 3
Question: The first two steps are pretty easily done. For the last, normally I would just create pull requests and then merge. But I'm not sure of a way that does this offline and also creates the dump of the information that I want. Is there a straightforward way to accomplish these goals? The easier the solution the better, as I would want to automate such a process with testing scripts.