Merge branch 'rs/blame-code-cleanup' into maint
Code clean-up. * rs/blame-code-cleanup: blame: move blame_entry duplication to add_blame_entry()
This commit is contained in:
commit
a9508a1345
@ -658,8 +658,11 @@ static struct origin *find_rename(struct scoreboard *sb,
|
|||||||
/*
|
/*
|
||||||
* Append a new blame entry to a given output queue.
|
* Append a new blame entry to a given output queue.
|
||||||
*/
|
*/
|
||||||
static void add_blame_entry(struct blame_entry ***queue, struct blame_entry *e)
|
static void add_blame_entry(struct blame_entry ***queue,
|
||||||
|
const struct blame_entry *src)
|
||||||
{
|
{
|
||||||
|
struct blame_entry *e = xmalloc(sizeof(*e));
|
||||||
|
memcpy(e, src, sizeof(*e));
|
||||||
origin_incref(e->suspect);
|
origin_incref(e->suspect);
|
||||||
|
|
||||||
e->next = **queue;
|
e->next = **queue;
|
||||||
@ -760,21 +763,15 @@ static void split_blame(struct blame_entry ***blamed,
|
|||||||
struct blame_entry *split,
|
struct blame_entry *split,
|
||||||
struct blame_entry *e)
|
struct blame_entry *e)
|
||||||
{
|
{
|
||||||
struct blame_entry *new_entry;
|
|
||||||
|
|
||||||
if (split[0].suspect && split[2].suspect) {
|
if (split[0].suspect && split[2].suspect) {
|
||||||
/* The first part (reuse storage for the existing entry e) */
|
/* The first part (reuse storage for the existing entry e) */
|
||||||
dup_entry(unblamed, e, &split[0]);
|
dup_entry(unblamed, e, &split[0]);
|
||||||
|
|
||||||
/* The last part -- me */
|
/* The last part -- me */
|
||||||
new_entry = xmalloc(sizeof(*new_entry));
|
add_blame_entry(unblamed, &split[2]);
|
||||||
memcpy(new_entry, &(split[2]), sizeof(struct blame_entry));
|
|
||||||
add_blame_entry(unblamed, new_entry);
|
|
||||||
|
|
||||||
/* ... and the middle part -- parent */
|
/* ... and the middle part -- parent */
|
||||||
new_entry = xmalloc(sizeof(*new_entry));
|
add_blame_entry(blamed, &split[1]);
|
||||||
memcpy(new_entry, &(split[1]), sizeof(struct blame_entry));
|
|
||||||
add_blame_entry(blamed, new_entry);
|
|
||||||
}
|
}
|
||||||
else if (!split[0].suspect && !split[2].suspect)
|
else if (!split[0].suspect && !split[2].suspect)
|
||||||
/*
|
/*
|
||||||
@ -785,18 +782,12 @@ static void split_blame(struct blame_entry ***blamed,
|
|||||||
else if (split[0].suspect) {
|
else if (split[0].suspect) {
|
||||||
/* me and then parent */
|
/* me and then parent */
|
||||||
dup_entry(unblamed, e, &split[0]);
|
dup_entry(unblamed, e, &split[0]);
|
||||||
|
add_blame_entry(blamed, &split[1]);
|
||||||
new_entry = xmalloc(sizeof(*new_entry));
|
|
||||||
memcpy(new_entry, &(split[1]), sizeof(struct blame_entry));
|
|
||||||
add_blame_entry(blamed, new_entry);
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
/* parent and then me */
|
/* parent and then me */
|
||||||
dup_entry(blamed, e, &split[1]);
|
dup_entry(blamed, e, &split[1]);
|
||||||
|
add_blame_entry(unblamed, &split[2]);
|
||||||
new_entry = xmalloc(sizeof(*new_entry));
|
|
||||||
memcpy(new_entry, &(split[2]), sizeof(struct blame_entry));
|
|
||||||
add_blame_entry(unblamed, new_entry);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user