rugged 0.24.6.1 → 0.25.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (213) hide show
  1. checksums.yaml +4 -4
  2. data/LICENSE +1 -1
  3. data/ext/rugged/extconf.rb +9 -2
  4. data/ext/rugged/rugged.c +85 -21
  5. data/ext/rugged/rugged.h +7 -21
  6. data/ext/rugged/rugged_backend.c +3 -20
  7. data/ext/rugged/rugged_blame.c +7 -24
  8. data/ext/rugged/rugged_blob.c +136 -59
  9. data/ext/rugged/rugged_branch.c +3 -20
  10. data/ext/rugged/rugged_branch_collection.c +3 -20
  11. data/ext/rugged/rugged_commit.c +251 -101
  12. data/ext/rugged/rugged_config.c +3 -20
  13. data/ext/rugged/rugged_cred.c +3 -20
  14. data/ext/rugged/rugged_diff.c +3 -20
  15. data/ext/rugged/rugged_diff_delta.c +3 -20
  16. data/ext/rugged/rugged_diff_hunk.c +3 -20
  17. data/ext/rugged/rugged_diff_line.c +3 -20
  18. data/ext/rugged/rugged_index.c +46 -229
  19. data/ext/rugged/rugged_note.c +3 -20
  20. data/ext/rugged/rugged_object.c +3 -20
  21. data/ext/rugged/rugged_patch.c +192 -34
  22. data/ext/rugged/rugged_rebase.c +90 -48
  23. data/ext/rugged/rugged_reference.c +4 -21
  24. data/ext/rugged/rugged_reference_collection.c +3 -20
  25. data/ext/rugged/rugged_remote.c +70 -42
  26. data/ext/rugged/rugged_remote_collection.c +3 -20
  27. data/ext/rugged/rugged_repo.c +50 -59
  28. data/ext/rugged/rugged_revwalk.c +4 -21
  29. data/ext/rugged/rugged_settings.c +3 -20
  30. data/ext/rugged/rugged_signature.c +3 -20
  31. data/ext/rugged/rugged_submodule.c +4 -21
  32. data/ext/rugged/rugged_submodule_collection.c +3 -20
  33. data/ext/rugged/rugged_tag.c +3 -20
  34. data/ext/rugged/rugged_tag_collection.c +3 -20
  35. data/ext/rugged/rugged_tree.c +189 -184
  36. data/lib/rugged/attributes.rb +5 -0
  37. data/lib/rugged/blob.rb +5 -0
  38. data/lib/rugged/branch.rb +6 -1
  39. data/lib/rugged/commit.rb +5 -0
  40. data/lib/rugged/console.rb +5 -0
  41. data/lib/rugged/credentials.rb +5 -0
  42. data/lib/rugged/diff/delta.rb +5 -0
  43. data/lib/rugged/diff/hunk.rb +5 -0
  44. data/lib/rugged/diff/line.rb +5 -0
  45. data/lib/rugged/diff.rb +5 -0
  46. data/lib/rugged/index.rb +120 -0
  47. data/lib/rugged/object.rb +5 -0
  48. data/lib/rugged/patch.rb +5 -0
  49. data/lib/rugged/reference.rb +5 -0
  50. data/lib/rugged/remote.rb +5 -0
  51. data/lib/rugged/repository.rb +9 -4
  52. data/lib/rugged/submodule_collection.rb +5 -0
  53. data/lib/rugged/tag.rb +5 -0
  54. data/lib/rugged/tree.rb +156 -1
  55. data/lib/rugged/version.rb +6 -1
  56. data/lib/rugged/walker.rb +5 -0
  57. data/lib/rugged.rb +5 -0
  58. data/vendor/libgit2/CMakeLists.txt +12 -2
  59. data/vendor/libgit2/include/git2/blob.h +39 -28
  60. data/vendor/libgit2/include/git2/commit.h +76 -0
  61. data/vendor/libgit2/include/git2/common.h +21 -1
  62. data/vendor/libgit2/include/git2/describe.h +5 -2
  63. data/vendor/libgit2/include/git2/diff.h +62 -7
  64. data/vendor/libgit2/include/git2/errors.h +2 -1
  65. data/vendor/libgit2/include/git2/index.h +25 -0
  66. data/vendor/libgit2/include/git2/merge.h +10 -1
  67. data/vendor/libgit2/include/git2/odb.h +47 -1
  68. data/vendor/libgit2/include/git2/pack.h +4 -4
  69. data/vendor/libgit2/include/git2/patch.h +1 -1
  70. data/vendor/libgit2/include/git2/proxy.h +92 -0
  71. data/vendor/libgit2/include/git2/refs.h +11 -0
  72. data/vendor/libgit2/include/git2/remote.h +21 -8
  73. data/vendor/libgit2/include/git2/repository.h +20 -1
  74. data/vendor/libgit2/include/git2/revwalk.h +4 -6
  75. data/vendor/libgit2/include/git2/signature.h +13 -0
  76. data/vendor/libgit2/include/git2/submodule.h +11 -3
  77. data/vendor/libgit2/include/git2/sys/merge.h +177 -0
  78. data/vendor/libgit2/include/git2/sys/odb_backend.h +11 -0
  79. data/vendor/libgit2/include/git2/sys/remote.h +16 -0
  80. data/vendor/libgit2/include/git2/sys/stream.h +2 -1
  81. data/vendor/libgit2/include/git2/sys/time.h +31 -0
  82. data/vendor/libgit2/include/git2/sys/transport.h +3 -1
  83. data/vendor/libgit2/include/git2/tag.h +9 -0
  84. data/vendor/libgit2/include/git2/transaction.h +9 -0
  85. data/vendor/libgit2/include/git2/tree.h +55 -0
  86. data/vendor/libgit2/include/git2/version.h +4 -4
  87. data/vendor/libgit2/include/git2.h +1 -0
  88. data/vendor/libgit2/src/annotated_commit.c +99 -80
  89. data/vendor/libgit2/src/annotated_commit.h +5 -2
  90. data/vendor/libgit2/src/apply.c +377 -0
  91. data/vendor/libgit2/src/apply.h +21 -0
  92. data/vendor/libgit2/src/array.h +0 -1
  93. data/vendor/libgit2/src/blob.c +71 -39
  94. data/vendor/libgit2/src/branch.c +7 -5
  95. data/vendor/libgit2/src/buffer.c +252 -20
  96. data/vendor/libgit2/src/buffer.h +8 -0
  97. data/vendor/libgit2/src/checkout.c +69 -42
  98. data/vendor/libgit2/src/clone.c +0 -8
  99. data/vendor/libgit2/src/commit.c +193 -49
  100. data/vendor/libgit2/src/commit_list.c +8 -3
  101. data/vendor/libgit2/src/commit_list.h +1 -0
  102. data/vendor/libgit2/src/common.h +2 -1
  103. data/vendor/libgit2/src/config.c +3 -3
  104. data/vendor/libgit2/src/config_file.c +20 -10
  105. data/vendor/libgit2/src/crlf.c +1 -0
  106. data/vendor/libgit2/src/curl_stream.c +106 -6
  107. data/vendor/libgit2/src/delta.c +238 -62
  108. data/vendor/libgit2/src/delta.h +79 -58
  109. data/vendor/libgit2/src/describe.c +1 -1
  110. data/vendor/libgit2/src/diff.c +32 -1554
  111. data/vendor/libgit2/src/diff.h +14 -122
  112. data/vendor/libgit2/src/diff_driver.c +4 -6
  113. data/vendor/libgit2/src/diff_file.c +3 -0
  114. data/vendor/libgit2/src/diff_generate.c +1613 -0
  115. data/vendor/libgit2/src/diff_generate.h +123 -0
  116. data/vendor/libgit2/src/diff_parse.c +101 -0
  117. data/vendor/libgit2/src/diff_parse.h +18 -0
  118. data/vendor/libgit2/src/diff_print.c +263 -144
  119. data/vendor/libgit2/src/diff_stats.c +21 -12
  120. data/vendor/libgit2/src/diff_tform.c +1 -0
  121. data/vendor/libgit2/src/diff_tform.h +22 -0
  122. data/vendor/libgit2/src/diff_xdiff.c +9 -9
  123. data/vendor/libgit2/src/diff_xdiff.h +5 -5
  124. data/vendor/libgit2/src/fetchhead.c +8 -8
  125. data/vendor/libgit2/src/filebuf.c +6 -1
  126. data/vendor/libgit2/src/filebuf.h +1 -0
  127. data/vendor/libgit2/src/fileops.c +22 -1
  128. data/vendor/libgit2/src/fileops.h +8 -2
  129. data/vendor/libgit2/src/fnmatch.c +18 -5
  130. data/vendor/libgit2/src/global.c +21 -4
  131. data/vendor/libgit2/src/global.h +6 -0
  132. data/vendor/libgit2/src/graph.c +1 -1
  133. data/vendor/libgit2/src/index.c +159 -46
  134. data/vendor/libgit2/src/index.h +2 -0
  135. data/vendor/libgit2/src/iterator.c +1573 -1468
  136. data/vendor/libgit2/src/iterator.h +52 -69
  137. data/vendor/libgit2/src/merge.c +163 -64
  138. data/vendor/libgit2/src/merge.h +61 -2
  139. data/vendor/libgit2/src/merge_driver.c +397 -0
  140. data/vendor/libgit2/src/merge_driver.h +60 -0
  141. data/vendor/libgit2/src/merge_file.c +11 -49
  142. data/vendor/libgit2/src/netops.c +12 -10
  143. data/vendor/libgit2/src/object_api.c +19 -1
  144. data/vendor/libgit2/src/odb.c +228 -52
  145. data/vendor/libgit2/src/odb_loose.c +19 -1
  146. data/vendor/libgit2/src/odb_mempack.c +1 -1
  147. data/vendor/libgit2/src/odb_pack.c +27 -1
  148. data/vendor/libgit2/src/openssl_stream.c +4 -5
  149. data/vendor/libgit2/src/pack-objects.c +105 -76
  150. data/vendor/libgit2/src/pack-objects.h +13 -12
  151. data/vendor/libgit2/src/pack.c +16 -10
  152. data/vendor/libgit2/src/pack.h +2 -0
  153. data/vendor/libgit2/src/patch.c +216 -0
  154. data/vendor/libgit2/src/patch.h +66 -0
  155. data/vendor/libgit2/src/{diff_patch.c → patch_generate.c} +203 -376
  156. data/vendor/libgit2/src/patch_generate.h +68 -0
  157. data/vendor/libgit2/src/patch_parse.c +1159 -0
  158. data/vendor/libgit2/src/patch_parse.h +56 -0
  159. data/vendor/libgit2/src/path.c +38 -2
  160. data/vendor/libgit2/src/path.h +18 -0
  161. data/vendor/libgit2/src/pathspec.c +1 -1
  162. data/vendor/libgit2/src/pool.h +5 -0
  163. data/vendor/libgit2/src/pqueue.c +12 -5
  164. data/vendor/libgit2/src/pqueue.h +1 -0
  165. data/vendor/libgit2/src/proxy.c +32 -0
  166. data/vendor/libgit2/src/proxy.h +14 -0
  167. data/vendor/libgit2/src/push.c +1 -1
  168. data/vendor/libgit2/src/rebase.c +63 -36
  169. data/vendor/libgit2/src/refdb.c +4 -2
  170. data/vendor/libgit2/src/refdb_fs.c +82 -54
  171. data/vendor/libgit2/src/refs.c +13 -1
  172. data/vendor/libgit2/src/remote.c +20 -81
  173. data/vendor/libgit2/src/repository.c +212 -29
  174. data/vendor/libgit2/src/reset.c +1 -1
  175. data/vendor/libgit2/src/revparse.c +1 -1
  176. data/vendor/libgit2/src/revwalk.c +260 -184
  177. data/vendor/libgit2/src/settings.c +11 -3
  178. data/vendor/libgit2/src/signature.c +27 -2
  179. data/vendor/libgit2/src/sortedcache.c +14 -5
  180. data/vendor/libgit2/src/stash.c +1 -0
  181. data/vendor/libgit2/src/status.c +1 -0
  182. data/vendor/libgit2/src/stransport_stream.c +4 -2
  183. data/vendor/libgit2/src/stream.h +2 -2
  184. data/vendor/libgit2/src/submodule.c +16 -4
  185. data/vendor/libgit2/src/sysdir.c +1 -1
  186. data/vendor/libgit2/src/transport.c +3 -5
  187. data/vendor/libgit2/src/transports/http.c +38 -13
  188. data/vendor/libgit2/src/transports/local.c +4 -1
  189. data/vendor/libgit2/src/transports/smart.c +6 -0
  190. data/vendor/libgit2/src/transports/smart.h +1 -0
  191. data/vendor/libgit2/src/transports/smart_pkt.c +5 -13
  192. data/vendor/libgit2/src/transports/smart_protocol.c +22 -7
  193. data/vendor/libgit2/src/transports/winhttp.c +144 -11
  194. data/vendor/libgit2/src/tree.c +267 -2
  195. data/vendor/libgit2/src/unix/posix.h +10 -0
  196. data/vendor/libgit2/src/unix/pthread.h +2 -0
  197. data/vendor/libgit2/src/util.c +25 -2
  198. data/vendor/libgit2/src/util.h +10 -0
  199. data/vendor/libgit2/src/varint.c +44 -0
  200. data/vendor/libgit2/src/varint.h +15 -0
  201. data/vendor/libgit2/src/vector.c +58 -0
  202. data/vendor/libgit2/src/vector.h +8 -0
  203. data/vendor/libgit2/src/win32/posix.h +3 -0
  204. data/vendor/libgit2/src/win32/thread.c +18 -0
  205. data/vendor/libgit2/src/win32/thread.h +2 -0
  206. data/vendor/libgit2/src/win32/w32_util.h +1 -1
  207. data/vendor/libgit2/src/zstream.c +37 -8
  208. data/vendor/libgit2/src/zstream.h +8 -1
  209. metadata +100 -82
  210. data/vendor/libgit2/Makefile.embed +0 -60
  211. data/vendor/libgit2/src/delta-apply.c +0 -166
  212. data/vendor/libgit2/src/delta-apply.h +0 -62
  213. data/vendor/libgit2/src/diff_patch.h +0 -83
