diff.h 1.7 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 18 19
#include <stdio.h>
#include "vector.h"
#include "buffer.h"
20 21
#include "iterator.h"
#include "repository.h"
22
#include "pool.h"
23
#include "odb.h"
24

25 26
#define DIFF_OLD_PREFIX_DEFAULT "a/"
#define DIFF_NEW_PREFIX_DEFAULT "b/"
27

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

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

46 47 48 49
	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);
50

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

55 56 57 58 59 60 61
extern int git_diff_delta__format_file_header(
	git_buf *out,
	const git_diff_delta *delta,
	const char *oldpfx,
	const char *newpfx,
	int oid_strlen);

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

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

68
#endif