How to indicate which fixations make changes in the merger of the octopuses

When a particular recursive merge has 2 parent commits, as indicated here , the second parent is the commit on the branch that we merged into, which means all changes made by this join. This is normal for a recursive merge . But if it is an octopuss merge , like this , how can we determine which commits introduce which changes ?. thanks in advance

+1
source share
1 answer

UPDATE - some clarification added regarding diff based approach

It is somewhat wrong to say that the second parent is the source of all the changes in the normal merge. It may be manual conflict resolution, or someone may just merge with the --no-commit option and introduce additional changes during the merge itself. It is more common to think about how the merger is different from each of its parents than to think about which parent made each change.

However, it may be useful to think in terms of "where is this change from." Depending on what kind of information you really have after you can start with one of them:

1) git blame will tell you about the commit that every line of code comes from. Everything that comes from HEAD^..branchN in HEAD^..branchN should indicate a change to branchN . But since the information you provided is a commit identifier for each line of code, significant post-processing will be required for a zero change.

2) You can make diff for each branch. I originally thought

 git diff HEAD^ HEAD^2 

etc. (replacing HEAD^2 link to each merged branch). This is normal, except when the main branch has changed a lot since the other branches diverge (in this case, the inverse of these changes will be displayed in each fault).

What you are really asking is the difference between each end of the branch and the point at which this branch began to diverge; therefore, if you can find a "common ancestor", maybe just use this:

 git diff A HEAD^2 

(where A is the last commit available from both HEAD^ and HEAD^2 ). Although this is a straightforward way to express (one branch at a time) exactly what you mean, it does require tracking a common ancestor in each case. (Maybe a good shortcut that I donโ€™t think about, I will come back with an update if this happens to me.)

And if the branch topology is too dirty, it might be somewhat obscure. For example, if branch3 was actually forked with branch2 , then you will need to decide whether you want to use diff branch3 for a common ancestor using HEAD or using branch2 (the first approach means some changes will be attributed to both branch2 and branch3 ).

It would be nice to use one command to generate all the differences, and on the surface this is what the -m option does for log or show ; but this brings us back to the beginning of my answer, since you get the difference between merging with each branch (and not the changes made by each branch) and must mentally deny each change. (i.e. you have to look for one branch whose diff does not include the change in order to know where the change is from).

0
source

Source: https://habr.com/ru/post/1200677/


All Articles