]> git.ipfire.org Git - thirdparty/git.git/commit - t/t8009-blame-vs-topicbranches.sh
blame: test to describe use of blame --reverse --first-parent
authorMax Kirillov <max@max630.net>
Fri, 30 Oct 2015 05:01:51 +0000 (07:01 +0200)
committerJunio C Hamano <gitster@pobox.com>
Fri, 30 Oct 2015 22:28:45 +0000 (15:28 -0700)
commitec352401fb7f74939cbd1154a878e094f75d79ce
tree6561f90d863fd6578e303518430c7e49ff0e83d8
parent95a4fb0eac20de024fed242a7c9227af86334202
blame: test to describe use of blame --reverse --first-parent

Reverse blame can be used to locate removal of lines which does not
change adjacent lines. Such edits do not appear in non-reverse blame,
because the adjacent lines last changed commit is older history, before
the edit.

For a big and active project which uses topic branches, or analogous
feature, for example pull-requests, the history can contain many
concurrent branches, and even after an edit merged into the target
branch, there are still many (sometimes several tens or even hundreds)
topic branch which do not contain it:

 a0--a1-----*a2-*a3-a4...-*a100
 |\         /   /         /
 | b0-B1..bN   /         /
 |\           /         /
 | c0..   ..cN         /
 \                    /
  z0..            ..zN

Here, the '*'s mark the first parent in merge, and uppercase B1 - the
commit where the line being blamed for was removed. Since commits cN-zN
do not contain B1, they still have the line removed in B1, and
reverse blame can report that the last commit for the line was zN
(meaning that it was removed in a100). In fact it really does return
some very late commit, and this makes it unusable for finding the B1
commit.

The search could be done by blame --reverse --first-parent. For range
a0..a100 it would return a1, and then only one additional blame along
the a0..bN will return the desired commit b0. But combining --reverse
and --first-parent was forbidden in 95a4fb0eac, because incorrectly
specified range could produce unexpected and meaningless result.

Add test which describes the expected behavior of
`blame --reverse --first-parent` in the case described above.

Signed-off-by: Max Kirillov <max@max630.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
t/t8009-blame-vs-topicbranches.sh [new file with mode: 0755]