Merge branch 'jk/blame-first-parent'

"git blame --first-parent v1.0..v2.0" was not rejected but did not
limit the blame to commits on the first parent chain.

* jk/blame-first-parent:
  blame: handle --first-parent
This commit is contained in:
Junio C Hamano 2015-10-05 12:30:24 -07:00
commit ff2be2610a
2 changed files with 14 additions and 1 deletions

View File

@ -1366,8 +1366,15 @@ static void pass_whole_blame(struct scoreboard *sb,
*/ */
static struct commit_list *first_scapegoat(struct rev_info *revs, struct commit *commit) static struct commit_list *first_scapegoat(struct rev_info *revs, struct commit *commit)
{ {
if (!reverse) if (!reverse) {
if (revs->first_parent_only &&
commit->parents &&
commit->parents->next) {
free_commit_list(commit->parents->next);
commit->parents->next = NULL;
}
return commit->parents; return commit->parents;
}
return lookup_decoration(&revs->children, &commit->object); return lookup_decoration(&revs->children, &commit->object);
} }
@ -2679,6 +2686,8 @@ parse_done:
} }
else if (contents_from) else if (contents_from)
die("--contents and --children do not blend well."); die("--contents and --children do not blend well.");
else if (revs.first_parent_only)
die("combining --first-parent and --reverse is not supported");
else { else {
final_commit_name = prepare_initial(&sb); final_commit_name = prepare_initial(&sb);
sb.commits.compare = compare_commits_by_reverse_commit_date; sb.commits.compare = compare_commits_by_reverse_commit_date;

View File

@ -111,6 +111,10 @@ test_expect_success 'blame 2 authors + 2 merged-in authors' '
check_count A 2 B 1 B1 2 B2 1 check_count A 2 B 1 B1 2 B2 1
' '
test_expect_success 'blame --first-parent blames merge for branch1' '
check_count --first-parent A 2 B 1 "A U Thor" 2 B2 1
'
test_expect_success 'blame ancestor' ' test_expect_success 'blame ancestor' '
check_count -h master A 2 B 2 check_count -h master A 2 B 2
' '