@@ -98,7 +98,8 @@ typedef enum {
98
98
  GITERR_CHERRYPICK,
99
99
  GITERR_DESCRIBE,
100
100
  GITERR_REBASE,
101
- GITERR_FILESYSTEM
101
+ GITERR_FILESYSTEM,
102
+ GITERR_PATCH,
102
103
  } git_error_t;
103
104
 
104
105
  /**
@@ -251,6 +251,31 @@ GIT_EXTERN(int) git_index_caps(const git_index *index);
251
251
  */
252
252
  GIT_EXTERN(int) git_index_set_caps(git_index *index, int caps);
253
253
 
254
+ /**
255
+ * Get index on-disk version.
256
+ *
257
+ * Valid return values are 2, 3, or 4. If 3 is returned, an index
258
+ * with version 2 may be written instead, if the extension data in
259
+ * version 3 is not necessary.
260
+ *
261
+ * @param index An existing index object
262
+ * @return the index version
263
+ */
264
+ GIT_EXTERN(unsigned int) git_index_version(git_index *index);
265
+
266
+ /**
267
+ * Set index on-disk version.
268
+ *
269
+ * Valid values are 2, 3, or 4. If 2 is given, git_index_write may
270
+ * write an index with version 3 instead, if necessary to accurately
271
+ * represent the index.
272
+ *
273
+ * @param index An existing index object
274
+ * @param version The new version number
275
+ * @return 0 on success, -1 on failure
276
+ */
277
+ GIT_EXTERN(int) git_index_set_version(git_index *index, unsigned int version);
278
+
254
279
  /**
255
280
  * Update the contents of an existing index object in memory by reading
256
281
  * from the hard disk.
@@ -273,7 +273,16 @@ typedef struct {
273
273
  */
