]> git.proxmox.com Git - libgit2.git/blame - src/patch.h
Drop patch as it is merged upstream
[libgit2.git] / src / patch.h
CommitLineData
804d5fe9
ET
1/*
2* Copyright (C) the libgit2 contributors. All rights reserved.
3*
4* This file is part of libgit2, distributed under the GNU GPL v2 with
5* a Linking Exception. For full terms see the included COPYING file.
6*/
7#ifndef INCLUDE_patch_h__
8#define INCLUDE_patch_h__
9
eae0bfdc
PP
10#include "common.h"
11
804d5fe9
ET
12#include "git2/patch.h"
13#include "array.h"
14
15/* cached information about a hunk in a patch */
16typedef struct git_patch_hunk {
17 git_diff_hunk hunk;
18 size_t line_start;
19 size_t line_count;
20} git_patch_hunk;
21
22struct git_patch {
23 git_refcount rc;
24
25 git_repository *repo; /* may be null */
26
27 git_diff_options diff_opts;
28
29 git_diff_delta *delta;
30 git_diff_binary binary;
31 git_array_t(git_patch_hunk) hunks;
32 git_array_t(git_diff_line) lines;
33
34 size_t header_size;
35 size_t content_size;
36 size_t context_size;
37
804d5fe9
ET
38 void (*free_fn)(git_patch *patch);
39};
40
41extern int git_patch__invoke_callbacks(
42 git_patch *patch,
43 git_diff_file_cb file_cb,
44 git_diff_binary_cb binary_cb,
45 git_diff_hunk_cb hunk_cb,
46 git_diff_line_cb line_cb,
47 void *payload);
48
49extern int git_patch_line_stats(
50 size_t *total_ctxt,
51 size_t *total_adds,
52 size_t *total_dels,
53 const git_patch *patch);
54
440e3bae
ET
55/** Options for parsing patch files. */
56typedef struct {
57 /**
58 * The length of the prefix (in path segments) for the filenames.
59 * This prefix will be removed when looking for files. The default is 1.
60 */
61 uint32_t prefix_len;
62} git_patch_options;
63
64#define GIT_PATCH_OPTIONS_INIT { 1 }
65
804d5fe9
ET
66extern void git_patch_free(git_patch *patch);
67
68#endif