Blame src/blame.h

Packit ae9e2a
#ifndef INCLUDE_blame_h__
Packit ae9e2a
#define INCLUDE_blame_h__
Packit ae9e2a
Packit ae9e2a
#include "git2/blame.h"
Packit ae9e2a
#include "common.h"
Packit ae9e2a
#include "vector.h"
Packit ae9e2a
#include "diff.h"
Packit ae9e2a
#include "array.h"
Packit ae9e2a
#include "git2/oid.h"
Packit ae9e2a
Packit ae9e2a
/*
Packit ae9e2a
 * One blob in a commit that is being suspected
Packit ae9e2a
 */
Packit ae9e2a
typedef struct git_blame__origin {
Packit ae9e2a
	int refcnt;
Packit ae9e2a
	struct git_blame__origin *previous;
Packit ae9e2a
	git_commit *commit;
Packit ae9e2a
	git_blob *blob;
Packit ae9e2a
	char path[GIT_FLEX_ARRAY];
Packit ae9e2a
} git_blame__origin;
Packit ae9e2a
Packit ae9e2a
/*
Packit ae9e2a
 * Each group of lines is described by a git_blame__entry; it can be split
Packit ae9e2a
 * as we pass blame to the parents.  They form a linked list in the
Packit ae9e2a
 * scoreboard structure, sorted by the target line number.
Packit ae9e2a
 */
Packit ae9e2a
typedef struct git_blame__entry {
Packit ae9e2a
	struct git_blame__entry *prev;
Packit ae9e2a
	struct git_blame__entry *next;
Packit ae9e2a
Packit ae9e2a
	/* the first line of this group in the final image;
Packit ae9e2a
	 * internally all line numbers are 0 based.
Packit ae9e2a
	 */
Packit ae9e2a
	size_t lno;
Packit ae9e2a
Packit ae9e2a
	/* how many lines this group has */
Packit ae9e2a
	size_t num_lines;
Packit ae9e2a
Packit ae9e2a
	/* the commit that introduced this group into the final image */
Packit ae9e2a
	git_blame__origin *suspect;
Packit ae9e2a
Packit ae9e2a
	/* true if the suspect is truly guilty; false while we have not
Packit ae9e2a
	 * checked if the group came from one of its parents.
Packit ae9e2a
	 */
Packit ae9e2a
	bool guilty;
Packit ae9e2a
Packit ae9e2a
	/* true if the entry has been scanned for copies in the current parent
Packit ae9e2a
	 */
Packit ae9e2a
	bool scanned;
Packit ae9e2a
Packit ae9e2a
	/* the line number of the first line of this group in the
Packit ae9e2a
	 * suspect's file; internally all line numbers are 0 based.
Packit ae9e2a
	 */
Packit ae9e2a
	size_t s_lno;
Packit ae9e2a
Packit ae9e2a
	/* how significant this entry is -- cached to avoid
Packit ae9e2a
	 * scanning the lines over and over.
Packit ae9e2a
	 */
Packit ae9e2a
	unsigned score;
Packit ae9e2a
Packit ae9e2a
	/* Whether this entry has been tracked to a boundary commit.
Packit ae9e2a
	 */
Packit ae9e2a
	bool is_boundary;
Packit ae9e2a
} git_blame__entry;
Packit ae9e2a
Packit ae9e2a
struct git_blame {
Packit ae9e2a
	char *path;
Packit ae9e2a
	git_repository *repository;
Packit ae9e2a
	git_blame_options options;
Packit ae9e2a
Packit ae9e2a
	git_vector hunks;
Packit ae9e2a
	git_vector paths;
Packit ae9e2a
Packit ae9e2a
	git_blob *final_blob;
Packit ae9e2a
	git_array_t(size_t) line_index;
Packit ae9e2a
Packit ae9e2a
	size_t current_diff_line;
Packit ae9e2a
	git_blame_hunk *current_hunk;
Packit ae9e2a
Packit ae9e2a
	/* Scoreboard fields */
Packit ae9e2a
	git_commit *final;
Packit ae9e2a
	git_blame__entry *ent;
Packit ae9e2a
	int num_lines;
Packit ae9e2a
	const char *final_buf;
Packit ae9e2a
	git_off_t final_buf_size;
Packit ae9e2a
};
Packit ae9e2a
Packit ae9e2a
git_blame *git_blame__alloc(
Packit ae9e2a
	git_repository *repo,
Packit ae9e2a
	git_blame_options opts,
Packit ae9e2a
	const char *path);
Packit ae9e2a
Packit ae9e2a
#endif