From: Max Kirillov <max@max630.net>
To: Junio C Hamano <gitster@pobox.com>, Jeff King <peff@peff.net>
Cc: Max Kirillov <max@max630.net>, git@vger.kernel.org
Subject: [PATCH 2/2] blame: allow blame --reverse --first-parent when it makes sense
Date: Wed, 21 Oct 2015 07:08:02 +0300 [thread overview]
Message-ID: <1445400482-1977-3-git-send-email-max@max630.net> (raw)
In-Reply-To: <1445400482-1977-1-git-send-email-max@max630.net>
Do not die immediately when the two flags are specified. Instead
check that the specified range is along first-parent chain. Explioit
how prepare_revision_walk() handles first_parent_only flag: the commits
outside of first-parent chain are either unknown (and do not have any
children recorded) or appear as non-first parent of a commit along the
first-parent chain.
Since the check seems fragile, add test which makes sure that blame dies
in both cases.
Signed-off-by: Max Kirillov <max@max630.net>
---
builtin/blame.c | 11 +++++++++--
t/t8009-blame-reverse.sh | 7 ++++++-
2 files changed, 15 insertions(+), 3 deletions(-)
diff --git a/builtin/blame.c b/builtin/blame.c
index 295ce92..27de544 100644
--- a/builtin/blame.c
+++ b/builtin/blame.c
@@ -2692,8 +2692,6 @@ 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;
@@ -2721,6 +2719,15 @@ parse_done:
if (prepare_revision_walk(&revs))
die(_("revision walk setup failed"));
+ if (reverse && revs.first_parent_only) {
+ struct commit_list *final_children = lookup_decoration(&revs.children,
+ &sb.final->object);
+ if (!final_children ||
+ hashcmp(final_children->item->parents->item->object.sha1,
+ sb.final->object.sha1))
+ die("--reverse --first-parent together require range along first-parent chain");
+ }
+
if (is_null_sha1(sb.final->object.sha1)) {
o = sb.final->util;
sb.final_buf = xmemdupz(o->file.ptr, o->file.size);
diff --git a/t/t8009-blame-reverse.sh b/t/t8009-blame-reverse.sh
index 9f40613..042863b 100755
--- a/t/t8009-blame-reverse.sh
+++ b/t/t8009-blame-reverse.sh
@@ -24,11 +24,16 @@ test_expect_failure 'blame --reverse finds B1, not C1' '
test_cmp expect actual
'
-test_expect_failure 'blame --reverse --first-parent finds A1' '
+test_expect_success 'blame --reverse --first-parent finds A1' '
git blame --porcelain --reverse --first-parent A0..A3 -- file.t >actual_full &&
head -1 <actual_full | sed -e "sX .*XX" >actual &&
git rev-parse A1 >expect &&
test_cmp expect actual
'
+test_expect_success 'blame --reverse --first-parse dies if no first parent chain' '
+ test_must_fail git blame --porcelain --reverse --first-parent B1..A3 -- file.t &&
+ test_must_fail git blame --porcelain --reverse --first-parent B2..A3 -- file.t
+ '
+
test_done
--
2.3.4.2801.g3d0809b
next prev parent reply other threads:[~2015-10-21 4:16 UTC|newest]
Thread overview: 34+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-10-21 4:08 [PATCH 0/2] blame: allow blame --reverse --first-parent when it makes sense Max Kirillov
2015-10-21 4:08 ` [PATCH 1/2] Add test to describe expectation of blame --reverse with branched history Max Kirillov
2015-10-21 4:08 ` Max Kirillov [this message]
2015-10-21 4:29 ` [PATCH 2/2] blame: allow blame --reverse --first-parent when it makes sense Eric Sunshine
2015-10-22 3:52 ` Max Kirillov
2015-10-22 3:51 ` [PATCH v2 0/2] " Max Kirillov
2015-10-22 3:51 ` [PATCH v2 1/2] Add test to describe expectation of blame --reverse with branched history Max Kirillov
2015-10-22 4:19 ` Junio C Hamano
2015-10-22 14:37 ` Max Kirillov
2015-10-22 14:56 ` Max Kirillov
2015-10-22 3:51 ` [PATCH v2 2/2] blame: allow blame --reverse --first-parent when it makes sense Max Kirillov
2015-10-22 4:25 ` Junio C Hamano
2015-10-22 14:56 ` Max Kirillov
2015-10-22 19:11 ` Junio C Hamano
2015-10-25 12:43 ` Max Kirillov
2015-10-25 16:52 ` Junio C Hamano
2015-10-22 4:07 ` [PATCH v3 0/2] " Max Kirillov
2015-10-22 4:07 ` [PATCH v3 1/2] Add test to describe expectation of blame --reverse with branched history Max Kirillov
2015-10-22 4:07 ` [PATCH v3 2/2] blame: allow blame --reverse --first-parent when it makes sense Max Kirillov
2015-10-26 5:26 ` [PATCH v4 0/4] " Max Kirillov
2015-10-26 5:26 ` [PATCH v4 1/3] Add test to describe expectation of blame --reverse with branched history Max Kirillov
2015-10-26 5:41 ` Max Kirillov
2015-10-26 6:27 ` Junio C Hamano
2015-10-27 4:40 ` Max Kirillov
2015-10-27 17:57 ` Junio C Hamano
2015-10-26 5:26 ` [PATCH v4 2/3] blame: extract find_single_final Max Kirillov
2015-10-26 5:26 ` [PATCH v4 3/3] blame: allow blame --reverse --first-parent when it makes sense Max Kirillov
2015-10-30 5:01 ` [PATCH v5 0/3] " Max Kirillov
2015-10-30 5:01 ` [PATCH v5 1/3] blame: test to describe use of blame --reverse --first-parent Max Kirillov
2015-10-30 22:30 ` Junio C Hamano
2015-10-30 5:01 ` [PATCH v5 2/3] blame: extract find_single_final Max Kirillov
2015-10-30 5:01 ` [PATCH v5 3/3] blame: allow blame --reverse --first-parent when it makes sense Max Kirillov
2015-10-26 5:26 ` [PATCH v4 0/4] " Max Kirillov
2015-10-26 5:31 ` Max Kirillov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1445400482-1977-3-git-send-email-max@max630.net \
--to=max@max630.net \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=peff@peff.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.