rugged 0.17.0.b6 → 0.17.0.b7
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +3 -3
- data/Rakefile +3 -1
- data/ext/rugged/rugged.c +30 -0
- data/ext/rugged/rugged.h +9 -0
- data/ext/rugged/rugged_branch.c +306 -0
- data/ext/rugged/rugged_config.c +16 -13
- data/ext/rugged/rugged_index.c +25 -0
- data/ext/rugged/rugged_object.c +6 -2
- data/ext/rugged/rugged_reference.c +11 -18
- data/ext/rugged/rugged_revwalk.c +1 -1
- data/lib/rugged.rb +1 -0
- data/lib/rugged/branch.rb +28 -0
- data/lib/rugged/commit.rb +5 -5
- data/lib/rugged/repository.rb +32 -7
- data/lib/rugged/tag.rb +5 -1
- data/lib/rugged/version.rb +1 -1
- data/test/branch_test.rb +227 -0
- data/test/config_test.rb +1 -1
- data/test/fixtures/testrepo.git/objects/4b/825dc642cb6eb9a060e54bf8d69288fbee4904 +0 -0
- data/test/fixtures/testrepo.git/objects/a3/e05719b428a2d0ed7a55c4ce53dcc5768c6d5e +0 -0
- data/test/index_test.rb +31 -0
- data/test/index_test.rb~ +218 -0
- data/test/lib_test.rb +22 -0
- data/test/reference_test.rb +5 -3
- data/vendor/libgit2/Makefile.embed +1 -1
- data/vendor/libgit2/include/git2.h +1 -0
- data/vendor/libgit2/include/git2/branch.h +17 -13
- data/vendor/libgit2/include/git2/checkout.h +83 -22
- data/vendor/libgit2/include/git2/clone.h +6 -3
- data/vendor/libgit2/include/git2/common.h +1 -8
- data/vendor/libgit2/include/git2/config.h +185 -26
- data/vendor/libgit2/include/git2/diff.h +229 -17
- data/vendor/libgit2/include/git2/errors.h +39 -1
- data/vendor/libgit2/include/git2/ignore.h +6 -3
- data/vendor/libgit2/include/git2/indexer.h +1 -0
- data/vendor/libgit2/include/git2/merge.h +1 -1
- data/vendor/libgit2/include/git2/object.h +7 -4
- data/vendor/libgit2/include/git2/odb.h +4 -2
- data/vendor/libgit2/include/git2/odb_backend.h +6 -0
- data/vendor/libgit2/include/git2/oid.h +2 -0
- data/vendor/libgit2/include/git2/pack.h +89 -0
- data/vendor/libgit2/include/git2/refs.h +88 -0
- data/vendor/libgit2/include/git2/refspec.h +0 -8
- data/vendor/libgit2/include/git2/remote.h +34 -1
- data/vendor/libgit2/include/git2/repository.h +238 -6
- data/vendor/libgit2/include/git2/reset.h +4 -1
- data/vendor/libgit2/include/git2/revwalk.h +1 -1
- data/vendor/libgit2/include/git2/status.h +19 -14
- data/vendor/libgit2/include/git2/strarray.h +54 -0
- data/vendor/libgit2/include/git2/submodule.h +451 -45
- data/vendor/libgit2/include/git2/tag.h +16 -0
- data/vendor/libgit2/include/git2/tree.h +2 -2
- data/vendor/libgit2/include/git2/types.h +4 -0
- data/vendor/libgit2/src/amiga/map.c +4 -7
- data/vendor/libgit2/src/attr.c +21 -13
- data/vendor/libgit2/src/attr.h +3 -1
- data/vendor/libgit2/src/attr_file.c +14 -14
- data/vendor/libgit2/src/attr_file.h +6 -5
- data/vendor/libgit2/src/blob.c +22 -12
- data/vendor/libgit2/src/branch.c +62 -66
- data/vendor/libgit2/src/buffer.c +63 -14
- data/vendor/libgit2/src/buffer.h +4 -0
- data/vendor/libgit2/src/cache.c +5 -4
- data/vendor/libgit2/src/checkout.c +381 -159
- data/vendor/libgit2/src/clone.c +221 -94
- data/vendor/libgit2/src/common.h +13 -3
- data/vendor/libgit2/src/compress.c +53 -0
- data/vendor/libgit2/src/compress.h +16 -0
- data/vendor/libgit2/src/config.c +380 -175
- data/vendor/libgit2/src/config.h +2 -5
- data/vendor/libgit2/src/config_file.c +63 -46
- data/vendor/libgit2/src/config_file.h +16 -4
- data/vendor/libgit2/src/crlf.c +4 -3
- data/vendor/libgit2/src/delta.c +491 -0
- data/vendor/libgit2/src/delta.h +112 -0
- data/vendor/libgit2/src/diff.c +310 -67
- data/vendor/libgit2/src/diff.h +10 -1
- data/vendor/libgit2/src/diff_output.c +1030 -337
- data/vendor/libgit2/src/diff_output.h +86 -0
- data/vendor/libgit2/src/errors.c +10 -1
- data/vendor/libgit2/src/fetch.c +108 -24
- data/vendor/libgit2/src/filebuf.c +8 -2
- data/vendor/libgit2/src/fileops.c +342 -177
- data/vendor/libgit2/src/fileops.h +84 -7
- data/vendor/libgit2/src/filter.c +0 -35
- data/vendor/libgit2/src/filter.h +0 -12
- data/vendor/libgit2/src/{compat/fnmatch.c → fnmatch.c} +16 -4
- data/vendor/libgit2/src/{compat/fnmatch.h → fnmatch.h} +4 -3
- data/vendor/libgit2/src/global.c +4 -0
- data/vendor/libgit2/src/ignore.c +122 -23
- data/vendor/libgit2/src/ignore.h +1 -0
- data/vendor/libgit2/src/index.c +56 -10
- data/vendor/libgit2/src/index.h +2 -0
- data/vendor/libgit2/src/indexer.c +8 -9
- data/vendor/libgit2/src/iterator.c +244 -31
- data/vendor/libgit2/src/iterator.h +30 -1
- data/vendor/libgit2/src/message.c +1 -1
- data/vendor/libgit2/src/netops.c +44 -4
- data/vendor/libgit2/src/object.c +80 -69
- data/vendor/libgit2/src/object.h +39 -0
- data/vendor/libgit2/src/odb.c +79 -15
- data/vendor/libgit2/src/odb.h +20 -5
- data/vendor/libgit2/src/odb_pack.c +65 -33
- data/vendor/libgit2/src/oid.c +0 -3
- data/vendor/libgit2/src/pack-objects.c +1315 -0
- data/vendor/libgit2/src/pack-objects.h +87 -0
- data/vendor/libgit2/src/pack.c +36 -12
- data/vendor/libgit2/src/pack.h +1 -0
- data/vendor/libgit2/src/path.c +42 -9
- data/vendor/libgit2/src/path.h +14 -0
- data/vendor/libgit2/src/pkt.c +52 -2
- data/vendor/libgit2/src/pkt.h +10 -0
- data/vendor/libgit2/src/pool.h +11 -0
- data/vendor/libgit2/src/posix.h +8 -0
- data/vendor/libgit2/src/protocol.c +24 -2
- data/vendor/libgit2/src/protocol.h +4 -0
- data/vendor/libgit2/src/reflog.c +1 -1
- data/vendor/libgit2/src/refs.c +292 -124
- data/vendor/libgit2/src/refs.h +4 -2
- data/vendor/libgit2/src/refspec.c +117 -19
- data/vendor/libgit2/src/refspec.h +19 -0
- data/vendor/libgit2/src/remote.c +152 -48
- data/vendor/libgit2/src/remote.h +4 -1
- data/vendor/libgit2/src/repo_template.h +58 -0
- data/vendor/libgit2/src/repository.c +594 -179
- data/vendor/libgit2/src/repository.h +23 -22
- data/vendor/libgit2/src/reset.c +71 -29
- data/vendor/libgit2/src/revparse.c +26 -17
- data/vendor/libgit2/src/revwalk.c +36 -19
- data/vendor/libgit2/src/sha1.h +7 -0
- data/vendor/libgit2/src/{sha1.c → sha1/sha1.c} +0 -0
- data/vendor/libgit2/src/signature.c +12 -10
- data/vendor/libgit2/src/status.c +52 -6
- data/vendor/libgit2/src/submodule.c +1363 -255
- data/vendor/libgit2/src/submodule.h +102 -0
- data/vendor/libgit2/src/tag.c +42 -26
- data/vendor/libgit2/src/thread-utils.h +7 -7
- data/vendor/libgit2/src/transport.h +15 -1
- data/vendor/libgit2/src/transports/git.c +1 -1
- data/vendor/libgit2/src/transports/http.c +197 -36
- data/vendor/libgit2/src/tree.c +3 -3
- data/vendor/libgit2/src/unix/map.c +2 -0
- data/vendor/libgit2/src/unix/posix.h +1 -8
- data/vendor/libgit2/src/util.c +6 -1
- data/vendor/libgit2/src/util.h +7 -0
- data/vendor/libgit2/src/vector.c +16 -0
- data/vendor/libgit2/src/vector.h +1 -0
- data/vendor/libgit2/src/win32/dir.c +8 -21
- data/vendor/libgit2/src/win32/findfile.c +149 -0
- data/vendor/libgit2/src/win32/findfile.h +23 -0
- data/vendor/libgit2/src/win32/posix.h +3 -7
- data/vendor/libgit2/src/win32/posix_w32.c +44 -102
- data/vendor/libgit2/src/win32/pthread.c +68 -0
- data/vendor/libgit2/src/win32/pthread.h +7 -0
- data/vendor/libgit2/src/win32/utf-conv.c +60 -71
- data/vendor/libgit2/src/win32/utf-conv.h +4 -3
- metadata +70 -71
- data/vendor/libgit2/include/git2/windows.h +0 -59
@@ -29,9 +29,12 @@ GIT_BEGIN_DECL
|
|
29
29
|
* @param out pointer that will receive the resulting repository object
|
30
30
|
* @param origin_url repository to clone from
|
31
31
|
* @param workdir_path local directory to clone to
|
32
|
-
* @param fetch_stats pointer to structure that receives fetch progress
|
33
|
-
*
|
34
|
-
* @
|
32
|
+
* @param fetch_stats pointer to structure that receives fetch progress
|
33
|
+
* information (may be NULL)
|
34
|
+
* @param checkout_opts options for the checkout step. If NULL, no checkout
|
35
|
+
* is performed
|
36
|
+
* @return 0 on success, GIT_ERROR otherwise (use giterr_last for information
|
37
|
+
* about the error)
|
35
38
|
*/
|
36
39
|
GIT_EXTERN(int) git_clone(git_repository **out,
|
37
40
|
const char *origin_url,
|
@@ -85,14 +85,6 @@ GIT_BEGIN_DECL
|
|
85
85
|
*/
|
86
86
|
#define GIT_PATH_MAX 4096
|
87
87
|
|
88
|
-
typedef struct {
|
89
|
-
char **strings;
|
90
|
-
size_t count;
|
91
|
-
} git_strarray;
|
92
|
-
|
93
|
-
GIT_EXTERN(void) git_strarray_free(git_strarray *array);
|
94
|
-
GIT_EXTERN(int) git_strarray_copy(git_strarray *tgt, const git_strarray *src);
|
95
|
-
|
96
88
|
/**
|
97
89
|
* Return the version of the libgit2 library
|
98
90
|
* being currently used.
|
@@ -128,4 +120,5 @@ GIT_EXTERN(int) git_libgit2_capabilities(void);
|
|
128
120
|
|
129
121
|
/** @} */
|
130
122
|
GIT_END_DECL
|
123
|
+
|
131
124
|
#endif
|
@@ -19,6 +19,28 @@
|
|
19
19
|
*/
|
20
20
|
GIT_BEGIN_DECL
|
21
21
|
|
22
|
+
/**
|
23
|
+
* Priority level of a config file.
|
24
|
+
* These priority levels correspond to the natural escalation logic
|
25
|
+
* (from higher to lower) when searching for config entries in git.git.
|
26
|
+
*
|
27
|
+
* git_config_open_default() and git_repository_config() honor those
|
28
|
+
* priority levels as well.
|
29
|
+
*/
|
30
|
+
enum {
|
31
|
+
GIT_CONFIG_LEVEL_SYSTEM = 1, /**< System-wide configuration file. */
|
32
|
+
GIT_CONFIG_LEVEL_XDG = 2, /**< XDG compatible configuration file (.config/git/config). */
|
33
|
+
GIT_CONFIG_LEVEL_GLOBAL = 3, /**< User-specific configuration file, also called Global configuration file. */
|
34
|
+
GIT_CONFIG_LEVEL_LOCAL = 4, /**< Repository specific configuration file. */
|
35
|
+
GIT_CONFIG_HIGHEST_LEVEL = -1, /**< Represents the highest level of a config file. */
|
36
|
+
};
|
37
|
+
|
38
|
+
typedef struct {
|
39
|
+
const char *name;
|
40
|
+
const char *value;
|
41
|
+
unsigned int level;
|
42
|
+
} git_config_entry;
|
43
|
+
|
22
44
|
/**
|
23
45
|
* Generic backend that implements the interface to
|
24
46
|
* access a configuration file
|
@@ -27,13 +49,13 @@ struct git_config_file {
|
|
27
49
|
struct git_config *cfg;
|
28
50
|
|
29
51
|
/* Open means open the file/database and parse if necessary */
|
30
|
-
int (*open)(struct git_config_file
|
31
|
-
int (*get)(struct git_config_file *, const char *key, const
|
32
|
-
int (*get_multivar)(struct git_config_file *, const char *key, const char *regexp, int (*fn)(const
|
52
|
+
int (*open)(struct git_config_file *, unsigned int level);
|
53
|
+
int (*get)(struct git_config_file *, const char *key, const git_config_entry **entry);
|
54
|
+
int (*get_multivar)(struct git_config_file *, const char *key, const char *regexp, int (*fn)(const git_config_entry *, void *), void *data);
|
33
55
|
int (*set)(struct git_config_file *, const char *key, const char *value);
|
34
56
|
int (*set_multivar)(git_config_file *cfg, const char *name, const char *regexp, const char *value);
|
35
57
|
int (*del)(struct git_config_file *, const char *key);
|
36
|
-
int (*foreach)(struct git_config_file *, const char *, int (*fn)(const
|
58
|
+
int (*foreach)(struct git_config_file *, const char *, int (*fn)(const git_config_entry *, void *), void *data);
|
37
59
|
void (*free)(struct git_config_file *);
|
38
60
|
};
|
39
61
|
|
@@ -61,12 +83,32 @@ typedef struct {
|
|
61
83
|
* may be used on any `git_config` call to load the
|
62
84
|
* global configuration file.
|
63
85
|
*
|
86
|
+
* This method will not guess the path to the xdg compatible
|
87
|
+
* config file (.config/git/config).
|
88
|
+
*
|
64
89
|
* @param global_config_path Buffer of GIT_PATH_MAX length to store the path
|
65
90
|
* @return 0 if a global configuration file has been
|
66
91
|
* found. Its path will be stored in `buffer`.
|
67
92
|
*/
|
68
93
|
GIT_EXTERN(int) git_config_find_global(char *global_config_path, size_t length);
|
69
94
|
|
95
|
+
/**
|
96
|
+
* Locate the path to the global xdg compatible configuration file
|
97
|
+
*
|
98
|
+
* The xdg compatible configuration file is usually
|
99
|
+
* located in `$HOME/.config/git/config`.
|
100
|
+
*
|
101
|
+
* This method will try to guess the full path to that
|
102
|
+
* file, if the file exists. The returned path
|
103
|
+
* may be used on any `git_config` call to load the
|
104
|
+
* xdg compatible configuration file.
|
105
|
+
*
|
106
|
+
* @param xdg_config_path Buffer of GIT_PATH_MAX length to store the path
|
107
|
+
* @return 0 if a xdg compatible configuration file has been
|
108
|
+
* found. Its path will be stored in `buffer`.
|
109
|
+
*/
|
110
|
+
GIT_EXTERN(int) git_config_find_xdg(char *xdg_config_path, size_t length);
|
111
|
+
|
70
112
|
/**
|
71
113
|
* Locate the path to the system configuration file
|
72
114
|
*
|
@@ -80,15 +122,16 @@ GIT_EXTERN(int) git_config_find_global(char *global_config_path, size_t length);
|
|
80
122
|
GIT_EXTERN(int) git_config_find_system(char *system_config_path, size_t length);
|
81
123
|
|
82
124
|
/**
|
83
|
-
* Open the global configuration
|
125
|
+
* Open the global, XDG and system configuration files
|
84
126
|
*
|
85
|
-
* Utility wrapper that
|
86
|
-
* and opens
|
127
|
+
* Utility wrapper that finds the global, XDG and system configuration files
|
128
|
+
* and opens them into a single prioritized config object that can be
|
129
|
+
* used when accessing default config data outside a repository.
|
87
130
|
*
|
88
131
|
* @param out Pointer to store the config instance
|
89
132
|
* @return 0 or an error code
|
90
133
|
*/
|
91
|
-
GIT_EXTERN(int)
|
134
|
+
GIT_EXTERN(int) git_config_open_default(git_config **out);
|
92
135
|
|
93
136
|
/**
|
94
137
|
* Create a configuration file backend for ondisk files
|
@@ -122,14 +165,21 @@ GIT_EXTERN(int) git_config_new(git_config **out);
|
|
122
165
|
*
|
123
166
|
* Further queries on this config object will access each
|
124
167
|
* of the config file instances in order (instances with
|
125
|
-
* a higher priority will be accessed first).
|
168
|
+
* a higher priority level will be accessed first).
|
126
169
|
*
|
127
170
|
* @param cfg the configuration to add the file to
|
128
171
|
* @param file the configuration file (backend) to add
|
129
|
-
* @param
|
130
|
-
* @
|
172
|
+
* @param level the priority level of the backend
|
173
|
+
* @param force if a config file already exists for the given
|
174
|
+
* priority level, replace it
|
175
|
+
* @return 0 on success, GIT_EEXISTS when adding more than one file
|
176
|
+
* for a given priority level (and force_replace set to 0), or error code
|
131
177
|
*/
|
132
|
-
GIT_EXTERN(int) git_config_add_file(
|
178
|
+
GIT_EXTERN(int) git_config_add_file(
|
179
|
+
git_config *cfg,
|
180
|
+
git_config_file *file,
|
181
|
+
unsigned int level,
|
182
|
+
int force);
|
133
183
|
|
134
184
|
/**
|
135
185
|
* Add an on-disk config file instance to an existing config
|
@@ -143,14 +193,21 @@ GIT_EXTERN(int) git_config_add_file(git_config *cfg, git_config_file *file, int
|
|
143
193
|
*
|
144
194
|
* Further queries on this config object will access each
|
145
195
|
* of the config file instances in order (instances with
|
146
|
-
* a higher priority will be accessed first).
|
196
|
+
* a higher priority level will be accessed first).
|
147
197
|
*
|
148
198
|
* @param cfg the configuration to add the file to
|
149
199
|
* @param path path to the configuration file (backend) to add
|
150
|
-
* @param
|
151
|
-
* @
|
200
|
+
* @param level the priority level of the backend
|
201
|
+
* @param force if a config file already exists for the given
|
202
|
+
* priority level, replace it
|
203
|
+
* @return 0 on success, GIT_EEXISTS when adding more than one file
|
204
|
+
* for a given priority level (and force_replace set to 0), or error code
|
152
205
|
*/
|
153
|
-
GIT_EXTERN(int) git_config_add_file_ondisk(
|
206
|
+
GIT_EXTERN(int) git_config_add_file_ondisk(
|
207
|
+
git_config *cfg,
|
208
|
+
const char *path,
|
209
|
+
unsigned int level,
|
210
|
+
int force);
|
154
211
|
|
155
212
|
|
156
213
|
/**
|
@@ -167,6 +224,24 @@ GIT_EXTERN(int) git_config_add_file_ondisk(git_config *cfg, const char *path, in
|
|
167
224
|
*/
|
168
225
|
GIT_EXTERN(int) git_config_open_ondisk(git_config **cfg, const char *path);
|
169
226
|
|
227
|
+
/**
|
228
|
+
* Build a single-level focused config object from a multi-level one.
|
229
|
+
*
|
230
|
+
* The returned config object can be used to perform get/set/delete operations
|
231
|
+
* on a single specific level.
|
232
|
+
*
|
233
|
+
* Getting several times the same level from the same parent multi-level config
|
234
|
+
* will return different config instances, but containing the same config_file
|
235
|
+
* instance.
|
236
|
+
*
|
237
|
+
* @return 0, GIT_ENOTFOUND if the passed level cannot be found in the
|
238
|
+
* multi-level parent config, or an error code
|
239
|
+
*/
|
240
|
+
GIT_EXTERN(int) git_config_open_level(
|
241
|
+
git_config **cfg_out,
|
242
|
+
git_config *cfg_parent,
|
243
|
+
unsigned int level);
|
244
|
+
|
170
245
|
/**
|
171
246
|
* Free the configuration and its associated memory and files
|
172
247
|
*
|
@@ -174,9 +249,26 @@ GIT_EXTERN(int) git_config_open_ondisk(git_config **cfg, const char *path);
|
|
174
249
|
*/
|
175
250
|
GIT_EXTERN(void) git_config_free(git_config *cfg);
|
176
251
|
|
252
|
+
/**
|
253
|
+
* Get the git_config_entry of a config variable.
|
254
|
+
*
|
255
|
+
* The git_config_entry is owned by the config and should not be freed by the
|
256
|
+
* user.
|
257
|
+
|
258
|
+
* @param out pointer to the variable git_config_entry
|
259
|
+
* @param cfg where to look for the variable
|
260
|
+
* @param name the variable's name
|
261
|
+
* @return 0 or an error code
|
262
|
+
*/
|
263
|
+
GIT_EXTERN(int) git_config_get_config_entry(const git_config_entry **out, git_config *cfg, const char *name);
|
264
|
+
|
177
265
|
/**
|
178
266
|
* Get the value of an integer config variable.
|
179
267
|
*
|
268
|
+
* All config files will be looked into, in the order of their
|
269
|
+
* defined level. A higher level means a higher priority. The
|
270
|
+
* first occurence of the variable will be returned here.
|
271
|
+
*
|
180
272
|
* @param out pointer to the variable where the value should be stored
|
181
273
|
* @param cfg where to look for the variable
|
182
274
|
* @param name the variable's name
|
@@ -187,6 +279,10 @@ GIT_EXTERN(int) git_config_get_int32(int32_t *out, git_config *cfg, const char *
|
|
187
279
|
/**
|
188
280
|
* Get the value of a long integer config variable.
|
189
281
|
*
|
282
|
+
* All config files will be looked into, in the order of their
|
283
|
+
* defined level. A higher level means a higher priority. The
|
284
|
+
* first occurence of the variable will be returned here.
|
285
|
+
*
|
190
286
|
* @param out pointer to the variable where the value should be stored
|
191
287
|
* @param cfg where to look for the variable
|
192
288
|
* @param name the variable's name
|
@@ -200,6 +296,10 @@ GIT_EXTERN(int) git_config_get_int64(int64_t *out, git_config *cfg, const char *
|
|
200
296
|
* This function uses the usual C convention of 0 being false and
|
201
297
|
* anything else true.
|
202
298
|
*
|
299
|
+
* All config files will be looked into, in the order of their
|
300
|
+
* defined level. A higher level means a higher priority. The
|
301
|
+
* first occurence of the variable will be returned here.
|
302
|
+
*
|
203
303
|
* @param out pointer to the variable where the value should be stored
|
204
304
|
* @param cfg where to look for the variable
|
205
305
|
* @param name the variable's name
|
@@ -213,6 +313,10 @@ GIT_EXTERN(int) git_config_get_bool(int *out, git_config *cfg, const char *name)
|
|
213
313
|
* The string is owned by the variable and should not be freed by the
|
214
314
|
* user.
|
215
315
|
*
|
316
|
+
* All config files will be looked into, in the order of their
|
317
|
+
* defined level. A higher level means a higher priority. The
|
318
|
+
* first occurence of the variable will be returned here.
|
319
|
+
*
|
216
320
|
* @param out pointer to the variable's value
|
217
321
|
* @param cfg where to look for the variable
|
218
322
|
* @param name the variable's name
|
@@ -232,10 +336,11 @@ GIT_EXTERN(int) git_config_get_string(const char **out, git_config *cfg, const c
|
|
232
336
|
* @param fn the function to be called on each value of the variable
|
233
337
|
* @param data opaque pointer to pass to the callback
|
234
338
|
*/
|
235
|
-
GIT_EXTERN(int) git_config_get_multivar(git_config *cfg, const char *name, const char *regexp, int (*fn)(const
|
339
|
+
GIT_EXTERN(int) git_config_get_multivar(git_config *cfg, const char *name, const char *regexp, int (*fn)(const git_config_entry *, void *), void *data);
|
236
340
|
|
237
341
|
/**
|
238
|
-
* Set the value of an integer config variable
|
342
|
+
* Set the value of an integer config variable in the config file
|
343
|
+
* with the highest level (usually the local one).
|
239
344
|
*
|
240
345
|
* @param cfg where to look for the variable
|
241
346
|
* @param name the variable's name
|
@@ -245,7 +350,8 @@ GIT_EXTERN(int) git_config_get_multivar(git_config *cfg, const char *name, const
|
|
245
350
|
GIT_EXTERN(int) git_config_set_int32(git_config *cfg, const char *name, int32_t value);
|
246
351
|
|
247
352
|
/**
|
248
|
-
* Set the value of a long integer config variable
|
353
|
+
* Set the value of a long integer config variable in the config file
|
354
|
+
* with the highest level (usually the local one).
|
249
355
|
*
|
250
356
|
* @param cfg where to look for the variable
|
251
357
|
* @param name the variable's name
|
@@ -255,7 +361,8 @@ GIT_EXTERN(int) git_config_set_int32(git_config *cfg, const char *name, int32_t
|
|
255
361
|
GIT_EXTERN(int) git_config_set_int64(git_config *cfg, const char *name, int64_t value);
|
256
362
|
|
257
363
|
/**
|
258
|
-
* Set the value of a boolean config variable
|
364
|
+
* Set the value of a boolean config variable in the config file
|
365
|
+
* with the highest level (usually the local one).
|
259
366
|
*
|
260
367
|
* @param cfg where to look for the variable
|
261
368
|
* @param name the variable's name
|
@@ -265,7 +372,8 @@ GIT_EXTERN(int) git_config_set_int64(git_config *cfg, const char *name, int64_t
|
|
265
372
|
GIT_EXTERN(int) git_config_set_bool(git_config *cfg, const char *name, int value);
|
266
373
|
|
267
374
|
/**
|
268
|
-
* Set the value of a string config variable
|
375
|
+
* Set the value of a string config variable in the config file
|
376
|
+
* with the highest level (usually the local one).
|
269
377
|
*
|
270
378
|
* A copy of the string is made and the user is free to use it
|
271
379
|
* afterwards.
|
@@ -277,9 +385,8 @@ GIT_EXTERN(int) git_config_set_bool(git_config *cfg, const char *name, int value
|
|
277
385
|
*/
|
278
386
|
GIT_EXTERN(int) git_config_set_string(git_config *cfg, const char *name, const char *value);
|
279
387
|
|
280
|
-
|
281
388
|
/**
|
282
|
-
* Set a multivar
|
389
|
+
* Set a multivar in the local config file.
|
283
390
|
*
|
284
391
|
* @param cfg where to look for the variable
|
285
392
|
* @param name the variable's name
|
@@ -289,7 +396,8 @@ GIT_EXTERN(int) git_config_set_string(git_config *cfg, const char *name, const c
|
|
289
396
|
GIT_EXTERN(int) git_config_set_multivar(git_config *cfg, const char *name, const char *regexp, const char *value);
|
290
397
|
|
291
398
|
/**
|
292
|
-
* Delete a config variable
|
399
|
+
* Delete a config variable from the config file
|
400
|
+
* with the highest level (usually the local one).
|
293
401
|
*
|
294
402
|
* @param cfg the configuration
|
295
403
|
* @param name the variable to delete
|
@@ -311,7 +419,7 @@ GIT_EXTERN(int) git_config_delete(git_config *cfg, const char *name);
|
|
311
419
|
*/
|
312
420
|
GIT_EXTERN(int) git_config_foreach(
|
313
421
|
git_config *cfg,
|
314
|
-
int (*callback)(const
|
422
|
+
int (*callback)(const git_config_entry *, void *payload),
|
315
423
|
void *payload);
|
316
424
|
|
317
425
|
/**
|
@@ -330,7 +438,7 @@ GIT_EXTERN(int) git_config_foreach(
|
|
330
438
|
GIT_EXTERN(int) git_config_foreach_match(
|
331
439
|
git_config *cfg,
|
332
440
|
const char *regexp,
|
333
|
-
int (*callback)(const
|
441
|
+
int (*callback)(const git_config_entry *entry, void *payload),
|
334
442
|
void *payload);
|
335
443
|
|
336
444
|
/**
|
@@ -369,6 +477,57 @@ GIT_EXTERN(int) git_config_foreach_match(
|
|
369
477
|
*/
|
370
478
|
GIT_EXTERN(int) git_config_get_mapped(int *out, git_config *cfg, const char *name, git_cvar_map *maps, size_t map_n);
|
371
479
|
|
480
|
+
/**
|
481
|
+
* Maps a string value to an integer constant
|
482
|
+
*
|
483
|
+
* @param out place to store the result of the parsing
|
484
|
+
* @param maps array of `git_cvar_map` objects specifying the possible mappings
|
485
|
+
* @param map_n number of mapping objects in `maps`
|
486
|
+
* @param value value to parse
|
487
|
+
*/
|
488
|
+
GIT_EXTERN(int) git_config_lookup_map_value(
|
489
|
+
int *out,
|
490
|
+
git_cvar_map *maps,
|
491
|
+
size_t map_n,
|
492
|
+
const char *value);
|
493
|
+
|
494
|
+
/**
|
495
|
+
* Parse a string value as a bool.
|
496
|
+
*
|
497
|
+
* Valid values for true are: 'true', 'yes', 'on', 1 or any
|
498
|
+
* number different from 0
|
499
|
+
* Valid values for false are: 'false', 'no', 'off', 0
|
500
|
+
*
|
501
|
+
* @param out place to store the result of the parsing
|
502
|
+
* @param value value to parse
|
503
|
+
*/
|
504
|
+
GIT_EXTERN(int) git_config_parse_bool(int *out, const char *value);
|
505
|
+
|
506
|
+
/**
|
507
|
+
* Parse a string value as an int64.
|
508
|
+
*
|
509
|
+
* An optional value suffix of 'k', 'm', or 'g' will
|
510
|
+
* cause the value to be multiplied by 1024, 1048576,
|
511
|
+
* or 1073741824 prior to output.
|
512
|
+
*
|
513
|
+
* @param out place to store the result of the parsing
|
514
|
+
* @param value value to parse
|
515
|
+
*/
|
516
|
+
GIT_EXTERN(int) git_config_parse_int64(int64_t *out, const char *value);
|
517
|
+
|
518
|
+
/**
|
519
|
+
* Parse a string value as an int32.
|
520
|
+
*
|
521
|
+
* An optional value suffix of 'k', 'm', or 'g' will
|
522
|
+
* cause the value to be multiplied by 1024, 1048576,
|
523
|
+
* or 1073741824 prior to output.
|
524
|
+
*
|
525
|
+
* @param out place to store the result of the parsing
|
526
|
+
* @param value value to parse
|
527
|
+
*/
|
528
|
+
GIT_EXTERN(int) git_config_parse_int32(int32_t *out, const char *value);
|
529
|
+
|
530
|
+
|
372
531
|
/** @} */
|
373
532
|
GIT_END_DECL
|
374
533
|
#endif
|
@@ -34,19 +34,58 @@ GIT_BEGIN_DECL
|
|
34
34
|
* in via the `flags` value in the `git_diff_options`.
|
35
35
|
*/
|
36
36
|
enum {
|
37
|
+
/** Normal diff, the default */
|
37
38
|
GIT_DIFF_NORMAL = 0,
|
39
|
+
/** Reverse the sides of the diff */
|
38
40
|
GIT_DIFF_REVERSE = (1 << 0),
|
41
|
+
/** Treat all files as text, disabling binary attributes & detection */
|
39
42
|
GIT_DIFF_FORCE_TEXT = (1 << 1),
|
43
|
+
/** Ignore all whitespace */
|
40
44
|
GIT_DIFF_IGNORE_WHITESPACE = (1 << 2),
|
45
|
+
/** Ignore changes in amount of whitespace */
|
41
46
|
GIT_DIFF_IGNORE_WHITESPACE_CHANGE = (1 << 3),
|
47
|
+
/** Ignore whitespace at end of line */
|
42
48
|
GIT_DIFF_IGNORE_WHITESPACE_EOL = (1 << 4),
|
49
|
+
/** Exclude submodules from the diff completely */
|
43
50
|
GIT_DIFF_IGNORE_SUBMODULES = (1 << 5),
|
51
|
+
/** Use the "patience diff" algorithm (currently unimplemented) */
|
44
52
|
GIT_DIFF_PATIENCE = (1 << 6),
|
53
|
+
/** Include ignored files in the diff list */
|
45
54
|
GIT_DIFF_INCLUDE_IGNORED = (1 << 7),
|
55
|
+
/** Include untracked files in the diff list */
|
46
56
|
GIT_DIFF_INCLUDE_UNTRACKED = (1 << 8),
|
57
|
+
/** Include unmodified files in the diff list */
|
47
58
|
GIT_DIFF_INCLUDE_UNMODIFIED = (1 << 9),
|
59
|
+
/** Even with the GIT_DIFF_INCLUDE_UNTRACKED flag, when an untracked
|
60
|
+
* directory is found, only a single entry for the directory is added
|
61
|
+
* to the diff list; with this flag, all files under the directory will
|
62
|
+
* be included, too.
|
63
|
+
*/
|
48
64
|
GIT_DIFF_RECURSE_UNTRACKED_DIRS = (1 << 10),
|
65
|
+
/** If the pathspec is set in the diff options, this flags means to
|
66
|
+
* apply it as an exact match instead of as an fnmatch pattern.
|
67
|
+
*/
|
49
68
|
GIT_DIFF_DISABLE_PATHSPEC_MATCH = (1 << 11),
|
69
|
+
/** Use case insensitive filename comparisons */
|
70
|
+
GIT_DIFF_DELTAS_ARE_ICASE = (1 << 12),
|
71
|
+
/** When generating patch text, include the content of untracked files */
|
72
|
+
GIT_DIFF_INCLUDE_UNTRACKED_CONTENT = (1 << 13),
|
73
|
+
/** Disable updating of the `binary` flag in delta records. This is
|
74
|
+
* useful when iterating over a diff if you don't need hunk and data
|
75
|
+
* callbacks and want to avoid having to load file completely.
|
76
|
+
*/
|
77
|
+
GIT_DIFF_SKIP_BINARY_CHECK = (1 << 14),
|
78
|
+
/** Normally, a type change between files will be converted into a
|
79
|
+
* DELETED record for the old and an ADDED record for the new; this
|
80
|
+
* options enabled the generation of TYPECHANGE delta records.
|
81
|
+
*/
|
82
|
+
GIT_DIFF_INCLUDE_TYPECHANGE = (1 << 15),
|
83
|
+
/** Even with GIT_DIFF_INCLUDE_TYPECHANGE, blob->tree changes still
|
84
|
+
* generally show as a DELETED blob. This flag tries to correctly
|
85
|
+
* label blob->tree transitions as TYPECHANGE records with new_file's
|
86
|
+
* mode set to tree. Note: the tree SHA will not be available.
|
87
|
+
*/
|
88
|
+
GIT_DIFF_INCLUDE_TYPECHANGE_TREES = (1 << 16),
|
50
89
|
};
|
51
90
|
|
52
91
|
/**
|
@@ -56,7 +95,13 @@ enum {
|
|
56
95
|
* values. Similarly, passing NULL for the options structure will
|
57
96
|
* give the defaults. The default values are marked below.
|
58
97
|
*
|
59
|
-
*
|
98
|
+
* - flags: a combination of the GIT_DIFF_... values above
|
99
|
+
* - context_lines: number of lines of context to show around diffs
|
100
|
+
* - interhunk_lines: min lines between diff hunks to merge them
|
101
|
+
* - old_prefix: "directory" to prefix to old file names (default "a")
|
102
|
+
* - new_prefix: "directory" to prefix to new file names (default "b")
|
103
|
+
* - pathspec: array of paths / patterns to constrain diff
|
104
|
+
* - max_size: maximum blob size to diff, above this treated as binary
|
60
105
|
*/
|
61
106
|
typedef struct {
|
62
107
|
uint32_t flags; /**< defaults to GIT_DIFF_NORMAL */
|
@@ -65,6 +110,7 @@ typedef struct {
|
|
65
110
|
char *old_prefix; /**< defaults to "a" */
|
66
111
|
char *new_prefix; /**< defaults to "b" */
|
67
112
|
git_strarray pathspec; /**< defaults to show all paths */
|
113
|
+
git_off_t max_size; /**< defaults to 512Mb */
|
68
114
|
} git_diff_options;
|
69
115
|
|
70
116
|
/**
|
@@ -72,13 +118,20 @@ typedef struct {
|
|
72
118
|
*/
|
73
119
|
typedef struct git_diff_list git_diff_list;
|
74
120
|
|
121
|
+
/**
|
122
|
+
* Flags that can be set for the file on side of a diff.
|
123
|
+
*
|
124
|
+
* Most of the flags are just for internal consumption by libgit2,
|
125
|
+
* but some of them may be interesting to external users.
|
126
|
+
*/
|
75
127
|
enum {
|
76
|
-
GIT_DIFF_FILE_VALID_OID = (1 << 0),
|
77
|
-
GIT_DIFF_FILE_FREE_PATH = (1 << 1),
|
78
|
-
GIT_DIFF_FILE_BINARY = (1 << 2),
|
79
|
-
GIT_DIFF_FILE_NOT_BINARY = (1 << 3),
|
80
|
-
GIT_DIFF_FILE_FREE_DATA = (1 << 4),
|
81
|
-
GIT_DIFF_FILE_UNMAP_DATA = (1 << 5)
|
128
|
+
GIT_DIFF_FILE_VALID_OID = (1 << 0), /** `oid` value is known correct */
|
129
|
+
GIT_DIFF_FILE_FREE_PATH = (1 << 1), /** `path` is allocated memory */
|
130
|
+
GIT_DIFF_FILE_BINARY = (1 << 2), /** should be considered binary data */
|
131
|
+
GIT_DIFF_FILE_NOT_BINARY = (1 << 3), /** should be considered text data */
|
132
|
+
GIT_DIFF_FILE_FREE_DATA = (1 << 4), /** internal file data is allocated */
|
133
|
+
GIT_DIFF_FILE_UNMAP_DATA = (1 << 5), /** internal file data is mmap'ed */
|
134
|
+
GIT_DIFF_FILE_NO_DATA = (1 << 6), /** file data should not be loaded */
|
82
135
|
};
|
83
136
|
|
84
137
|
/**
|
@@ -92,7 +145,8 @@ typedef enum {
|
|
92
145
|
GIT_DELTA_RENAMED = 4,
|
93
146
|
GIT_DELTA_COPIED = 5,
|
94
147
|
GIT_DELTA_IGNORED = 6,
|
95
|
-
GIT_DELTA_UNTRACKED = 7
|
148
|
+
GIT_DELTA_UNTRACKED = 7,
|
149
|
+
GIT_DELTA_TYPECHANGE = 8,
|
96
150
|
} git_delta_t;
|
97
151
|
|
98
152
|
/**
|
@@ -100,7 +154,7 @@ typedef enum {
|
|
100
154
|
*/
|
101
155
|
typedef struct {
|
102
156
|
git_oid oid;
|
103
|
-
char *path;
|
157
|
+
const char *path;
|
104
158
|
git_off_t size;
|
105
159
|
unsigned int flags;
|
106
160
|
uint16_t mode;
|
@@ -132,7 +186,7 @@ typedef struct {
|
|
132
186
|
*/
|
133
187
|
typedef int (*git_diff_file_fn)(
|
134
188
|
void *cb_data,
|
135
|
-
git_diff_delta *delta,
|
189
|
+
const git_diff_delta *delta,
|
136
190
|
float progress);
|
137
191
|
|
138
192
|
/**
|
@@ -150,8 +204,8 @@ typedef struct {
|
|
150
204
|
*/
|
151
205
|
typedef int (*git_diff_hunk_fn)(
|
152
206
|
void *cb_data,
|
153
|
-
git_diff_delta *delta,
|
154
|
-
git_diff_range *range,
|
207
|
+
const git_diff_delta *delta,
|
208
|
+
const git_diff_range *range,
|
155
209
|
const char *header,
|
156
210
|
size_t header_len);
|
157
211
|
|
@@ -169,7 +223,7 @@ enum {
|
|
169
223
|
GIT_DIFF_LINE_CONTEXT = ' ',
|
170
224
|
GIT_DIFF_LINE_ADDITION = '+',
|
171
225
|
GIT_DIFF_LINE_DELETION = '-',
|
172
|
-
GIT_DIFF_LINE_ADD_EOFNL = '\n', /**<
|
226
|
+
GIT_DIFF_LINE_ADD_EOFNL = '\n', /**< Removed line w/o LF & added one with */
|
173
227
|
GIT_DIFF_LINE_DEL_EOFNL = '\0', /**< LF was removed at end of file */
|
174
228
|
|
175
229
|
/* The following values will only be sent to a `git_diff_data_fn` when
|
@@ -191,12 +245,21 @@ enum {
|
|
191
245
|
*/
|
192
246
|
typedef int (*git_diff_data_fn)(
|
193
247
|
void *cb_data,
|
194
|
-
git_diff_delta *delta,
|
195
|
-
git_diff_range *range,
|
248
|
+
const git_diff_delta *delta,
|
249
|
+
const git_diff_range *range,
|
196
250
|
char line_origin, /**< GIT_DIFF_LINE_... value from above */
|
197
251
|
const char *content,
|
198
252
|
size_t content_len);
|
199
253
|
|
254
|
+
/**
|
255
|
+
* The diff patch is used to store all the text diffs for a delta.
|
256
|
+
*
|
257
|
+
* You can easily loop over the content of patches and get information about
|
258
|
+
* them.
|
259
|
+
*/
|
260
|
+
typedef struct git_diff_patch git_diff_patch;
|
261
|
+
|
262
|
+
|
200
263
|
/** @name Diff List Generator Functions
|
201
264
|
*
|
202
265
|
* These are the functions you would use to create (or destroy) a
|
@@ -322,7 +385,7 @@ GIT_EXTERN(int) git_diff_merge(
|
|
322
385
|
/**@{*/
|
323
386
|
|
324
387
|
/**
|
325
|
-
*
|
388
|
+
* Loop over all deltas in a diff list issuing callbacks.
|
326
389
|
*
|
327
390
|
* This will iterate through all of the files described in a diff. You
|
328
391
|
* should provide a file callback to learn about each file.
|
@@ -369,6 +432,20 @@ GIT_EXTERN(int) git_diff_print_compact(
|
|
369
432
|
void *cb_data,
|
370
433
|
git_diff_data_fn print_cb);
|
371
434
|
|
435
|
+
/**
|
436
|
+
* Look up the single character abbreviation for a delta status code.
|
437
|
+
*
|
438
|
+
* When you call `git_diff_print_compact` it prints single letter codes into
|
439
|
+
* the output such as 'A' for added, 'D' for deleted, 'M' for modified, etc.
|
440
|
+
* It is sometimes convenient to convert a git_delta_t value into these
|
441
|
+
* letters for your own purposes. This function does just that. By the
|
442
|
+
* way, unmodified will return a space (i.e. ' ').
|
443
|
+
*
|
444
|
+
* @param delta_t The git_delta_t value to look up
|
445
|
+
* @return The single character label for that code
|
446
|
+
*/
|
447
|
+
GIT_EXTERN(char) git_diff_status_char(git_delta_t status);
|
448
|
+
|
372
449
|
/**
|
373
450
|
* Iterate over a diff generating text output like "git diff".
|
374
451
|
*
|
@@ -391,6 +468,141 @@ GIT_EXTERN(int) git_diff_print_patch(
|
|
391
468
|
void *cb_data,
|
392
469
|
git_diff_data_fn print_cb);
|
393
470
|
|
471
|
+
/**
|
472
|
+
* Query how many diff records are there in a diff list.
|
473
|
+
*
|
474
|
+
* @param diff A git_diff_list generated by one of the above functions
|
475
|
+
* @return Count of number of deltas in the list
|
476
|
+
*/
|
477
|
+
GIT_EXTERN(size_t) git_diff_num_deltas(git_diff_list *diff);
|
478
|
+
|
479
|
+
/**
|
480
|
+
* Query how many diff deltas are there in a diff list filtered by type.
|
481
|
+
*
|
482
|
+
* This works just like `git_diff_entrycount()` with an extra parameter
|
483
|
+
* that is a `git_delta_t` and returns just the count of how many deltas
|
484
|
+
* match that particular type.
|
485
|
+
*
|
486
|
+
* @param diff A git_diff_list generated by one of the above functions
|
487
|
+
* @param type A git_delta_t value to filter the count
|
488
|
+
* @return Count of number of deltas matching delta_t type
|
489
|
+
*/
|
490
|
+
GIT_EXTERN(size_t) git_diff_num_deltas_of_type(
|
491
|
+
git_diff_list *diff,
|
492
|
+
git_delta_t type);
|
493
|
+
|
494
|
+
/**
|
495
|
+
* Return the diff delta and patch for an entry in the diff list.
|
496
|
+
*
|
497
|
+
* The `git_diff_patch` is a newly created object contains the text diffs
|
498
|
+
* for the delta. You have to call `git_diff_patch_free()` when you are
|
499
|
+
* done with it. You can use the patch object to loop over all the hunks
|
500
|
+
* and lines in the diff of the one delta.
|
501
|
+
*
|
502
|
+
* For an unchanged file or a binary file, no `git_diff_patch` will be
|
503
|
+
* created, the output will be set to NULL, and the `binary` flag will be
|
504
|
+
* set true in the `git_diff_delta` structure.
|
505
|
+
*
|
506
|
+
* The `git_diff_delta` pointer points to internal data and you do not have
|
507
|
+
* to release it when you are done with it. It will go away when the
|
508
|
+
* `git_diff_list` and `git_diff_patch` go away.
|
509
|
+
*
|
510
|
+
* It is okay to pass NULL for either of the output parameters; if you pass
|
511
|
+
* NULL for the `git_diff_patch`, then the text diff will not be calculated.
|
512
|
+
*
|
513
|
+
* @param patch Output parameter for the delta patch object
|
514
|
+
* @param delta Output parameter for the delta object
|
515
|
+
* @param diff Diff list object
|
516
|
+
* @param idx Index into diff list
|
517
|
+
* @return 0 on success, other value < 0 on error
|
518
|
+
*/
|
519
|
+
GIT_EXTERN(int) git_diff_get_patch(
|
520
|
+
git_diff_patch **patch,
|
521
|
+
const git_diff_delta **delta,
|
522
|
+
git_diff_list *diff,
|
523
|
+
size_t idx);
|
524
|
+
|
525
|
+
/**
|
526
|
+
* Free a git_diff_patch object.
|
527
|
+
*/
|
528
|
+
GIT_EXTERN(void) git_diff_patch_free(
|
529
|
+
git_diff_patch *patch);
|
530
|
+
|
531
|
+
/**
|
532
|
+
* Get the delta associated with a patch
|
533
|
+
*/
|
534
|
+
GIT_EXTERN(const git_diff_delta *) git_diff_patch_delta(
|
535
|
+
git_diff_patch *patch);
|
536
|
+
|
537
|
+
/**
|
538
|
+
* Get the number of hunks in a patch
|
539
|
+
*/
|
540
|
+
GIT_EXTERN(size_t) git_diff_patch_num_hunks(
|
541
|
+
git_diff_patch *patch);
|
542
|
+
|
543
|
+
/**
|
544
|
+
* Get the information about a hunk in a patch
|
545
|
+
*
|
546
|
+
* Given a patch and a hunk index into the patch, this returns detailed
|
547
|
+
* information about that hunk. Any of the output pointers can be passed
|
548
|
+
* as NULL if you don't care about that particular piece of information.
|
549
|
+
*
|
550
|
+
* @param range Output pointer to git_diff_range of hunk
|
551
|
+
* @param header Output pointer to header string for hunk. Unlike the
|
552
|
+
* content pointer for each line, this will be NUL-terminated
|
553
|
+
* @param header_len Output value of characters in header string
|
554
|
+
* @param lines_in_hunk Output count of total lines in this hunk
|
555
|
+
* @param patch Input pointer to patch object
|
556
|
+
* @param hunk_idx Input index of hunk to get information about
|
557
|
+
* @return 0 on success, GIT_ENOTFOUND if hunk_idx out of range, <0 on error
|
558
|
+
*/
|
559
|
+
GIT_EXTERN(int) git_diff_patch_get_hunk(
|
560
|
+
const git_diff_range **range,
|
561
|
+
const char **header,
|
562
|
+
size_t *header_len,
|
563
|
+
size_t *lines_in_hunk,
|
564
|
+
git_diff_patch *patch,
|
565
|
+
size_t hunk_idx);
|
566
|
+
|
567
|
+
/**
|
568
|
+
* Get the number of lines in a hunk.
|
569
|
+
*
|
570
|
+
* @param patch The git_diff_patch object
|
571
|
+
* @param hunk_idx Index of the hunk
|
572
|
+
* @return Number of lines in hunk or -1 if invalid hunk index
|
573
|
+
*/
|
574
|
+
GIT_EXTERN(int) git_diff_patch_num_lines_in_hunk(
|
575
|
+
git_diff_patch *patch,
|
576
|
+
size_t hunk_idx);
|
577
|
+
|
578
|
+
/**
|
579
|
+
* Get data about a line in a hunk of a patch.
|
580
|
+
*
|
581
|
+
* Given a patch, a hunk index, and a line index in the hunk, this
|
582
|
+
* will return a lot of details about that line. If you pass a hunk
|
583
|
+
* index larger than the number of hunks or a line index larger than
|
584
|
+
* the number of lines in the hunk, this will return -1.
|
585
|
+
*
|
586
|
+
* @param line_origin A GIT_DIFF_LINE constant from above
|
587
|
+
* @param content Pointer to content of diff line, not NUL-terminated
|
588
|
+
* @param content_len Number of characters in content
|
589
|
+
* @param old_lineno Line number in old file or -1 if line is added
|
590
|
+
* @param new_lineno Line number in new file or -1 if line is deleted
|
591
|
+
* @param patch The patch to look in
|
592
|
+
* @param hunk_idx The index of the hunk
|
593
|
+
* @param line_of_index The index of the line in the hunk
|
594
|
+
* @return 0 on success, <0 on failure
|
595
|
+
*/
|
596
|
+
GIT_EXTERN(int) git_diff_patch_get_line_in_hunk(
|
597
|
+
char *line_origin,
|
598
|
+
const char **content,
|
599
|
+
size_t *content_len,
|
600
|
+
int *old_lineno,
|
601
|
+
int *new_lineno,
|
602
|
+
git_diff_patch *patch,
|
603
|
+
size_t hunk_idx,
|
604
|
+
size_t line_of_hunk);
|
605
|
+
|
394
606
|
/**@}*/
|
395
607
|
|
396
608
|
|
@@ -415,7 +627,7 @@ GIT_EXTERN(int) git_diff_print_patch(
|
|
415
627
|
GIT_EXTERN(int) git_diff_blobs(
|
416
628
|
git_blob *old_blob,
|
417
629
|
git_blob *new_blob,
|
418
|
-
git_diff_options *options,
|
630
|
+
const git_diff_options *options,
|
419
631
|
void *cb_data,
|
420
632
|
git_diff_file_fn file_cb,
|
421
633
|
git_diff_hunk_fn hunk_cb,
|