|
28 | 28 | #include "line-log.h"
|
29 | 29 | #include "dir.h"
|
30 | 30 | #include "progress.h"
|
| 31 | +#include "blame.h" |
31 | 32 |
|
32 | 33 | static char blame_usage[] = N_("git blame [<options>] [<rev-opts>] [<rev>] [--] <file>");
|
33 | 34 |
|
@@ -75,50 +76,6 @@ static unsigned blame_copy_score;
|
75 | 76 | #define METAINFO_SHOWN (1u<<12)
|
76 | 77 | #define MORE_THAN_ONE_PATH (1u<<13)
|
77 | 78 |
|
78 |
| -/* |
79 |
| - * One blob in a commit that is being suspected |
80 |
| - */ |
81 |
| -struct blame_origin { |
82 |
| - int refcnt; |
83 |
| - /* Record preceding blame record for this blob */ |
84 |
| - struct blame_origin *previous; |
85 |
| - /* origins are put in a list linked via `next' hanging off the |
86 |
| - * corresponding commit's util field in order to make finding |
87 |
| - * them fast. The presence in this chain does not count |
88 |
| - * towards the origin's reference count. It is tempting to |
89 |
| - * let it count as long as the commit is pending examination, |
90 |
| - * but even under circumstances where the commit will be |
91 |
| - * present multiple times in the priority queue of unexamined |
92 |
| - * commits, processing the first instance will not leave any |
93 |
| - * work requiring the origin data for the second instance. An |
94 |
| - * interspersed commit changing that would have to be |
95 |
| - * preexisting with a different ancestry and with the same |
96 |
| - * commit date in order to wedge itself between two instances |
97 |
| - * of the same commit in the priority queue _and_ produce |
98 |
| - * blame entries relevant for it. While we don't want to let |
99 |
| - * us get tripped up by this case, it certainly does not seem |
100 |
| - * worth optimizing for. |
101 |
| - */ |
102 |
| - struct blame_origin *next; |
103 |
| - struct commit *commit; |
104 |
| - /* `suspects' contains blame entries that may be attributed to |
105 |
| - * this origin's commit or to parent commits. When a commit |
106 |
| - * is being processed, all suspects will be moved, either by |
107 |
| - * assigning them to an origin in a different commit, or by |
108 |
| - * shipping them to the scoreboard's ent list because they |
109 |
| - * cannot be attributed to a different commit. |
110 |
| - */ |
111 |
| - struct blame_entry *suspects; |
112 |
| - mmfile_t file; |
113 |
| - struct object_id blob_oid; |
114 |
| - unsigned mode; |
115 |
| - /* guilty gets set when shipping any suspects to the final |
116 |
| - * blame list instead of other commits |
117 |
| - */ |
118 |
| - char guilty; |
119 |
| - char path[FLEX_ARRAY]; |
120 |
| -}; |
121 |
| - |
122 | 79 | struct progress_info {
|
123 | 80 | struct progress *progress;
|
124 | 81 | int blamed_lines;
|
@@ -208,40 +165,6 @@ static void drop_origin_blob(struct blame_origin *o)
|
208 | 165 | }
|
209 | 166 | }
|
210 | 167 |
|
211 |
| -/* |
212 |
| - * Each group of lines is described by a blame_entry; it can be split |
213 |
| - * as we pass blame to the parents. They are arranged in linked lists |
214 |
| - * kept as `suspects' of some unprocessed origin, or entered (when the |
215 |
| - * blame origin has been finalized) into the scoreboard structure. |
216 |
| - * While the scoreboard structure is only sorted at the end of |
217 |
| - * processing (according to final image line number), the lists |
218 |
| - * attached to an origin are sorted by the target line number. |
219 |
| - */ |
220 |
| -struct blame_entry { |
221 |
| - struct blame_entry *next; |
222 |
| - |
223 |
| - /* the first line of this group in the final image; |
224 |
| - * internally all line numbers are 0 based. |
225 |
| - */ |
226 |
| - int lno; |
227 |
| - |
228 |
| - /* how many lines this group has */ |
229 |
| - int num_lines; |
230 |
| - |
231 |
| - /* the commit that introduced this group into the final image */ |
232 |
| - struct blame_origin *suspect; |
233 |
| - |
234 |
| - /* the line number of the first line of this group in the |
235 |
| - * suspect's file; internally all line numbers are 0 based. |
236 |
| - */ |
237 |
| - int s_lno; |
238 |
| - |
239 |
| - /* how significant this entry is -- cached to avoid |
240 |
| - * scanning the lines over and over. |
241 |
| - */ |
242 |
| - unsigned score; |
243 |
| -}; |
244 |
| - |
245 | 168 | /*
|
246 | 169 | * Any merge of blames happens on lists of blames that arrived via
|
247 | 170 | * different parents in a single suspect. In this case, we want to
|
@@ -335,61 +258,6 @@ static int compare_commits_by_reverse_commit_date(const void *a,
|
335 | 258 | return -compare_commits_by_commit_date(a, b, c);
|
336 | 259 | }
|
337 | 260 |
|
338 |
| -/* |
339 |
| - * The current state of the blame assignment. |
340 |
| - */ |
341 |
| -struct blame_scoreboard { |
342 |
| - /* the final commit (i.e. where we started digging from) */ |
343 |
| - struct commit *final; |
344 |
| - /* Priority queue for commits with unassigned blame records */ |
345 |
| - struct prio_queue commits; |
346 |
| - struct rev_info *revs; |
347 |
| - const char *path; |
348 |
| - |
349 |
| - /* |
350 |
| - * The contents in the final image. |
351 |
| - * Used by many functions to obtain contents of the nth line, |
352 |
| - * indexed with scoreboard.lineno[blame_entry.lno]. |
353 |
| - */ |
354 |
| - const char *final_buf; |
355 |
| - unsigned long final_buf_size; |
356 |
| - |
357 |
| - /* linked list of blames */ |
358 |
| - struct blame_entry *ent; |
359 |
| - |
360 |
| - /* look-up a line in the final buffer */ |
361 |
| - int num_lines; |
362 |
| - int *lineno; |
363 |
| - |
364 |
| - /* stats */ |
365 |
| - int num_read_blob; |
366 |
| - int num_get_patch; |
367 |
| - int num_commits; |
368 |
| - |
369 |
| - /* |
370 |
| - * blame for a blame_entry with score lower than these thresholds |
371 |
| - * is not passed to the parent using move/copy logic. |
372 |
| - */ |
373 |
| - unsigned move_score; |
374 |
| - unsigned copy_score; |
375 |
| - |
376 |
| - /* use this file's contents as the final image */ |
377 |
| - const char *contents_from; |
378 |
| - |
379 |
| - /* flags */ |
380 |
| - int reverse; |
381 |
| - int show_root; |
382 |
| - int xdl_opts; |
383 |
| - int no_whole_file_rename; |
384 |
| - int debug; |
385 |
| - |
386 |
| - /* callbacks */ |
387 |
| - void(*on_sanity_fail)(struct blame_scoreboard *, int); |
388 |
| - void(*found_guilty_entry)(struct blame_entry *, void *); |
389 |
| - |
390 |
| - void *found_guilty_entry_data; |
391 |
| -}; |
392 |
| - |
393 | 261 | static void blame_sort_final(struct blame_scoreboard *sb)
|
394 | 262 | {
|
395 | 263 | sb->ent = llist_mergesort(sb->ent, get_next_blame, set_next_blame,
|
|
0 commit comments