Merge branch 'jk/blame-first-parent' into maint
authorJunio C Hamano <gitster@pobox.com>
Fri, 16 Oct 2015 21:32:34 +0000 (14:32 -0700)
committerJunio C Hamano <gitster@pobox.com>
Fri, 16 Oct 2015 21:32:34 +0000 (14:32 -0700)
"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

builtin/blame.c
t/annotate-tests.sh
index 245d253d041021429265eb81fb008e528613af34..295ce92da5df25a9082b868e848ee9634145e636 100644 (file)
@@ -1371,8 +1371,15 @@ static void pass_whole_blame(struct scoreboard *sb,
  */
 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 lookup_decoration(&revs->children, &commit->object);
 }
 
@@ -2685,6 +2692,8 @@ int cmd_blame(int argc, const char **argv, const char *prefix)
        }
        else if (contents_from)
                die("--contents and --children do not blend well.");
+       else if (revs.first_parent_only)
+               die("combining --first-parent and --reverse is not supported");
        else {
                final_commit_name = prepare_initial(&sb);
                sb.commits.compare = compare_commits_by_reverse_commit_date;
index f5c01758ca38b58fc10e30cfac81be5becb0316b..b1673b3e8f38d9961b8b2783e1f5c47a865638fb 100644 (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
 '
 
+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' '
        check_count -h master A 2 B 2
 '