diff.h 1.67 KB
Newer Older
1
/*
Edward Thomson committed
2
 * Copyright (C) the libgit2 contributors. All rights reserved.
3 4 5 6 7 8 9
 *
 * This file is part of libgit2, distributed under the GNU GPL v2 with
 * a Linking Exception. For full terms see the included COPYING file.
 */
#ifndef INCLUDE_diff_h__
#define INCLUDE_diff_h__

10 11
#include "common.h"

12
#include "git2/diff.h"
13
#include "git2/patch.h"
14
#include "git2/sys/diff.h"
15 16
#include "git2/oid.h"

17
#include "vector.h"
18 19
#include "iterator.h"
#include "repository.h"
20
#include "pool.h"
21
#include "odb.h"
22

23 24
#define DIFF_OLD_PREFIX_DEFAULT "a/"
#define DIFF_NEW_PREFIX_DEFAULT "b/"
25

26 27 28
typedef enum {
	GIT_DIFF_TYPE_UNKNOWN = 0,
	GIT_DIFF_TYPE_GENERATED = 1,
29
	GIT_DIFF_TYPE_PARSED = 2
30
} git_diff_origin_t;
31

32
struct git_diff {
Russell Belfer committed
33
	git_refcount     rc;
34
	git_repository   *repo;
35
	git_attr_session attrsession;
36
	git_diff_origin_t type;
37
	git_diff_options opts;
Russell Belfer committed
38
	git_vector       deltas;    /* vector of git_diff_delta */
39
	git_pool pool;
40 41
	git_iterator_t old_src;
	git_iterator_t new_src;
42
	git_diff_perfdata perf;
43

44 45 46 47
	int (*strcomp)(const char *, const char *);
	int (*strncomp)(const char *, const char *, size_t);
	int (*pfxcomp)(const char *str, const char *pfx);
	int (*entrycomp)(const void *a, const void *b);
48

49
	int (*patch_fn)(git_patch **out, git_diff *diff, size_t idx);
50 51
	void (*free_fn)(git_diff *diff);
};
52

53
extern int git_diff_delta__format_file_header(
54
	git_str *out,
55 56 57
	const git_diff_delta *delta,
	const char *oldpfx,
	const char *newpfx,
58 59
	int oid_strlen,
	bool print_index);
60

61 62
extern int git_diff_delta__cmp(const void *a, const void *b);
extern int git_diff_delta__casecmp(const void *a, const void *b);
63

64 65 66
extern int git_diff__entry_cmp(const void *a, const void *b);
extern int git_diff__entry_icmp(const void *a, const void *b);

67
#endif