Blame src/diff_generate.h

Packit ae9e2a
/*
Packit ae9e2a
 * Copyright (C) the libgit2 contributors. All rights reserved.
Packit ae9e2a
 *
Packit ae9e2a
 * This file is part of libgit2, distributed under the GNU GPL v2 with
Packit ae9e2a
 * a Linking Exception. For full terms see the included COPYING file.
Packit ae9e2a
 */
Packit ae9e2a
#ifndef INCLUDE_diff_generate_h__
Packit ae9e2a
#define INCLUDE_diff_generate_h__
Packit ae9e2a
Packit ae9e2a
enum {
Packit ae9e2a
	GIT_DIFFCAPS_HAS_SYMLINKS     = (1 << 0), /* symlinks on platform? */
Packit ae9e2a
	GIT_DIFFCAPS_IGNORE_STAT      = (1 << 1), /* use stat? */
Packit ae9e2a
	GIT_DIFFCAPS_TRUST_MODE_BITS  = (1 << 2), /* use st_mode? */
Packit ae9e2a
	GIT_DIFFCAPS_TRUST_CTIME      = (1 << 3), /* use st_ctime? */
Packit ae9e2a
	GIT_DIFFCAPS_USE_DEV          = (1 << 4), /* use st_dev? */
Packit ae9e2a
};
Packit ae9e2a
Packit ae9e2a
#define DIFF_FLAGS_KNOWN_BINARY (GIT_DIFF_FLAG_BINARY|GIT_DIFF_FLAG_NOT_BINARY)
Packit ae9e2a
#define DIFF_FLAGS_NOT_BINARY   (GIT_DIFF_FLAG_NOT_BINARY|GIT_DIFF_FLAG__NO_DATA)
Packit ae9e2a
Packit ae9e2a
enum {
Packit ae9e2a
	GIT_DIFF_FLAG__FREE_PATH  = (1 << 7),  /* `path` is allocated memory */
Packit ae9e2a
	GIT_DIFF_FLAG__FREE_DATA  = (1 << 8),  /* internal file data is allocated */
Packit ae9e2a
	GIT_DIFF_FLAG__UNMAP_DATA = (1 << 9),  /* internal file data is mmap'ed */
Packit ae9e2a
	GIT_DIFF_FLAG__NO_DATA    = (1 << 10), /* file data should not be loaded */
Packit ae9e2a
	GIT_DIFF_FLAG__FREE_BLOB  = (1 << 11), /* release the blob when done */
Packit ae9e2a
	GIT_DIFF_FLAG__LOADED     = (1 << 12), /* file data has been loaded */
Packit ae9e2a
Packit ae9e2a
	GIT_DIFF_FLAG__TO_DELETE  = (1 << 16), /* delete entry during rename det. */
Packit ae9e2a
	GIT_DIFF_FLAG__TO_SPLIT   = (1 << 17), /* split entry during rename det. */
Packit ae9e2a
	GIT_DIFF_FLAG__IS_RENAME_TARGET = (1 << 18),
Packit ae9e2a
	GIT_DIFF_FLAG__IS_RENAME_SOURCE = (1 << 19),
Packit ae9e2a
	GIT_DIFF_FLAG__HAS_SELF_SIMILARITY = (1 << 20),
Packit ae9e2a
};
Packit ae9e2a
Packit ae9e2a
#define GIT_DIFF_FLAG__CLEAR_INTERNAL(F) (F) = ((F) & 0x00FFFF)
Packit ae9e2a
Packit ae9e2a
#define GIT_DIFF__VERBOSE  (1 << 30)
Packit ae9e2a
Packit ae9e2a
extern void git_diff_addref(git_diff *diff);
Packit ae9e2a
Packit ae9e2a
extern bool git_diff_delta__should_skip(
Packit ae9e2a
	const git_diff_options *opts, const git_diff_delta *delta);
Packit ae9e2a
Packit ae9e2a
extern int git_diff__from_iterators(
Packit ae9e2a
	git_diff **diff_ptr,
Packit ae9e2a
	git_repository *repo,
Packit ae9e2a
	git_iterator *old_iter,
Packit ae9e2a
	git_iterator *new_iter,
Packit ae9e2a
	const git_diff_options *opts);
