Merge branch 'mk/blame-first-parent'
Regression fix for a topic already in master. * mk/blame-first-parent: blame: fix object casting regression
This commit is contained in:
commit
fd13a2ecfb
@ -2402,10 +2402,12 @@ static struct commit *fake_working_tree_commit(struct diff_options *opt,
|
|||||||
return commit;
|
return commit;
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct object_array_entry *find_single_final(struct rev_info *revs)
|
static struct commit *find_single_final(struct rev_info *revs,
|
||||||
|
const char **name_p)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
struct object_array_entry *found = NULL;
|
struct commit *found = NULL;
|
||||||
|
const char *name = NULL;
|
||||||
|
|
||||||
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;
|
||||||
@ -2417,22 +2419,20 @@ static struct object_array_entry *find_single_final(struct rev_info *revs)
|
|||||||
die("Non commit %s?", revs->pending.objects[i].name);
|
die("Non commit %s?", revs->pending.objects[i].name);
|
||||||
if (found)
|
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, name);
|
||||||
found->name);
|
found = (struct commit *)obj;
|
||||||
found = &(revs->pending.objects[i]);
|
name = revs->pending.objects[i].name;
|
||||||
}
|
}
|
||||||
|
if (name_p)
|
||||||
|
*name_p = name;
|
||||||
return found;
|
return found;
|
||||||
}
|
}
|
||||||
|
|
||||||
static char *prepare_final(struct scoreboard *sb)
|
static char *prepare_final(struct scoreboard *sb)
|
||||||
{
|
{
|
||||||
struct object_array_entry *found = find_single_final(sb->revs);
|
const char *name;
|
||||||
if (found) {
|
sb->final = find_single_final(sb->revs, &name);
|
||||||
sb->final = (struct commit *) found->item;
|
return xstrdup_or_null(name);
|
||||||
return xstrdup(found->name);
|
|
||||||
} else {
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static char *prepare_initial(struct scoreboard *sb)
|
static char *prepare_initial(struct scoreboard *sb)
|
||||||
@ -2720,11 +2720,9 @@ parse_done:
|
|||||||
die("Cannot use --contents with final commit object name");
|
die("Cannot use --contents with final commit object name");
|
||||||
|
|
||||||
if (reverse && revs.first_parent_only) {
|
if (reverse && revs.first_parent_only) {
|
||||||
struct object_array_entry *entry = find_single_final(sb.revs);
|
final_commit = find_single_final(sb.revs, NULL);
|
||||||
if (!entry)
|
if (!final_commit)
|
||||||
die("--reverse and --first-parent together require specified latest commit");
|
die("--reverse and --first-parent together require specified latest commit");
|
||||||
else
|
|
||||||
final_commit = (struct commit*) entry->item;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -68,6 +68,13 @@ test_expect_success 'blame 1 author' '
|
|||||||
check_count A 2
|
check_count A 2
|
||||||
'
|
'
|
||||||
|
|
||||||
|
test_expect_success 'blame by tag objects' '
|
||||||
|
git tag -m "test tag" testTag &&
|
||||||
|
git tag -m "test tag #2" testTag2 testTag &&
|
||||||
|
check_count -h testTag A 2 &&
|
||||||
|
check_count -h testTag2 A 2
|
||||||
|
'
|
||||||
|
|
||||||
test_expect_success 'setup B lines' '
|
test_expect_success 'setup B lines' '
|
||||||
echo "2A quick brown fox jumps over the" >>file &&
|
echo "2A quick brown fox jumps over the" >>file &&
|
||||||
echo "lazy dog" >>file &&
|
echo "lazy dog" >>file &&
|
||||||
|
Loading…
Reference in New Issue
Block a user