From: Max Kirillov <max@max630.net>
To: Junio C Hamano <gitster@pobox.com>, Jeff King <peff@peff.net>,
Eric Sunshine <sunshine@sunshineco.com>
Cc: Max Kirillov <max@max630.net>, git@vger.kernel.org
Subject: [PATCH v4 2/3] blame: extract find_single_final
Date: Mon, 26 Oct 2015 07:26:56 +0200 [thread overview]
Message-ID: <1445837217-4252-4-git-send-email-max@max630.net> (raw)
In-Reply-To: <1445837217-4252-1-git-send-email-max@max630.net>
Signed-off-by: Max Kirillov <max@max630.net>
---
builtin/blame.c | 29 +++++++++++++++++------------
1 file changed, 17 insertions(+), 12 deletions(-)
diff --git a/builtin/blame.c b/builtin/blame.c
index 295ce92..38f6267 100644
--- a/builtin/blame.c
+++ b/builtin/blame.c
@@ -2401,16 +2401,11 @@ static struct commit *fake_working_tree_commit(struct diff_options *opt,
return commit;
}
-static char *prepare_final(struct scoreboard *sb)
+static struct object_array_entry *find_single_final(struct rev_info *revs)
{
int i;
- const char *final_commit_name = NULL;
- struct rev_info *revs = sb->revs;
+ struct object_array_entry *found = NULL;
- /*
- * There must be one and only one positive commit in the
- * revs->pending array.
- */
for (i = 0; i < revs->pending.nr; i++) {
struct object *obj = revs->pending.objects[i].item;
if (obj->flags & UNINTERESTING)
@@ -2419,14 +2414,24 @@ static char *prepare_final(struct scoreboard *sb)
obj = deref_tag(obj, NULL, 0);
if (obj->type != OBJ_COMMIT)
die("Non commit %s?", revs->pending.objects[i].name);
- if (sb->final)
+ if (found)
die("More than one commit to dig from %s and %s?",
revs->pending.objects[i].name,
- final_commit_name);
- sb->final = (struct commit *) obj;
- final_commit_name = revs->pending.objects[i].name;
+ found->name);
+ found = &(revs->pending.objects[i]);
+ }
+ return found;
+}
+
+static char *prepare_final(struct scoreboard *sb)
+{
+ struct object_array_entry *found = find_single_final(sb->revs);
+ if (found) {
+ sb->final = (struct commit *) found->item;
+ return xstrdup(found->name);
+ } else {
+ return NULL;
}
- return xstrdup_or_null(final_commit_name);
}
static char *prepare_initial(struct scoreboard *sb)
--
2.3.4.2801.g3d0809b
next prev parent reply other threads:[~2015-10-26 5:27 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 ` [PATCH 2/2] blame: allow blame --reverse --first-parent when it makes sense Max Kirillov
2015-10-21 4:29 ` 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 ` Max Kirillov [this message]
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=1445837217-4252-4-git-send-email-max@max630.net \
--to=max@max630.net \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=peff@peff.net \
--cc=sunshine@sunshineco.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).