]> git.proxmox.com Git - libgit2.git/blob - src/blame.h
Upload to experimental
[libgit2.git] / src / blame.h
1 #ifndef INCLUDE_blame_h__
2 #define INCLUDE_blame_h__
3
4 #include "common.h"
5
6 #include "git2/blame.h"
7 #include "vector.h"
8 #include "diff.h"
9 #include "array.h"
10 #include "git2/oid.h"
11
12 /*
13 * One blob in a commit that is being suspected
14 */
15 typedef struct git_blame__origin {
16 int refcnt;
17 struct git_blame__origin *previous;
18 git_commit *commit;
19 git_blob *blob;
20 char path[GIT_FLEX_ARRAY];
21 } git_blame__origin;
22
23 /*
24 * Each group of lines is described by a git_blame__entry; it can be split
25 * as we pass blame to the parents. They form a linked list in the
26 * scoreboard structure, sorted by the target line number.
27 */
28 typedef struct git_blame__entry {
29 struct git_blame__entry *prev;
30 struct git_blame__entry *next;
31
32 /* the first line of this group in the final image;
33 * internally all line numbers are 0 based.
34 */
35 size_t lno;
36
37 /* how many lines this group has */
38 size_t num_lines;
39
40 /* the commit that introduced this group into the final image */
41 git_blame__origin *suspect;
42
43 /* true if the suspect is truly guilty; false while we have not
44 * checked if the group came from one of its parents.
45 */
46 bool guilty;
47
48 /* true if the entry has been scanned for copies in the current parent
49 */
50 bool scanned;
51
52 /* the line number of the first line of this group in the
53 * suspect's file; internally all line numbers are 0 based.
54 */
55 size_t s_lno;
56
57 /* how significant this entry is -- cached to avoid
58 * scanning the lines over and over.
59 */
60 unsigned score;
61
62 /* Whether this entry has been tracked to a boundary commit.
63 */
64 bool is_boundary;
65 } git_blame__entry;
66
67 struct git_blame {
68 char *path;
69 git_repository *repository;
70 git_mailmap *mailmap;
71 git_blame_options options;
72
73 git_vector hunks;
74 git_vector paths;
75
76 git_blob *final_blob;
77 git_array_t(size_t) line_index;
78
79 size_t current_diff_line;
80 git_blame_hunk *current_hunk;
81
82 /* Scoreboard fields */
83 git_commit *final;
84 git_blame__entry *ent;
85 int num_lines;
86 const char *final_buf;
87 size_t final_buf_size;
88 };
89
90 git_blame *git_blame__alloc(
91 git_repository *repo,
92 git_blame_options opts,
93 const char *path);
94
95 #endif