274
274
  unsigned int recursion_limit;
275
275
 
276
- /** Flags for handling conflicting content. */
276
+ /**
277
+ * Default merge driver to be used when both sides of a merge have
278
+ * changed. The default is the `text` driver.
279
+ */
280
+ const char *default_driver;
281
+
282
+ /**
283
+ * Flags for handling conflicting content, to be used with the standard
284
+ * (`text`) merge driver.
285
+ */
277
286
  git_merge_file_favor_t file_favor;
278
287
 
279
288
  /** see `git_merge_file_flag_t` above */
@@ -10,6 +10,7 @@
10
10
  #include "common.h"
11
11
  #include "types.h"
12
12
  #include "oid.h"
13
+ #include "oidarray.h"
13
14
 
14
15
  /**
15
16
  * @file git2/odb.h
@@ -159,7 +160,8 @@ GIT_EXTERN(int) git_odb_read_header(size_t *len_out, git_otype *type_out, git_od
159
160
  GIT_EXTERN(int) git_odb_exists(git_odb *db, const git_oid *id);
160
161
 
161
162
  /**
162
- * Determine if objects can be found in the object database from a short OID.
163
+ * Determine if an object can be found in the object database by an
164
+ * abbreviated object ID.
163
165
  *
164
166
  * @param out The full OID of the found object if just one is found.
165
167
  * @param db The database to be searched for the given object.
@@ -171,6 +173,50 @@ GIT_EXTERN(int) git_odb_exists(git_odb *db, const git_oid *id);
171
173
  GIT_EXTERN(int) git_odb_exists_prefix(
172
174
  git_oid *out, git_odb *db, const git_oid *short_id, size_t len);
173
175
 
176
+ /**
177
+ * The information about object IDs to query in `git_odb_expand_ids`,
178
+ * which will be populated upon return.
179
+ */
180
+ typedef struct git_odb_expand_id {
181
+ /** The object ID to expand */
182
+ git_oid id;
183
+
184
+ /**
185
+ * The length of the object ID (in nibbles, or packets of 4 bits; the
186
+ * number of hex characters)
187
+ * */
188
+ unsigned short length;
189
+
190
+ /**
191
+ * The (optional) type of the object to search for; leave as `0` or set
192
+ * to `GIT_OBJ_ANY` to query for any object matching the ID.
193
+ */
194
+ git_otype type;
195
+ } git_odb_expand_id;
196
+
197
+ /**
198
+ * Determine if one or more objects can be found in the object database
199
+ * by their abbreviated object ID and type. The given array will be
200
+ * updated in place: for each abbreviated ID that is unique in the
201
+ * database, and of the given type (if specified), the full object ID,
202
+ * object ID length (`GIT_OID_HEXSZ`) and type will be written back to
203
+ * the array. For IDs that are not found (or are ambiguous), the
204
+ * array entry will be zeroed.
205
+ *
206
+ * Note that since this function operates on multiple objects, the
207
+ * underlying database will not be asked to be reloaded if an object is
208
+ * not found (which is unlike other object database operations.)
209
+ *
210
+ * @param db The database to be searched for the given objects.
211
+ * @param ids An array of short object IDs to search for
212
+ * @param count The length of the `ids` array
213
+ * @return 0 on success or an error code on failure
214
+ */
215
+ GIT_EXTERN(int) git_odb_expand_ids(
216
+ git_odb *db,
217
+ git_odb_expand_id *ids,
218
+ size_t count);
219
+
174
220
  /**
175
221
  * Refresh the object database to load newly added files.
176
222
  *
@@ -196,7 +196,7 @@ GIT_EXTERN(int) git_packbuilder_foreach(git_packbuilder *pb, git_packbuilder_for
196
196
  * @param pb the packbuilder
197
197
  * @return the number of objects in the packfile
198
198
  */
