When looking at a merge, "git blame" inspects the blob object names
of all parents and if one of them exactly match the merge result,
pass the entire blame down to that parent.  This is very much in
line with the history simplification done with "git log" when
traversing a history with merges.

On the other hand, when the blob object in the merge result and none
of the parents match exactly, we let each parent to take as much blame
as they can, starting from the earlier parent, and later parents get
a chance to take blame on the "leftover bits".

Combination of the above can lead to an unexpected results.

Let's say that M is a two-parent merge, M^1 == A and M^2 == B, and
that M:path == B:path != A:path (i.e. the merge result matches its
second parent exactly).  The entire contents of the path is blamed
to the history leading to B; the history leading to A but not
involved in B will not get any blame.

Now, imagine if you amend M to create N, to add a single line at the
end of path.  M:path != N:path but there is very small difference
between the two.  That means B:path != N:path but the difference
between this merged result and the second parent is very small.

Because we give the chance to get blamed for the whole thing to the
first parent, however, A will grab blame for all the lines that are
common between A:path and B:path.  For the lines that are the same
between M:path and N:path, ideally, we should get identical results,
but it results in a very inconsistent behaviour.

Update blame.c::pass_blame() and give an option to arrange the list
of "scapegoats" in the order that are similar to the end result, in
order to address this issue.  That way, when blaming N:path, we will
inspect B:path first and let it grab as much blame, as it would happen
when we started the blame for M:path.

To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to