]> git.proxmox.com Git - libgit2.git/blob - src/diff.h
Merge branch 'arrbee/examples-log' into development
[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/oid.h"
12
13 #include <stdio.h>
14 #include "vector.h"
15 #include "buffer.h"
16 #include "iterator.h"
17 #include "repository.h"
18 #include "pool.h"
19
20 #define DIFF_OLD_PREFIX_DEFAULT "a/"
21 #define DIFF_NEW_PREFIX_DEFAULT "b/"
22
23 enum {
24 GIT_DIFFCAPS_HAS_SYMLINKS = (1 << 0), /* symlinks on platform? */
25 GIT_DIFFCAPS_ASSUME_UNCHANGED = (1 << 1), /* use stat? */
26 GIT_DIFFCAPS_TRUST_MODE_BITS = (1 << 2), /* use st_mode? */
27 GIT_DIFFCAPS_TRUST_CTIME = (1 << 3), /* use st_ctime? */
28 GIT_DIFFCAPS_USE_DEV = (1 << 4), /* use st_dev? */
29 GIT_DIFFCAPS_TRUST_NANOSECS = (1 << 5), /* use stat time nanoseconds */
30 };
31
32 #define DIFF_FLAGS_KNOWN_BINARY (GIT_DIFF_FLAG_BINARY|GIT_DIFF_FLAG_NOT_BINARY)
33 #define DIFF_FLAGS_NOT_BINARY (GIT_DIFF_FLAG_NOT_BINARY|GIT_DIFF_FLAG__NO_DATA)
34
35 enum {
36 GIT_DIFF_FLAG__FREE_PATH = (1 << 7), /* `path` is allocated memory */
37 GIT_DIFF_FLAG__FREE_DATA = (1 << 8), /* internal file data is allocated */
38 GIT_DIFF_FLAG__UNMAP_DATA = (1 << 9), /* internal file data is mmap'ed */
39 GIT_DIFF_FLAG__NO_DATA = (1 << 10), /* file data should not be loaded */
40 GIT_DIFF_FLAG__FREE_BLOB = (1 << 11), /* release the blob when done */
41 GIT_DIFF_FLAG__LOADED = (1 << 12), /* file data has been loaded */
42
43 GIT_DIFF_FLAG__TO_DELETE = (1 << 16), /* delete entry during rename det. */
44 GIT_DIFF_FLAG__TO_SPLIT = (1 << 17), /* split entry during rename det. */
45 GIT_DIFF_FLAG__IS_RENAME_TARGET = (1 << 18),
46 GIT_DIFF_FLAG__IS_RENAME_SOURCE = (1 << 19),
47 GIT_DIFF_FLAG__HAS_SELF_SIMILARITY = (1 << 20),
48 };
49
50 #define GIT_DIFF_FLAG__CLEAR_INTERNAL(F) (F) = ((F) & 0x00FFFF)
51
52 #define GIT_DIFF__VERBOSE (1 << 30)
53
54 struct git_diff_list {
55 git_refcount rc;
56 git_repository *repo;
57 git_diff_options opts;
58 git_vector pathspec;
59 git_vector deltas; /* vector of git_diff_delta */
60 git_pool pool;
61 git_iterator_type_t old_src;
62 git_iterator_type_t new_src;
63 uint32_t diffcaps;
64
65 int (*strcomp)(const char *, const char *);
66 int (*strncomp)(const char *, const char *, size_t);
67 int (*pfxcomp)(const char *str, const char *pfx);
68 int (*entrycomp)(const void *a, const void *b);
69 };
70
71 extern void git_diff__cleanup_modes(
72 uint32_t diffcaps, uint32_t *omode, uint32_t *nmode);
73
74 extern void git_diff_list_addref(git_diff_list *diff);
75
76 extern int git_diff_delta__cmp(const void *a, const void *b);
77 extern int git_diff_delta__casecmp(const void *a, const void *b);
78
79 extern const char *git_diff_delta__path(const git_diff_delta *delta);
80
81 extern bool git_diff_delta__should_skip(
82 const git_diff_options *opts, const git_diff_delta *delta);
83
84 extern int git_diff__oid_for_file(
85 git_repository *, const char *, uint16_t, git_off_t, git_oid *);
86
87 extern int git_diff__from_iterators(
88 git_diff_list **diff_ptr,
89 git_repository *repo,
90 git_iterator *old_iter,
91 git_iterator *new_iter,
92 const git_diff_options *opts);
93
94 extern int git_diff__paired_foreach(
95 git_diff_list *idx2head,
96 git_diff_list *wd2idx,
97 int (*cb)(git_diff_delta *i2h, git_diff_delta *w2i, void *payload),
98 void *payload);
99
100 extern int git_diff_find_similar__hashsig_for_file(
101 void **out, const git_diff_file *f, const char *path, void *p);
102
103 extern int git_diff_find_similar__hashsig_for_buf(
104 void **out, const git_diff_file *f, const char *buf, size_t len, void *p);
105
106 extern void git_diff_find_similar__hashsig_free(void *sig, void *payload);
107
108 extern int git_diff_find_similar__calc_similarity(
109 int *score, void *siga, void *sigb, void *payload);
110
111 #endif
112