]> git.proxmox.com Git - libgit2.git/blob - src/diff.h
introduce `git_diff_from_buffer` to parse diffs
[libgit2.git] / src / diff.h
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_diff_h__
8 #define INCLUDE_diff_h__
9
10 #include "git2/diff.h"
11 #include "git2/sys/diff.h"
12 #include "git2/oid.h"
13
14 #include <stdio.h>
15 #include "vector.h"
16 #include "buffer.h"
17 #include "iterator.h"
18 #include "repository.h"
19 #include "pool.h"
20 #include "odb.h"
21
22 #define DIFF_OLD_PREFIX_DEFAULT "a/"
23 #define DIFF_NEW_PREFIX_DEFAULT "b/"
24
25 typedef enum {
26 GIT_DIFF_TYPE_UNKNOWN = 0,
27 GIT_DIFF_TYPE_GENERATED = 1,
28 GIT_DIFF_TYPE_PARSED = 2,
29 } git_diff_origin_t;
30
31 struct git_diff {
32 git_refcount rc;
33 git_repository *repo;
34 git_diff_origin_t type;
35 git_diff_options opts;
36 git_vector deltas; /* vector of git_diff_delta */
37 git_pool pool;
38 git_iterator_type_t old_src;
39 git_iterator_type_t new_src;
40 git_diff_perfdata perf;
41
42 int (*strcomp)(const char *, const char *);
43 int (*strncomp)(const char *, const char *, size_t);
44 int (*pfxcomp)(const char *str, const char *pfx);
45 int (*entrycomp)(const void *a, const void *b);
46
47 void (*free_fn)(git_diff *diff);
48 };
49
50 extern int git_diff_delta__format_file_header(
51 git_buf *out,
52 const git_diff_delta *delta,
53 const char *oldpfx,
54 const char *newpfx,
55 int oid_strlen);
56
57 extern int git_diff_delta__cmp(const void *a, const void *b);
58 extern int git_diff_delta__casecmp(const void *a, const void *b);
59
60 extern int git_diff__entry_cmp(const void *a, const void *b);
61 extern int git_diff__entry_icmp(const void *a, const void *b);
62
63 #endif
64