6 #include "xdiff-interface.h"
8 #include "prio-queue.h"
11 * One blob in a commit that is being suspected
15 /* Record preceding blame record for this blob */
16 struct blame_origin
*previous
;
17 /* origins are put in a list linked via `next' hanging off the
18 * corresponding commit's util field in order to make finding
19 * them fast. The presence in this chain does not count
20 * towards the origin's reference count. It is tempting to
21 * let it count as long as the commit is pending examination,
22 * but even under circumstances where the commit will be
23 * present multiple times in the priority queue of unexamined
24 * commits, processing the first instance will not leave any
25 * work requiring the origin data for the second instance. An
26 * interspersed commit changing that would have to be
27 * preexisting with a different ancestry and with the same
28 * commit date in order to wedge itself between two instances
29 * of the same commit in the priority queue _and_ produce
30 * blame entries relevant for it. While we don't want to let
31 * us get tripped up by this case, it certainly does not seem
32 * worth optimizing for.
34 struct blame_origin
*next
;
35 struct commit
*commit
;
36 /* `suspects' contains blame entries that may be attributed to
37 * this origin's commit or to parent commits. When a commit
38 * is being processed, all suspects will be moved, either by
39 * assigning them to an origin in a different commit, or by
40 * shipping them to the scoreboard's ent list because they
41 * cannot be attributed to a different commit.
43 struct blame_entry
*suspects
;
45 struct object_id blob_oid
;
47 /* guilty gets set when shipping any suspects to the final
48 * blame list instead of other commits
51 char path
[FLEX_ARRAY
];
55 * Each group of lines is described by a blame_entry; it can be split
56 * as we pass blame to the parents. They are arranged in linked lists
57 * kept as `suspects' of some unprocessed origin, or entered (when the
58 * blame origin has been finalized) into the scoreboard structure.
59 * While the scoreboard structure is only sorted at the end of
60 * processing (according to final image line number), the lists
61 * attached to an origin are sorted by the target line number.
64 struct blame_entry
*next
;
66 /* the first line of this group in the final image;
67 * internally all line numbers are 0 based.
71 /* how many lines this group has */
74 /* the commit that introduced this group into the final image */
75 struct blame_origin
*suspect
;
77 /* the line number of the first line of this group in the
78 * suspect's file; internally all line numbers are 0 based.
82 /* how significant this entry is -- cached to avoid
83 * scanning the lines over and over.
89 * The current state of the blame assignment.
91 struct blame_scoreboard
{
92 /* the final commit (i.e. where we started digging from) */
94 /* Priority queue for commits with unassigned blame records */
95 struct prio_queue commits
;
96 struct rev_info
*revs
;
100 * The contents in the final image.
101 * Used by many functions to obtain contents of the nth line,
102 * indexed with scoreboard.lineno[blame_entry.lno].
104 const char *final_buf
;
105 unsigned long final_buf_size
;
107 /* linked list of blames */
108 struct blame_entry
*ent
;
110 /* look-up a line in the final buffer */
120 * blame for a blame_entry with score lower than these thresholds
121 * is not passed to the parent using move/copy logic.
126 /* use this file's contents as the final image */
127 const char *contents_from
;
133 int no_whole_file_rename
;
137 void(*on_sanity_fail
)(struct blame_scoreboard
*, int);
138 void(*found_guilty_entry
)(struct blame_entry
*, void *);
140 void *found_guilty_entry_data
;
144 * Origin is refcounted and usually we keep the blob contents to be
147 static inline struct blame_origin
*blame_origin_incref(struct blame_origin
*o
)
153 extern void blame_origin_decref(struct blame_origin
*o
);
155 extern struct blame_origin
*make_origin(struct commit
*commit
, const char *path
);
156 extern struct blame_origin
*get_origin(struct commit
*commit
, const char *path
);