199
- GIT_EXTERN(uint32_t) git_packbuilder_object_count(git_packbuilder *pb);
199
+ GIT_EXTERN(size_t) git_packbuilder_object_count(git_packbuilder *pb);
200
200
 
201
201
  /**
202
202
  * Get the number of objects the packbuilder has already written out
@@ -204,13 +204,13 @@ GIT_EXTERN(uint32_t) git_packbuilder_object_count(git_packbuilder *pb);
204
204
  * @param pb the packbuilder
205
205
  * @return the number of objects which have already been written
206
206
  */
207
- GIT_EXTERN(uint32_t) git_packbuilder_written(git_packbuilder *pb);
207
+ GIT_EXTERN(size_t) git_packbuilder_written(git_packbuilder *pb);
208
208
 
209
209
  /** Packbuilder progress notification function */
210
210
  typedef int (*git_packbuilder_progress)(
211
211
  int stage,
212
- unsigned int current,
213
- unsigned int total,
212
+ uint32_t current,
213
+ uint32_t total,
214
214
  void *payload);
215
215
 
216
216
  /**
@@ -191,7 +191,7 @@ GIT_EXTERN(int) git_patch_get_hunk(
191
191
  *
192
192
  * @param patch The git_patch object
193
193
  * @param hunk_idx Index of the hunk
194
- * @return Number of lines in hunk or -1 if invalid hunk index
194
+ * @return Number of lines in hunk or GIT_ENOTFOUND if invalid hunk index
195
195
  */
