diff options
author | Jeff King <peff@peff.net> | 2015-09-15 13:05:39 +0300 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2015-09-16 19:59:05 +0300 |
commit | 95a4fb0eac20de024fed242a7c9227af86334202 (patch) | |
tree | 5099a9f345c300b8290a4937550aeffb32c349ea /builtin/blame.c | |
parent | 27ea6f85beff1173ec74349fa35c45951feee570 (diff) |
blame: handle --first-parent
The revision.c options-parser will parse "--first-parent"
for us, but the blame code does not actually respect it, as
we simply iterate over the whole list returned by
first_scapegoat(). We can fix this by returning a
truncated parent list.
Note that we could technically also do so by limiting the
return value of num_scapegoats(), but that is less robust.
We would rely on nobody ever looking at the "next" pointer
from the returned list.
Combining "--reverse" with "--first-parent" is more
complicated, and will probably involve cooperation from
revision.c. Since the desired semantics are not even clear,
let's punt on this for now, but explicitly disallow it to
avoid confusing users (this is not really a regression,
since it did something nonsensical before).
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin/blame.c')
-rw-r--r-- | builtin/blame.c | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/builtin/blame.c b/builtin/blame.c index a22ac17407..e024f43aee 100644 --- a/builtin/blame.c +++ b/builtin/blame.c @@ -1365,8 +1365,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); } @@ -2677,6 +2684,8 @@ parse_done: } 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; |