Blame src/diff_generate.h

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