]> git.proxmox.com Git - libgit2.git/blame - src/patch_generate.h
Upload to experimental
[libgit2.git] / src / patch_generate.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 */
8d44f8b7
ET
7#ifndef INCLUDE_patch_generate_h__
8#define INCLUDE_patch_generate_h__
804d5fe9
ET
9
10#include "common.h"
eae0bfdc 11
804d5fe9
ET
12#include "diff.h"
13#include "diff_file.h"
14#include "patch.h"
15
16enum {
8d44f8b7
ET
17 GIT_PATCH_GENERATED_ALLOCATED = (1 << 0),
18 GIT_PATCH_GENERATED_INITIALIZED = (1 << 1),
19 GIT_PATCH_GENERATED_LOADED = (1 << 2),
804d5fe9 20 /* the two sides are different */
8d44f8b7 21 GIT_PATCH_GENERATED_DIFFABLE = (1 << 3),
804d5fe9 22 /* the difference between the two sides has been computed */
8d44f8b7 23 GIT_PATCH_GENERATED_DIFFED = (1 << 4),
e579e0f7 24 GIT_PATCH_GENERATED_FLATTENED = (1 << 5)
804d5fe9
ET
25};
26
8d44f8b7 27struct git_patch_generated {
804d5fe9
ET
28 struct git_patch base;
29
30 git_diff *diff; /* for refcount purposes, maybe NULL for blob diffs */
31 size_t delta_index;
32 git_diff_file_content ofile;
33 git_diff_file_content nfile;
34 uint32_t flags;
35 git_pool flattened;
36};
37
8d44f8b7 38typedef struct git_patch_generated git_patch_generated;
804d5fe9 39
8d44f8b7 40extern git_diff_driver *git_patch_generated_driver(git_patch_generated *);
804d5fe9 41
e579e0f7
MB
42extern int git_patch_generated_old_data(
43 char **, long *, git_patch_generated *);
44extern int git_patch_generated_new_data(
45 char **, long *, git_patch_generated *);
b859faa6
ET
46extern int git_patch_generated_from_diff(
47 git_patch **, git_diff *, size_t);
804d5fe9 48
8d44f8b7 49typedef struct git_patch_generated_output git_patch_generated_output;
804d5fe9 50
8d44f8b7 51struct git_patch_generated_output {
804d5fe9
ET
52 /* these callbacks are issued with the diff data */
53 git_diff_file_cb file_cb;
54 git_diff_binary_cb binary_cb;
55 git_diff_hunk_cb hunk_cb;
56 git_diff_line_cb data_cb;
57 void *payload;
58
59 /* this records the actual error in cases where it may be obscured */
60 int error;
61
62 /* this callback is used to do the diff and drive the other callbacks.
63 * see diff_xdiff.h for how to use this in practice for now.
64 */
8d44f8b7
ET
65 int (*diff_cb)(git_patch_generated_output *output,
66 git_patch_generated *patch);
804d5fe9
ET
67};
68
69#endif