1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
|
/*
* Copyright (C) 2009-2012 the libgit2 contributors
*
* 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_git_diff_h__
#define INCLUDE_git_diff_h__
#include "common.h"
#include "types.h"
#include "oid.h"
#include "tree.h"
#include "refs.h"
/**
* @file git2/diff.h
* @brief Git tree and file differencing routines.
* @ingroup Git
* @{
*/
GIT_BEGIN_DECL
typedef int (*git_diff_file_fn)(
void *cb_data,
const git_oid *old,
const char *old_path,
int old_mode,
const git_oid *new, /* hashed object if from work tree */
const char *new_path,
int new_mode);
typedef int (*git_diff_hunk_fn)(
void *cb_data,
int old_start,
int old_lines,
int new_start,
int new_lines);
#define GIT_DIFF_LINE_CONTEXT 0
#define GIT_DIFF_LINE_ADDITION 1
#define GIT_DIFF_LINE_DELETION 2
typedef int (*git_diff_line_fn)(
void *cb_data,
int origin, /* GIT_DIFF_LINE value from above */
const char *content,
size_t content_len);
typedef struct {
int context_lines;
int interhunk_lines;
int ignore_whitespace;
git_diff_file_fn file_cb;
git_diff_hunk_fn hunk_cb;
git_diff_line_fn line_cb;
void *cb_data;
} git_diff_opts;
GIT_EXTERN(int) git_diff_blobs(
git_repository *repo,
git_blob *old,
git_blob *new,
git_diff_opts *options);
GIT_EXTERN(int) git_diff_trees(
git_repository *repo,
git_tree *old,
git_tree *new,
git_diff_opts *options);
GIT_EXTERN(int) git_diff_index(
git_repository *repo,
git_tree *old,
git_diff_opts *options);
/* pass NULL for the git_tree to diff workdir against index */
GIT_EXTERN(int) git_diff_workdir(
git_repository *repo,
git_tree *old,
git_diff_opts *options);
GIT_EXTERN(int) git_diff_workdir_file(
git_repository *repo,
git_blob *old,
const char *path,
git_diff_opts *options);
/* pass git_objects to diff against or NULL for index.
* can handle: blob->blob, tree->index, tree->tree
* it will be an error if object types don't match
*/
/* pass git_object to diff WT against or NULL for index
* can handle: index->wt, tree->wt, blob->wt with path
*/
GIT_END_DECL
/** @} */
#endif
|