blame: extract find_single_final
Signed-off-by: Max Kirillov <max@max630.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
parent
ec352401fb
commit
1b0d40000a
@ -2396,16 +2396,11 @@ static struct commit *fake_working_tree_commit(struct diff_options *opt,
|
|||||||
return commit;
|
return commit;
|
||||||
}
|
}
|
||||||
|
|
||||||
static char *prepare_final(struct scoreboard *sb)
|
static struct object_array_entry *find_single_final(struct rev_info *revs)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
const char *final_commit_name = NULL;
|
struct object_array_entry *found = NULL;
|
||||||
struct rev_info *revs = sb->revs;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* There must be one and only one positive commit in the
|
|
||||||
* revs->pending array.
|
|
||||||
*/
|
|
||||||
for (i = 0; i < revs->pending.nr; i++) {
|
for (i = 0; i < revs->pending.nr; i++) {
|
||||||
struct object *obj = revs->pending.objects[i].item;
|
struct object *obj = revs->pending.objects[i].item;
|
||||||
if (obj->flags & UNINTERESTING)
|
if (obj->flags & UNINTERESTING)
|
||||||
@ -2414,14 +2409,24 @@ static char *prepare_final(struct scoreboard *sb)
|
|||||||
obj = deref_tag(obj, NULL, 0);
|
obj = deref_tag(obj, NULL, 0);
|
||||||
if (obj->type != OBJ_COMMIT)
|
if (obj->type != OBJ_COMMIT)
|
||||||
die("Non commit %s?", revs->pending.objects[i].name);
|
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?",
|
die("More than one commit to dig from %s and %s?",
|
||||||
revs->pending.objects[i].name,
|
revs->pending.objects[i].name,
|
||||||
final_commit_name);
|
found->name);
|
||||||
sb->final = (struct commit *) obj;
|
found = &(revs->pending.objects[i]);
|
||||||
final_commit_name = revs->pending.objects[i].name;
|
}
|
||||||
|
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)
|
static char *prepare_initial(struct scoreboard *sb)
|
||||||
|
Loading…
Reference in New Issue
Block a user