196
196
  GIT_EXTERN(int) git_patch_num_lines_in_hunk(
197
197
  const git_patch *patch,
@@ -0,0 +1,92 @@
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_git_proxy_h__
8
+ #define INCLUDE_git_proxy_h__
9
+
10
+ #include "common.h"
11
+ #include "transport.h"
12
+
13
+ GIT_BEGIN_DECL
14
+
15
+ /**
16
+ * The type of proxy to use.
17
+ */
18
+ typedef enum {
19
+ /**
20
+ * Do not attempt to connect through a proxy
21
+ *
22
+ * If built against libcurl, it itself may attempt to connect
23
+ * to a proxy if the environment variables specify it.
24
+ */
25
+ GIT_PROXY_NONE,
26
+ /**
27
+ * Try to auto-detect the proxy from the git configuration.
28
+ */
29
+ GIT_PROXY_AUTO,
30
+ /**
31
+ * Connect via the URL given in the options
32
+ */
33
+ GIT_PROXY_SPECIFIED,
34
+ } git_proxy_t;
35
+
36
+ /**
37
+ * Options for connecting through a proxy
38
+ *
39
+ * Note that not all types may be supported, depending on the platform
40
+ * and compilation options.
41
+ */
42
+ typedef struct {
43
+ unsigned int version;
44
+
45
+ /**
46
+ * The type of proxy to use, by URL, auto-detect.
47
+ */
48
+ git_proxy_t type;
49
+
50
+ /**
51
+ * The URL of the proxy.
52
+ */
53
+ const char *url;
54
+
55
+ /**
56
+ * This will be called if the remote host requires
57
+ * authentication in order to connect to it.
58
+ *
59
+ * Returning GIT_PASSTHROUGH will make libgit2 behave as
60
+ * though this field isn't set.
61
+ */
62
+ git_cred_acquire_cb credentials;
63
+
64
+ /**
65
+ * If cert verification fails, this will be called to let the
66
+ * user make the final decision of whether to allow the
67
+ * connection to proceed. Returns 1 to allow the connection, 0
68
+ * to disallow it or a negative value to indicate an error.
69
+ */
70
+ git_transport_certificate_check_cb certificate_check;
71
+
72
+ /**
73
+ * Payload to be provided to the credentials and certificate
74
+ * check callbacks.
75
+ */
76
+ void *payload;
77
+ } git_proxy_options;
78
+
79
+ #define GIT_PROXY_OPTIONS_VERSION 1
80
+ #define GIT_PROXY_OPTIONS_INIT {GIT_PROXY_OPTIONS_VERSION}
81
+
82
+ /**
83
+ * Initialize a proxy options structure
84
+ *
85
+ * @param opts the options struct to initialize
86
+ * @param version the version of the struct, use `GIT_PROXY_OPTIONS_VERSION`
87
+ */
88
+ GIT_EXTERN(int) git_proxy_init_options(git_proxy_options *opts, unsigned int version);
89
+
90
+ GIT_END_DECL
91
+
92
+ #endif
@@ -461,6 +461,17 @@ GIT_EXTERN(int) git_reference_foreach_name(
461
461
  git_reference_foreach_name_cb callback,
462
462
  void *payload);
463
463
 
464
+ /**
465
+ * Create a copy of an existing reference.
466
+ *
467
+ * Call `git_reference_free` to free the data.
468
+ *
469
+ * @param dest pointer where to store the copy
470
+ * @param source object to copy
471
+ * @return 0 or an error code
472
+ */
473
+ GIT_EXTERN(int) git_reference_dup(git_reference **dest, git_reference *source);
474
+
464
475
  /**
465
476
  * Free the given reference.
466
477
  *
@@ -15,6 +15,7 @@
15
15
  #include "strarray.h"
16
16
  #include "transport.h"
17
17
  #include "pack.h"
18
+ #include "proxy.h"
18
19
 
19
20
  /**
20
21
  * @file git2/remote.h
@@ -25,8 +26,6 @@
25
26
  */
26
27
  GIT_BEGIN_DECL
27
28
 
28
- typedef int (*git_remote_rename_problem_cb)(const char *problematic_refspec, void *payload);
29
-
30
29
  /**
31
30
  * Add a remote with the default fetch refspec to the repository's configuration.
32
31
  *
@@ -241,10 +240,11 @@ GIT_EXTERN(const git_refspec *)git_remote_get_refspec(const git_remote *remote,
241
240
  * @param direction GIT_DIRECTION_FETCH if you want to fetch or
242
241
  * GIT_DIRECTION_PUSH if you want to push
243
242
  * @param callbacks the callbacks to use for this connection
243
+ * @param proxy_opts proxy settings
244
244
  * @param custom_headers extra HTTP headers to use in this connection
245
245
  * @return 0 or an error code
246
246
  */
247
- GIT_EXTERN(int) git_remote_connect(git_remote *remote, git_direction direction, const git_remote_callbacks *callbacks, const git_strarray *custom_headers);
247
+ GIT_EXTERN(int) git_remote_connect(git_remote *remote, git_direction direction, const git_remote_callbacks *callbacks, const git_proxy_options *proxy_opts, const git_strarray *custom_headers);
248
248
 
249
249
  /**
250
250
  * Get the remote repository's reference advertisement list
@@ -358,6 +358,8 @@ typedef struct {
358
358
  } git_push_update;
359
359
 
360
360
  /**
361
+ * Callback used to inform of upcoming updates.
362
+ *
361
363
  * @param updates an array containing the updates which will be sent
362
364
  * as commands to the destination.
363
365
  * @param len number of elements in `updates`
@@ -376,7 +378,7 @@ struct git_remote_callbacks {
376
378
  /**
377
379
  * Textual progress from the remote. Text send over the
378
380
  * progress side-band will be passed to this function (this is
379
- * the 'counting objects' output.
381
+ * the 'counting objects' output).
380
382
  */
381
383
  git_transport_message_cb sideband_progress;
382
384
 
@@ -401,7 +403,7 @@ struct git_remote_callbacks {
401
403
  * connection to proceed. Returns 1 to allow the connection, 0
402
404
  * to disallow it or a negative value to indicate an error.
403
405
  */
404
- git_transport_certificate_check_cb certificate_check;
406
+ git_transport_certificate_check_cb certificate_check;
405
407
 
406
408
  /**
407
409
  * During the download of new data, this will be regularly
@@ -548,6 +550,11 @@ typedef struct {
548
550
  */
549
551
  git_remote_autotag_option_t download_tags;
550
552
 
553
+ /**
554
+ * Proxy options to use, by default no proxy is used.
555
+ */
556
+ git_proxy_options proxy_opts;
557
+
551
558
  /**
552
559
  * Extra headers for this fetch operation
553
560
  */
@@ -555,13 +562,14 @@ typedef struct {
555
562
  } git_fetch_options;
556
563
 
557
564
  #define GIT_FETCH_OPTIONS_VERSION 1
558
- #define GIT_FETCH_OPTIONS_INIT { GIT_FETCH_OPTIONS_VERSION, GIT_REMOTE_CALLBACKS_INIT, GIT_FETCH_PRUNE_UNSPECIFIED, 1 }
565
+ #define GIT_FETCH_OPTIONS_INIT { GIT_FETCH_OPTIONS_VERSION, GIT_REMOTE_CALLBACKS_INIT, GIT_FETCH_PRUNE_UNSPECIFIED, 1, \
566
+ GIT_REMOTE_DOWNLOAD_TAGS_UNSPECIFIED, GIT_PROXY_OPTIONS_INIT }
559
567
 
560
568
  /**
561
569
  * Initializes a `git_fetch_options` with default values. Equivalent to
562
570
  * creating an instance with GIT_FETCH_OPTIONS_INIT.
563
571
  *
564
- * @param opts the `git_push_options` instance to initialize.
572
+ * @param opts the `git_fetch_options` instance to initialize.
565
573
  * @param version the version of the struct; you should pass
566
574
  * `GIT_FETCH_OPTIONS_VERSION` here.
567
575
  * @return Zero on success; -1 on failure.
@@ -592,6 +600,11 @@ typedef struct {
592
600
  */
593
601
  git_remote_callbacks callbacks;
594
602
 
603
+ /**
604
+ * Proxy options to use, by default no proxy is used.
605
+ */
606
+ git_proxy_options proxy_opts;
607
+
595
608
  /**
596
609
  * Extra headers for this push operation
597
610
  */
@@ -599,7 +612,7 @@ typedef struct {
599
612
  } git_push_options;
600
613
 
601
614
  #define GIT_PUSH_OPTIONS_VERSION 1
602
- #define GIT_PUSH_OPTIONS_INIT { GIT_PUSH_OPTIONS_VERSION, 0, GIT_REMOTE_CALLBACKS_INIT }
615
+ #define GIT_PUSH_OPTIONS_INIT { GIT_PUSH_OPTIONS_VERSION, 0, GIT_REMOTE_CALLBACKS_INIT, GIT_PROXY_OPTIONS_INIT }
603
616
 
604
617
  /**
605
618
  * Initializes a `git_push_options` with default values. Equivalent to
@@ -95,11 +95,29 @@ GIT_EXTERN(int) git_repository_discover(
95
95
  * * GIT_REPOSITORY_OPEN_BARE - Open repository as a bare repo regardless
96
96
  * of core.bare config, and defer loading config file for faster setup.
97
97
  * Unlike `git_repository_open_bare`, this can follow gitlinks.
98
+ * * GIT_REPOSITORY_OPEN_NO_DOTGIT - Do not check for a repository by
99
+ * appending /.git to the start_path; only open the repository if
100
+ * start_path itself points to the git directory.
101
+ * * GIT_REPOSITORY_OPEN_FROM_ENV - Find and open a git repository,
102
+ * respecting the environment variables used by the git command-line
103
+ * tools. If set, `git_repository_open_ext` will ignore the other
104
+ * flags and the `ceiling_dirs` argument, and will allow a NULL `path`
105
+ * to use `GIT_DIR` or search from the current directory. The search
106
+ * for a repository will respect $GIT_CEILING_DIRECTORIES and
107
+ * $GIT_DISCOVERY_ACROSS_FILESYSTEM. The opened repository will
108
+ * respect $GIT_INDEX_FILE, $GIT_NAMESPACE, $GIT_OBJECT_DIRECTORY, and
109
+ * $GIT_ALTERNATE_OBJECT_DIRECTORIES. In the future, this flag will
110
+ * also cause `git_repository_open_ext` to respect $GIT_WORK_TREE and
111
+ * $GIT_COMMON_DIR; currently, `git_repository_open_ext` with this
112
+ * flag will error out if either $GIT_WORK_TREE or $GIT_COMMON_DIR is
113
+ * set.
98
114
  */
99
115
  typedef enum {
100
116
  GIT_REPOSITORY_OPEN_NO_SEARCH = (1 << 0),
101
117
  GIT_REPOSITORY_OPEN_CROSS_FS = (1 << 1),
102
118
  GIT_REPOSITORY_OPEN_BARE = (1 << 2),
119
+ GIT_REPOSITORY_OPEN_NO_DOTGIT = (1 << 3),
120
+ GIT_REPOSITORY_OPEN_FROM_ENV = (1 << 4),
103
121
  } git_repository_open_flag_t;
104
122
 
105
123
  /**
@@ -110,7 +128,8 @@ typedef enum {
110
128
  * see if a repo at this path could be opened.
111
129
  * @param path Path to open as git repository. If the flags
112
130
  * permit "searching", then this can be a path to a subdirectory
113
- * inside the working directory of the repository.
131
+ * inside the working directory of the repository. May be NULL if
132
+ * flags is GIT_REPOSITORY_OPEN_FROM_ENV.
114
133
  * @param flags A combination of the GIT_REPOSITORY_OPEN flags above.
115
134
  * @param ceiling_dirs A GIT_PATH_LIST_SEPARATOR delimited list of path
116
135
  * prefixes at which the search for a containing repository should
@@ -25,17 +25,15 @@ GIT_BEGIN_DECL
25
25
  */
26
26
  typedef enum {
27
27
  /**
28
- * Sort the repository contents in no particular ordering;
29
- * this sorting is arbitrary, implementation-specific
30
- * and subject to change at any time.
28
+ * Sort the output with the same default time-order method from git.
31
29
  * This is the default sorting for new walkers.
32
30
  */
33
31
  GIT_SORT_NONE = 0,
34
32
 
35
33
  /**
36
- * Sort the repository contents in topological order
37
- * (parents before children); this sorting mode
38
- * can be combined with time sorting.
34
+ * Sort the repository contents in topological order (parents before
35
+ * children); this sorting mode can be combined with time sorting to
36
+ * produce git's "time-order".
39
37
  */
40
38
  GIT_SORT_TOPOLOGICAL = 1 << 0,
41
39
 
@@ -62,6 +62,19 @@ GIT_EXTERN(int) git_signature_now(git_signature **out, const char *name, const c
62
62
  */
63
63
  GIT_EXTERN(int) git_signature_default(git_signature **out, git_repository *repo);
64
64
 
65
+ /**
66
+ * Create a new signature by parsing the given buffer, which is
67
+ * expected to be in the format "Real Name <email> timestamp tzoffset",
68
+ * where `timestamp` is the number of seconds since the Unix epoch and
69
+ * `tzoffset` is the timezone offset in `hhmm` format (note the lack
70
+ * of a colon separator).
71
+ *
72
+ * @param out new signature
73
+ * @param buf signature string
74
+ * @return 0 on success, or an error code
75
+ */
76
+ GIT_EXTERN(int) git_signature_from_buffer(git_signature **out, const char *buf);
77
+
65
78
  /**
66
79
  * Create a copy of an existing signature. All internal strings are also
67
80
  * duplicated.
@@ -154,13 +154,19 @@ typedef struct git_submodule_update_options {
154
154
  * in the working directory for the newly cloned repository.
155
155
  */
156
156
  unsigned int clone_checkout_strategy;
157
+
158
+ /**
159
+ * Allow fetching from the submodule's default remote if the target
160
+ * commit isn't found. Enabled by default.
161
+ */
162
+ int allow_fetch;
157
163
  } git_submodule_update_options;
158
164
 
159
165
  #define GIT_SUBMODULE_UPDATE_OPTIONS_VERSION 1
160
166
  #define GIT_SUBMODULE_UPDATE_OPTIONS_INIT \
161
- { GIT_CHECKOUT_OPTIONS_VERSION, \
167
+ { GIT_SUBMODULE_UPDATE_OPTIONS_VERSION, \
162
168
  { GIT_CHECKOUT_OPTIONS_VERSION, GIT_CHECKOUT_SAFE }, \
163
- GIT_FETCH_OPTIONS_INIT, GIT_CHECKOUT_SAFE }
169
+ GIT_FETCH_OPTIONS_INIT, GIT_CHECKOUT_SAFE, 1 }
164
170
 
165
171
  /**
166
172
  * Initializes a `git_submodule_update_options` with default values.
@@ -176,7 +182,9 @@ GIT_EXTERN(int) git_submodule_update_init_options(
176
182
  /**
177
183
  * Update a submodule. This will clone a missing submodule and
178
184
  * checkout the subrepository to the commit specified in the index of
179
- * containing repository.
185
+ * the containing repository. If the submodule repository doesn't contain
186
+ * the target commit (e.g. because fetchRecurseSubmodules isn't set), then
187
+ * the submodule is fetched using the fetch options supplied in options.
180
188
  *
181
189
  * @param submodule Submodule object
182
190
  * @param init If the submodule is not initialized, setting this flag to true
@@ -0,0 +1,177 @@
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_sys_git_merge_h__
8
+ #define INCLUDE_sys_git_merge_h__
9
+
10
+ /**
11
+ * @file git2/sys/merge.h
12
+ * @brief Git merge driver backend and plugin routines
13
+ * @defgroup git_backend Git custom backend APIs
14
+ * @ingroup Git
15
+ * @{
16
+ */
17
+ GIT_BEGIN_DECL
18
+
19
+ typedef struct git_merge_driver git_merge_driver;
20
+
21
+ /**
22
+ * Look up a merge driver by name
23
+ *
24
+ * @param name The name of the merge driver
25
+ * @return Pointer to the merge driver object or NULL if not found
26
+ */
27
+ GIT_EXTERN(git_merge_driver *) git_merge_driver_lookup(const char *name);
28
+
29
+ #define GIT_MERGE_DRIVER_TEXT "text"
30
+ #define GIT_MERGE_DRIVER_BINARY "binary"
31
+ #define GIT_MERGE_DRIVER_UNION "union"
32
+
33
+ /**
34
+ * A merge driver source represents the file to be merged
35
+ */
36
+ typedef struct git_merge_driver_source git_merge_driver_source;
37
+
38
+ /** Get the repository that the source data is coming from. */
39
+ GIT_EXTERN(git_repository *) git_merge_driver_source_repo(
40
+ const git_merge_driver_source *src);
41
+
42
+ /** Gets the ancestor of the file to merge. */
43
+ GIT_EXTERN(git_index_entry *) git_merge_driver_source_ancestor(
44
+ const git_merge_driver_source *src);
45
+
46
+ /** Gets the ours side of the file to merge. */
47
+ GIT_EXTERN(git_index_entry *) git_merge_driver_source_ours(
48
+ const git_merge_driver_source *src);
49
+
50
+ /** Gets the theirs side of the file to merge. */
51
+ GIT_EXTERN(git_index_entry *) git_merge_driver_source_theirs(
52
+ const git_merge_driver_source *src);
53
+
54
+ /** Gets the merge file options that the merge was invoked with */
55
+ GIT_EXTERN(git_merge_file_options *) git_merge_driver_source_file_options(
56
+ const git_merge_driver_source *src);
57
+
58
+
59
+ /**
60
+ * Initialize callback on merge driver
61
+ *
62
+ * Specified as `driver.initialize`, this is an optional callback invoked
63
+ * before a merge driver is first used. It will be called once at most
64
+ * per library lifetime.
65
+ *
66
+ * If non-NULL, the merge driver's `initialize` callback will be invoked
67
+ * right before the first use of the driver, so you can defer expensive
68
+ * initialization operations (in case libgit2 is being used in a way that
69
+ * doesn't need the merge driver).
70
+ */
71
+ typedef int (*git_merge_driver_init_fn)(git_merge_driver *self);
72
+
73
+ /**
74
+ * Shutdown callback on merge driver
75
+ *
76
+ * Specified as `driver.shutdown`, this is an optional callback invoked
77
+ * when the merge driver is unregistered or when libgit2 is shutting down.
78
+ * It will be called once at most and should release resources as needed.
79
+ * This may be called even if the `initialize` callback was not made.
80
+ *
81
+ * Typically this function will free the `git_merge_driver` object itself.
82
+ */
83
+ typedef void (*git_merge_driver_shutdown_fn)(git_merge_driver *self);
84
+
85
+ /**
86
+ * Callback to perform the merge.
87
+ *
88
+ * Specified as `driver.apply`, this is the callback that actually does the
89
+ * merge. If it can successfully perform a merge, it should populate
90
+ * `path_out` with a pointer to the filename to accept, `mode_out` with
91
+ * the resultant mode, and `merged_out` with the buffer of the merged file
92
+ * and then return 0. If the driver returns `GIT_PASSTHROUGH`, then the
93
+ * default merge driver should instead be run. It can also return
94
+ * `GIT_EMERGECONFLICT` if the driver is not able to produce a merge result,
95
+ * and the file will remain conflicted. Any other errors will fail and
96
+ * return to the caller.
97
+ *
98
+ * The `filter_name` contains the name of the filter that was invoked, as
99
+ * specified by the file's attributes.
100
+ *
101
+ * The `src` contains the data about the file to be merged.
102
+ */
103
+ typedef int (*git_merge_driver_apply_fn)(
104
+ git_merge_driver *self,
105
+ const char **path_out,
106
+ uint32_t *mode_out,
107
+ git_buf *merged_out,
108
+ const char *filter_name,
109
+ const git_merge_driver_source *src);
110
+
111
+ /**
112
+ * Merge driver structure used to register custom merge drivers.
113
+ *
114
+ * To associate extra data with a driver, allocate extra data and put the
115
+ * `git_merge_driver` struct at the start of your data buffer, then cast
116
+ * the `self` pointer to your larger structure when your callback is invoked.
117
+ */
118
+ struct git_merge_driver {
119
+ /** The `version` should be set to `GIT_MERGE_DRIVER_VERSION`. */
120
+ unsigned int version;
121
+
122
+ /** Called when the merge driver is first used for any file. */
123
+ git_merge_driver_init_fn initialize;
124
+
125
+ /** Called when the merge driver is unregistered from the system. */
126
+ git_merge_driver_shutdown_fn shutdown;
127
+
128
+ /**
129
+ * Called to merge the contents of a conflict. If this function
130
+ * returns `GIT_PASSTHROUGH` then the default (`text`) merge driver
131
+ * will instead be invoked. If this function returns
132
+ * `GIT_EMERGECONFLICT` then the file will remain conflicted.
133
+ */
134
+ git_merge_driver_apply_fn apply;
135
+ };
136
+
137
+ #define GIT_MERGE_DRIVER_VERSION 1
138
+
139
+ /**
140
+ * Register a merge driver under a given name.
141
+ *
142
+ * As mentioned elsewhere, the initialize callback will not be invoked
143
+ * immediately. It is deferred until the driver is used in some way.
144
+ *
145
+ * Currently the merge driver registry is not thread safe, so any
146
+ * registering or deregistering of merge drivers must be done outside of
147
+ * any possible usage of the drivers (i.e. during application setup or
148
+ * shutdown).
149
+ *
150
+ * @param name The name of this driver to match an attribute. Attempting
151
+ * to register with an in-use name will return GIT_EEXISTS.
152
+ * @param driver The merge driver definition. This pointer will be stored
153
+ * as is by libgit2 so it must be a durable allocation (either
154
+ * static or on the heap).
155
+ * @return 0 on successful registry, error code <0 on failure
156
+ */
157
+ GIT_EXTERN(int) git_merge_driver_register(
158
+ const char *name, git_merge_driver *driver);
159
+
160
+ /**
161
+ * Remove the merge driver with the given name.
162
+ *
163
+ * Attempting to remove the builtin libgit2 merge drivers is not permitted
164
+ * and will return an error.
165
+ *
166
+ * Currently the merge driver registry is not thread safe, so any
167
+ * registering or deregistering of drivers must be done outside of any
168
+ * possible usage of the drivers (i.e. during application setup or shutdown).
169
+ *
170
+ * @param name The name under which the merge driver was registered
171
+ * @return 0 on success, error code <0 on failure
172
+ */
173
+ GIT_EXTERN(int) git_merge_driver_unregister(const char *name);
174
+
175
+ /** @} */
176
+ GIT_END_DECL
177
+ #endif