RepoSense icon indicating copy to clipboard operation
RepoSense copied to clipboard

Handle merge commit with conflict resolution

Open HCY123902 opened this issue 1 year ago • 2 comments

What feature(s) would you like to see in RepoSense

Currently, the number of additions and deletions in merge commits with more than 1 parent commit will always be shown as 0 on the chart panel and commit panel due to the way how the wrapper class GitLog.java works. According to this post and this post, git log --numstat does not actually diff a merge commit against either of its parent by default, because it does not know which parent to compare with. However, there can be merge commits with conflict resolution. The number of additions and deletions in conflict resolution should get reflected for these merge commits in this case.

Is the feature request related to a problem?

This is related to the problem when a mege commit contains conflict resolution.

If possible, describe the solution

To actually get the number of additions and deletions, there has to be an additional option such as -c, --cc, or -m to either combine or pick the difference.

According to the posts, -c and --cc will only compute differences for a merge commit that is different from both of its parents, meaning that the merge commit contains additional changes for conflict resolution, and other merge commits will again be skipped. The -m option compares the commit with each of its parents separately.

However, there can be more complications involved. If the master branch also contains changes that have not been merged into the feature branch prior to the merge commit, then the result may also deviate from the desired addition or deletion count.

If applicable, describe alternatives you've considered

A possible alternative will be to use --first-parent with other necessary options to compute the addition and deletion count.

Additional context

Related issues: #1877 #1876 #389

HCY123902 avatar Mar 02 '23 08:03 HCY123902

Seems like there is an option in one of the later git versions (2.36) of git log --remerge-diff which I found from this stackoverflow post though I'm not too sure how it differs compared to the above. Just wanted to share this when I briefly looked at the issue some time back

chan-j-d avatar Mar 07 '23 12:03 chan-j-d

Seems like there is an option in one of the later git versions (2.36) of git log --remerge-diff which I found from this stackoverflow post though I'm not too sure how it differs compared to the above. Just wanted to share this when I briefly looked at the issue some time back

This seems helpful. The git version can be a concern but there should be a way to get around it. To contributors, if you want to take this issue, you may need to try the different options on merge commits such as this and check the behavioral difference

HCY123902 avatar Mar 07 '23 12:03 HCY123902