summaryrefslogtreecommitdiff
path: root/builtin/blame.c
diff options
context:
space:
mode:
authorJeff Smith <whydoubt@gmail.com>2017-05-24 05:15:31 (GMT)
committerJunio C Hamano <gitster@pobox.com>2017-05-25 04:08:22 (GMT)
commite94f77f0e28788972c3c828bdcbe5d68d034849e (patch)
treeb42442191807ca9ba60313fea837d59b8954fc35 /builtin/blame.c
parentd0d0ef1f67c1549aa1eab55c9a4ec1c2c34fccaa (diff)
downloadgit-e94f77f0e28788972c3c828bdcbe5d68d034849e.zip
git-e94f77f0e28788972c3c828bdcbe5d68d034849e.tar.gz
git-e94f77f0e28788972c3c828bdcbe5d68d034849e.tar.bz2
blame: create entry prepend function
Create function that populates a blame_entry and prepends it to a list. Signed-off-by: Jeff Smith <whydoubt@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin/blame.c')
-rw-r--r--builtin/blame.c25
1 files changed, 15 insertions, 10 deletions
diff --git a/builtin/blame.c b/builtin/blame.c
index fd41551..29771b7 100644
--- a/builtin/blame.c
+++ b/builtin/blame.c
@@ -2643,6 +2643,20 @@ void setup_scoreboard(struct blame_scoreboard *sb, const char *path, struct blam
*orig = o;
}
+struct blame_entry *blame_entry_prepend(struct blame_entry *head,
+ long start, long end,
+ struct blame_origin *o)
+{
+ struct blame_entry *new_head = xcalloc(1, sizeof(struct blame_entry));
+ new_head->lno = start;
+ new_head->num_lines = end - start;
+ new_head->suspect = o;
+ new_head->s_lno = start;
+ new_head->next = head;
+ blame_origin_incref(o);
+ return new_head;
+}
+
int cmd_blame(int argc, const char **argv, const char *prefix)
{
struct rev_info revs;
@@ -2885,16 +2899,7 @@ parse_done:
for (range_i = ranges.nr; range_i > 0; --range_i) {
const struct range *r = &ranges.ranges[range_i - 1];
- long bottom = r->start;
- long top = r->end;
- struct blame_entry *next = ent;
- ent = xcalloc(1, sizeof(*ent));
- ent->lno = bottom;
- ent->num_lines = top - bottom;
- ent->suspect = o;
- ent->s_lno = bottom;
- ent->next = next;
- blame_origin_incref(o);
+ ent = blame_entry_prepend(ent, r->start, r->end, o);
}
o->suspects = ent;