Blame include/git2/sys/diff.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_sys_git_diff_h__
Packit Service 20376f
#define INCLUDE_sys_git_diff_h__
Packit Service 20376f
Packit Service 20376f
#include "git2/common.h"
Packit Service 20376f
#include "git2/types.h"
Packit Service 20376f
#include "git2/oid.h"
Packit Service 20376f
#include "git2/diff.h"
Packit Service 20376f
#include "git2/status.h"
Packit Service 20376f
Packit Service 20376f
/**
Packit Service 20376f
 * @file git2/sys/diff.h
Packit Service 20376f
 * @brief Low-level Git diff utilities
Packit Service 20376f
 * @ingroup Git
Packit Service 20376f
 * @{
Packit Service 20376f
 */
Packit Service 20376f
GIT_BEGIN_DECL
Packit Service 20376f
Packit Service 20376f
/**
Packit Service 20376f
 * Diff print callback that writes to a git_buf.
Packit Service 20376f
 *
Packit Service 20376f
 * This function is provided not for you to call it directly, but instead
Packit Service 20376f
 * so you can use it as a function pointer to the `git_diff_print` or
Packit Service 20376f
 * `git_patch_print` APIs.  When using those APIs, you specify a callback
Packit Service 20376f
 * to actually handle the diff and/or patch data.
Packit Service 20376f
 *
Packit Service 20376f
 * Use this callback to easily write that data to a `git_buf` buffer.  You
Packit Service 20376f
 * must pass a `git_buf *` value as the payload to the `git_diff_print`
Packit Service 20376f
 * and/or `git_patch_print` function.  The data will be appended to the
Packit Service 20376f
 * buffer (after any existing content).
Packit Service 20376f
 */
Packit Service 20376f
GIT_EXTERN(int) git_diff_print_callback__to_buf(
Packit Service 20376f
	const git_diff_delta *delta,
Packit Service 20376f
	const git_diff_hunk *hunk,
Packit Service 20376f
	const git_diff_line *line,
Packit Service 20376f
	void *payload); /**< payload must be a `git_buf *` */
Packit Service 20376f
Packit Service 20376f
/**
Packit Service 20376f
 * Diff print callback that writes to stdio FILE handle.
Packit Service 20376f
 *
Packit Service 20376f
 * This function is provided not for you to call it directly, but instead
Packit Service 20376f
 * so you can use it as a function pointer to the `git_diff_print` or
Packit Service 20376f
 * `git_patch_print` APIs.  When using those APIs, you specify a callback
Packit Service 20376f
 * to actually handle the diff and/or patch data.
Packit Service 20376f
 *
Packit Service 20376f
 * Use this callback to easily write that data to a stdio FILE handle.  You
Packit Service 20376f
 * must pass a `FILE *` value (such as `stdout` or `stderr` or the return
Packit Service 20376f
 * value from `fopen()`) as the payload to the `git_diff_print`
Packit Service 20376f
 * and/or `git_patch_print` function.  If you pass NULL, this will write
Packit Service 20376f
 * data to `stdout`.
Packit Service 20376f
 */
Packit Service 20376f
GIT_EXTERN(int) git_diff_print_callback__to_file_handle(
Packit Service 20376f
	const git_diff_delta *delta,
Packit Service 20376f
	const git_diff_hunk *hunk,
Packit Service 20376f
	const git_diff_line *line,
Packit Service 20376f
	void *payload); /**< payload must be a `FILE *` */
Packit Service 20376f
Packit Service 20376f
Packit Service 20376f
/**
Packit Service 20376f
 * Performance data from diffing
Packit Service 20376f
 */
Packit Service 20376f
typedef struct {
Packit Service 20376f
	unsigned int version;
Packit Service 20376f
	size_t stat_calls; /**< Number of stat() calls performed */
Packit Service 20376f
	size_t oid_calculations; /**< Number of ID calculations */
Packit Service 20376f
} git_diff_perfdata;
Packit Service 20376f
Packit Service 20376f
#define GIT_DIFF_PERFDATA_VERSION 1
Packit Service 20376f
#define GIT_DIFF_PERFDATA_INIT {GIT_DIFF_PERFDATA_VERSION,0,0}
Packit Service 20376f
Packit Service 20376f
/**
Packit Service 20376f
 * Get performance data for a diff object.
Packit Service 20376f
 *
Packit Service 20376f
 * @param out Structure to be filled with diff performance data
Packit Service 20376f
 * @param diff Diff to read performance data from
Packit Service 20376f
 * @return 0 for success, <0 for error
Packit Service 20376f
 */
Packit Service 20376f
GIT_EXTERN(int) git_diff_get_perfdata(
Packit Service 20376f
	git_diff_perfdata *out, const git_diff *diff);
Packit Service 20376f
Packit Service 20376f
/**
Packit Service 20376f
 * Get performance data for diffs from a git_status_list
Packit Service 20376f
 */
Packit Service 20376f
GIT_EXTERN(int) git_status_list_get_perfdata(
Packit Service 20376f
	git_diff_perfdata *out, const git_status_list *status);
Packit Service 20376f
Packit Service 20376f
/** @} */
Packit Service 20376f
GIT_END_DECL
Packit Service 20376f
#endif