* Origin is refcounted and usually we keep the blob contents to be
* reused.
*/
-static inline struct blame_origin *origin_incref(struct blame_origin *o)
+static inline struct blame_origin *blame_origin_incref(struct blame_origin *o)
{
if (o)
o->refcnt++;
return o;
}
-static void origin_decref(struct blame_origin *o)
+static void blame_origin_decref(struct blame_origin *o)
{
if (o && --o->refcnt <= 0) {
struct blame_origin *p, *l = NULL;
if (o->previous)
- origin_decref(o->previous);
+ blame_origin_decref(o->previous);
free(o->file.ptr);
/* Should be present exactly once in commit chain */
for (p = o->commit->util; p; l = p, p = p->next) {
return;
}
}
- die("internal error in blame::origin_decref");
+ die("internal error in blame_origin_decref");
}
}
/*
* The current state of the blame assignment.
*/
-struct scoreboard {
+struct blame_scoreboard {
/* the final commit (i.e. where we started digging from) */
struct commit *final;
/* Priority queue for commits with unassigned blame records */
int *lineno;
};
-static void sanity_check_refcnt(struct scoreboard *);
+static void sanity_check_refcnt(struct blame_scoreboard *);
/*
* If two blame entries that are next to each other came from
* contiguous lines in the same origin (i.e. <commit, path> pair),
* merge them together.
*/
-static void coalesce(struct scoreboard *sb)
+static void coalesce(struct blame_scoreboard *sb)
{
struct blame_entry *ent, *next;
ent->s_lno + ent->num_lines == next->s_lno) {
ent->num_lines += next->num_lines;
ent->next = next->next;
- origin_decref(next->suspect);
+ blame_origin_decref(next->suspect);
free(next);
ent->score = 0;
next = ent; /* again */
* the commit priority queue of the score board.
*/
-static void queue_blames(struct scoreboard *sb, struct blame_origin *porigin,
+static void queue_blames(struct blame_scoreboard *sb, struct blame_origin *porigin,
struct blame_entry *sorted)
{
if (porigin->suspects)
o->next = commit->util;
commit->util = o;
}
- return origin_incref(o);
+ return blame_origin_incref(o);
}
}
return make_origin(commit, path);
* The same path between origin and its parent
* without renaming -- the most common case.
*/
- return origin_incref (porigin);
+ return blame_origin_incref (porigin);
}
/* See if the origin->path is different between parent
{
struct blame_entry *e = xmalloc(sizeof(*e));
memcpy(e, src, sizeof(*e));
- origin_incref(e->suspect);
+ blame_origin_incref(e->suspect);
e->next = **queue;
**queue = e;
static void dup_entry(struct blame_entry ***queue,
struct blame_entry *dst, struct blame_entry *src)
{
- origin_incref(src->suspect);
- origin_decref(dst->suspect);
+ blame_origin_incref(src->suspect);
+ blame_origin_decref(dst->suspect);
memcpy(dst, src, sizeof(*src));
dst->next = **queue;
**queue = dst;
*queue = &dst->next;
}
-static const char *nth_line(struct scoreboard *sb, long lno)
+static const char *nth_line(struct blame_scoreboard *sb, long lno)
{
return sb->final_buf + sb->lineno[lno];
}
static const char *nth_line_cb(void *data, long lno)
{
- return nth_line((struct scoreboard *)data, lno);
+ return nth_line((struct blame_scoreboard *)data, lno);
}
/*
if (e->s_lno < tlno) {
/* there is a pre-chunk part not blamed on parent */
- split[0].suspect = origin_incref(e->suspect);
+ split[0].suspect = blame_origin_incref(e->suspect);
split[0].lno = e->lno;
split[0].s_lno = e->s_lno;
split[0].num_lines = tlno - e->s_lno;
if (same < e->s_lno + e->num_lines) {
/* there is a post-chunk part not blamed on parent */
- split[2].suspect = origin_incref(e->suspect);
+ split[2].suspect = blame_origin_incref(e->suspect);
split[2].lno = e->lno + (same - e->s_lno);
split[2].s_lno = e->s_lno + (same - e->s_lno);
split[2].num_lines = e->s_lno + e->num_lines - same;
*/
if (split[1].num_lines < 1)
return;
- split[1].suspect = origin_incref(parent);
+ split[1].suspect = blame_origin_incref(parent);
}
/*
int i;
for (i = 0; i < 3; i++)
- origin_decref(split[i].suspect);
+ blame_origin_decref(split[i].suspect);
}
/*
n->next = diffp;
diffp = n;
} else
- origin_decref(e->suspect);
+ blame_origin_decref(e->suspect);
/* Pass blame for everything before the differing
* chunk to the parent */
- e->suspect = origin_incref(parent);
+ e->suspect = blame_origin_incref(parent);
e->s_lno += offset;
e->next = samep;
samep = e;
*/
int len = same - e->s_lno;
struct blame_entry *n = xcalloc(1, sizeof (struct blame_entry));
- n->suspect = origin_incref(e->suspect);
+ n->suspect = blame_origin_incref(e->suspect);
n->lno = e->lno + len;
n->s_lno = e->s_lno + len;
n->num_lines = e->num_lines - len;
* for the lines it is suspected to its parent. Run diff to find
* which lines came from parent and pass blame for them.
*/
-static void pass_blame_to_parent(struct scoreboard *sb,
+static void pass_blame_to_parent(struct blame_scoreboard *sb,
struct blame_origin *target,
struct blame_origin *parent)
{
*
* Compute how trivial the lines in the blame_entry are.
*/
-static unsigned ent_score(struct scoreboard *sb, struct blame_entry *e)
+static unsigned ent_score(struct blame_scoreboard *sb, struct blame_entry *e)
{
unsigned score;
const char *cp, *ep;
* so far, by comparing this and best_so_far and copying this into
* bst_so_far as needed.
*/
-static void copy_split_if_better(struct scoreboard *sb,
+static void copy_split_if_better(struct blame_scoreboard *sb,
struct blame_entry *best_so_far,
struct blame_entry *this)
{
}
for (i = 0; i < 3; i++)
- origin_incref(this[i].suspect);
+ blame_origin_incref(this[i].suspect);
decref_split(best_so_far);
memcpy(best_so_far, this, sizeof(struct blame_entry [3]));
}
*
* All line numbers are 0-based.
*/
-static void handle_split(struct scoreboard *sb,
+static void handle_split(struct blame_scoreboard *sb,
struct blame_entry *ent,
int tlno, int plno, int same,
struct blame_origin *parent,
}
struct handle_split_cb_data {
- struct scoreboard *sb;
+ struct blame_scoreboard *sb;
struct blame_entry *ent;
struct blame_origin *parent;
struct blame_entry *split;
* we can pass blames to it. file_p has the blob contents for
* the parent.
*/
-static void find_copy_in_blob(struct scoreboard *sb,
+static void find_copy_in_blob(struct blame_scoreboard *sb,
struct blame_entry *ent,
struct blame_origin *parent,
struct blame_entry *split,
* Returns a pointer to the link pointing to the old head of the small list.
*/
-static struct blame_entry **filter_small(struct scoreboard *sb,
+static struct blame_entry **filter_small(struct blame_scoreboard *sb,
struct blame_entry **small,
struct blame_entry **source,
unsigned score_min)
* See if lines currently target is suspected for can be attributed to
* parent.
*/
-static void find_move_in_parent(struct scoreboard *sb,
+static void find_move_in_parent(struct blame_scoreboard *sb,
struct blame_entry ***blamed,
struct blame_entry **toosmall,
struct blame_origin *target,
* across file boundary from the parent commit. porigin is the path
* in the parent we already tried.
*/
-static void find_copy_in_parent(struct scoreboard *sb,
+static void find_copy_in_parent(struct blame_scoreboard *sb,
struct blame_entry ***blamed,
struct blame_entry **toosmall,
struct blame_origin *target,
this);
decref_split(this);
}
- origin_decref(norigin);
+ blame_origin_decref(norigin);
}
for (j = 0; j < num_ents; j++) {
* The blobs of origin and porigin exactly match, so everything
* origin is suspected for can be blamed on the parent.
*/
-static void pass_whole_blame(struct scoreboard *sb,
+static void pass_whole_blame(struct blame_scoreboard *sb,
struct blame_origin *origin, struct blame_origin *porigin)
{
struct blame_entry *e, *suspects;
suspects = origin->suspects;
origin->suspects = NULL;
for (e = suspects; e; e = e->next) {
- origin_incref(porigin);
- origin_decref(e->suspect);
+ blame_origin_incref(porigin);
+ blame_origin_decref(e->suspect);
e->suspect = porigin;
}
queue_blames(sb, porigin, suspects);
/* Distribute collected unsorted blames to the respected sorted lists
* in the various origins.
*/
-static void distribute_blame(struct scoreboard *sb, struct blame_entry *blamed)
+static void distribute_blame(struct blame_scoreboard *sb, struct blame_entry *blamed)
{
blamed = blame_sort(blamed, compare_blame_suspect);
while (blamed)
#define MAXSG 16
-static void pass_blame(struct scoreboard *sb, struct blame_origin *origin, int opt)
+static void pass_blame(struct blame_scoreboard *sb, struct blame_origin *origin, int opt)
{
struct rev_info *revs = sb->revs;
int i, pass, num_sg;
continue;
if (!oidcmp(&porigin->blob_oid, &origin->blob_oid)) {
pass_whole_blame(sb, origin, porigin);
- origin_decref(porigin);
+ blame_origin_decref(porigin);
goto finish;
}
for (j = same = 0; j < i; j++)
if (!same)
sg_origin[i] = porigin;
else
- origin_decref(porigin);
+ blame_origin_decref(porigin);
}
}
if (!porigin)
continue;
if (!origin->previous) {
- origin_incref(porigin);
+ blame_origin_incref(porigin);
origin->previous = porigin;
}
pass_blame_to_parent(sb, origin, porigin);
for (i = 0; i < num_sg; i++) {
if (sg_origin[i]) {
drop_origin_blob(sg_origin[i]);
- origin_decref(sg_origin[i]);
+ blame_origin_decref(sg_origin[i]);
}
}
drop_origin_blob(origin);
* The main loop -- while we have blobs with lines whose true origin
* is still unknown, pick one blob, and allow its lines to pass blames
* to its parents. */
-static void assign_blame(struct scoreboard *sb, int opt)
+static void assign_blame(struct blame_scoreboard *sb, int opt)
{
struct rev_info *revs = sb->revs;
struct commit *commit = prio_queue_get(&sb->commits);
* We will use this suspect later in the loop,
* so hold onto it in the meantime.
*/
- origin_incref(suspect);
+ blame_origin_incref(suspect);
parse_commit(commit);
if (reverse ||
(!(commit->object.flags & UNINTERESTING) &&
break;
}
}
- origin_decref(suspect);
+ blame_origin_decref(suspect);
if (DEBUG) /* sanity */
sanity_check_refcnt(sb);
write_filename_info(suspect);
}
-static void emit_porcelain(struct scoreboard *sb, struct blame_entry *ent,
+static void emit_porcelain(struct blame_scoreboard *sb, struct blame_entry *ent,
int opt)
{
int repeat = opt & OUTPUT_LINE_PORCELAIN;
putchar('\n');
}
-static void emit_other(struct scoreboard *sb, struct blame_entry *ent, int opt)
+static void emit_other(struct blame_scoreboard *sb, struct blame_entry *ent, int opt)
{
int cnt;
const char *cp;
commit_info_destroy(&ci);
}
-static void output(struct scoreboard *sb, int option)
+static void output(struct blame_scoreboard *sb, int option)
{
struct blame_entry *ent;
* To allow quick access to the contents of nth line in the
* final image, prepare an index in the scoreboard.
*/
-static int prepare_lines(struct scoreboard *sb)
+static int prepare_lines(struct blame_scoreboard *sb)
{
const char *buf = sb->final_buf;
unsigned long len = sb->final_buf_size;
* How many columns do we need to show line numbers, authors,
* and filenames?
*/
-static void find_alignment(struct scoreboard *sb, int *option)
+static void find_alignment(struct blame_scoreboard *sb, int *option)
{
int longest_src_lines = 0;
int longest_dst_lines = 0;
* For debugging -- origin is refcounted, and this asserts that
* we do not underflow.
*/
-static void sanity_check_refcnt(struct scoreboard *sb)
+static void sanity_check_refcnt(struct blame_scoreboard *sb)
{
int baa = 0;
struct blame_entry *ent;
return found;
}
-static char *prepare_final(struct scoreboard *sb)
+static char *prepare_final(struct blame_scoreboard *sb)
{
const char *name;
sb->final = find_single_final(sb->revs, &name);
return xstrdup_or_null(name);
}
-static const char *dwim_reverse_initial(struct scoreboard *sb)
+static const char *dwim_reverse_initial(struct blame_scoreboard *sb)
{
/*
* DWIM "git blame --reverse ONE -- PATH" as
return sb->revs->pending.objects[0].name;
}
-static char *prepare_initial(struct scoreboard *sb)
+static char *prepare_initial(struct blame_scoreboard *sb)
{
int i;
const char *final_commit_name = NULL;
{
struct rev_info revs;
const char *path;
- struct scoreboard sb;
+ struct blame_scoreboard sb;
struct blame_origin *o;
struct blame_entry *ent = NULL;
long dashdash_pos, lno;
ent->suspect = o;
ent->s_lno = bottom;
ent->next = next;
- origin_incref(o);
+ blame_origin_incref(o);
}
o->suspects = ent;
prio_queue_put(&sb.commits, o->commit);
- origin_decref(o);
+ blame_origin_decref(o);
range_set_release(&ranges);
string_list_clear(&range_list, 0);