1

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.

paulinho
  • 292
  • 2
  • 13
  • Hi, can you share the code, im really interesting with this – Andy Winarko Dec 16 '20 at 17:43
  • Hi, I don't really have any code right now; I was wondering if there was a particular command/git utility that could accomplish the third step. Is there any code in particular that you are thinking of? – paulinho Dec 16 '20 at 17:46
  • 1
    Have a look at `git merge-base` https://git-scm.com/docs/git-merge-base and `git merge-tree` https://git-scm.com/docs/git-merge-tree -- these commands seem to be what you're looking for. – terrorrussia-keeps-killing Dec 16 '20 at 17:47
  • 1
    Sure you can.... just checkout one branch, then run `git merge the-other-branch` and let it rock. (as a side note, this is what goes on inside github or whatever other service you are using) – eftshift0 Dec 16 '20 at 21:15

0 Answers0