Packit ae9e2a
Packit ae9e2a
extern int git_diff__commit(
Packit ae9e2a
	git_diff **diff, git_repository *repo, const git_commit *commit, const git_diff_options *opts);
Packit ae9e2a
Packit ae9e2a
extern int git_diff__paired_foreach(
Packit ae9e2a
	git_diff *idx2head,
Packit ae9e2a
	git_diff *wd2idx,
Packit ae9e2a
	int (*cb)(git_diff_delta *i2h, git_diff_delta *w2i, void *payload),
Packit ae9e2a
	void *payload);
Packit ae9e2a
Packit ae9e2a
/* Merge two `git_diff`s according to the callback given by `cb`. */
Packit ae9e2a
Packit ae9e2a
typedef git_diff_delta *(*git_diff__merge_cb)(
Packit ae9e2a
	const git_diff_delta *left,
Packit ae9e2a
	const git_diff_delta *right,
Packit ae9e2a
	git_pool *pool);
Packit ae9e2a
Packit ae9e2a
extern int git_diff__merge(
Packit ae9e2a
	git_diff *onto, const git_diff *from, git_diff__merge_cb cb);
Packit ae9e2a
Packit ae9e2a
extern git_diff_delta *git_diff__merge_like_cgit(
Packit ae9e2a
	const git_diff_delta *a,
Packit ae9e2a
	const git_diff_delta *b,
Packit ae9e2a
	git_pool *pool);
Packit ae9e2a
Packit ae9e2a
/* Duplicate a `git_diff_delta` out of the `git_pool` */
Packit ae9e2a
extern git_diff_delta *git_diff__delta_dup(
Packit ae9e2a
	const git_diff_delta *d, git_pool *pool);
Packit ae9e2a
Packit ae9e2a
extern int git_diff__oid_for_file(
Packit ae9e2a
	git_oid *out,
Packit ae9e2a
	git_diff *diff,
Packit ae9e2a
	const char *path,
Packit ae9e2a
	uint16_t mode,
Packit ae9e2a
	git_off_t size);
Packit ae9e2a
Packit ae9e2a
extern int git_diff__oid_for_entry(
Packit ae9e2a
	git_oid *out,
Packit ae9e2a
	git_diff *diff,
Packit ae9e2a
	const git_index_entry *src,
Packit ae9e2a
	uint16_t mode,
Packit ae9e2a
	const git_oid *update_match);
Packit ae9e2a
Packit ae9e2a
/*
Packit ae9e2a
 * Sometimes a git_diff_file will have a zero size; this attempts to
Packit ae9e2a
 * fill in the size without loading the blob if possible.  If that is
Packit ae9e2a
 * not possible, then it will return the git_odb_object that had to be
Packit ae9e2a
 * loaded and the caller can use it or dispose of it as needed.
Packit ae9e2a
 */
Packit ae9e2a
GIT_INLINE(int) git_diff_file__resolve_zero_size(
Packit ae9e2a
	git_diff_file *file, git_odb_object **odb_obj, git_repository *repo)
Packit ae9e2a
{
Packit ae9e2a
	int error;
Packit ae9e2a
	git_odb *odb;
Packit ae9e2a
	size_t len;
Packit ae9e2a
	git_otype type;
Packit ae9e2a
Packit ae9e2a
	if ((error = git_repository_odb(&odb, repo)) < 0)
Packit ae9e2a
		return error;
Packit ae9e2a
Packit ae9e2a
	error = git_odb__read_header_or_object(
Packit ae9e2a
		odb_obj, &len, &type, odb, &file->id);
Packit ae9e2a
Packit ae9e2a
	git_odb_free(odb);
Packit ae9e2a
Packit ae9e2a
	if (!error)
Packit ae9e2a
		file->size = (git_off_t)len;
Packit ae9e2a
Packit ae9e2a
	return error;
Packit ae9e2a
}
Packit ae9e2a
Packit ae9e2a
#endif
Packit ae9e2a