summaryrefslogtreecommitdiff
path: root/src/blame.h
diff options
context:
space:
mode:
authorBen Straub <bs@github.com>2013-09-20 15:51:22 -0700
committerBen Straub <bs@github.com>2013-09-21 15:52:01 -0700
commit0a0f0558a44d3eb176c32bff57b84f135d65db7a (patch)
treedfe422ce8f34839caf167b97cf5b80e25876be1e /src/blame.h
parentef03d040cf6cc81d71d340cf3915735724a77449 (diff)
downloadlibgit2-0a0f0558a44d3eb176c32bff57b84f135d65db7a.tar.gz
git_blame is a scoreboard
Diffstat (limited to 'src/blame.h')
-rw-r--r--src/blame.h62
1 files changed, 62 insertions, 0 deletions
diff --git a/src/blame.h b/src/blame.h
index 1b107320b..d730cfb89 100644
--- a/src/blame.h
+++ b/src/blame.h
@@ -8,6 +8,61 @@
#include "array.h"
#include "git2/oid.h"
+/*
+ * One blob in a commit that is being suspected
+ */
+typedef struct git_blame__origin {
+ int refcnt;
+ struct git_blame__origin *previous;
+ git_commit *commit;
+ git_blob *blob;
+ char path[];
+} git_blame__origin;
+
+/*
+ * Each group of lines is described by a git_blame__entry; it can be split
+ * as we pass blame to the parents. They form a linked list in the
+ * scoreboard structure, sorted by the target line number.
+ */
+typedef struct git_blame__entry {
+ struct git_blame__entry *prev;
+ struct git_blame__entry *next;
+
+ /* the first line of this group in the final image;
+ * internally all line numbers are 0 based.
+ */
+ int lno;
+
+ /* how many lines this group has */
+ int num_lines;
+
+ /* the commit that introduced this group into the final image */
+ git_blame__origin *suspect;
+
+ /* true if the suspect is truly guilty; false while we have not
+ * checked if the group came from one of its parents.
+ */
+ char guilty;
+
+ /* true if the entry has been scanned for copies in the current parent
+ */
+ char scanned;
+
+ /* the line number of the first line of this group in the
+ * suspect's file; internally all line numbers are 0 based.
+ */
+ int s_lno;
+
+ /* how significant this entry is -- cached to avoid
+ * scanning the lines over and over.
+ */
+ unsigned score;
+
+ /* Whether this entry has been tracked to a boundary commit.
+ */
+ bool is_boundary;
+} git_blame__entry;
+
struct git_blame {
const char *path;
git_repository *repository;
@@ -20,6 +75,13 @@ struct git_blame {
size_t current_diff_line;
git_blame_hunk *current_hunk;
+
+ /* Scoreboard fields */
+ git_commit *final;
+ git_blame__entry *ent;
+ int num_lines;
+ const char *final_buf;
+ git_off_t final_buf_size;
};
git_blame *git_blame__alloc(