rugged 0.18.0.gh.de28323 → 0.19.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (283) hide show
  1. data/README.md +9 -4
  2. data/Rakefile +1 -1
  3. data/ext/rugged/extconf.rb +10 -0
  4. data/ext/rugged/rugged.c +153 -86
  5. data/ext/rugged/rugged.h +44 -33
  6. data/ext/rugged/rugged_blob.c +288 -60
  7. data/ext/rugged/rugged_branch.c +82 -57
  8. data/ext/rugged/rugged_commit.c +83 -86
  9. data/ext/rugged/rugged_config.c +68 -68
  10. data/ext/rugged/rugged_diff.c +509 -0
  11. data/ext/rugged/rugged_diff_delta.c +94 -0
  12. data/ext/rugged/rugged_diff_hunk.c +100 -0
  13. data/ext/rugged/rugged_diff_line.c +79 -0
  14. data/ext/rugged/rugged_diff_patch.c +169 -0
  15. data/ext/rugged/rugged_index.c +539 -8
  16. data/ext/rugged/rugged_note.c +74 -80
  17. data/ext/rugged/rugged_object.c +63 -8
  18. data/ext/rugged/rugged_reference.c +231 -145
  19. data/ext/rugged/rugged_remote.c +509 -53
  20. data/ext/rugged/rugged_repo.c +572 -236
  21. data/ext/rugged/rugged_revwalk.c +59 -36
  22. data/ext/rugged/rugged_settings.c +7 -9
  23. data/ext/rugged/rugged_signature.c +7 -11
  24. data/ext/rugged/rugged_tag.c +93 -39
  25. data/ext/rugged/rugged_tree.c +321 -58
  26. data/lib/rugged.rb +1 -0
  27. data/lib/rugged/commit.rb +16 -1
  28. data/lib/rugged/console.rb +9 -0
  29. data/lib/rugged/diff.rb +19 -0
  30. data/lib/rugged/diff/delta.rb +54 -0
  31. data/lib/rugged/diff/hunk.rb +23 -0
  32. data/lib/rugged/diff/line.rb +29 -0
  33. data/lib/rugged/diff/patch.rb +28 -0
  34. data/lib/rugged/repository.rb +36 -39
  35. data/lib/rugged/version.rb +1 -1
  36. data/test/blob_test.rb +308 -1
  37. data/test/branch_test.rb +7 -0
  38. data/test/commit_test.rb +7 -10
  39. data/test/coverage/cover.rb +9 -1
  40. data/test/diff_test.rb +777 -0
  41. data/test/fixtures/archive.tar.gz +0 -0
  42. data/test/fixtures/attr/attr0 +1 -0
  43. data/test/fixtures/attr/attr1 +29 -0
  44. data/test/fixtures/attr/attr2 +21 -0
  45. data/test/fixtures/attr/attr3 +4 -0
  46. data/test/fixtures/attr/binfile +1 -0
  47. data/test/fixtures/attr/dir/file +0 -0
  48. data/test/fixtures/attr/file +1 -0
  49. data/test/fixtures/attr/gitattributes +29 -0
  50. data/test/fixtures/attr/gitignore +2 -0
  51. data/test/fixtures/attr/ign +1 -0
  52. data/test/fixtures/attr/macro_bad +1 -0
  53. data/test/fixtures/attr/macro_test +1 -0
  54. data/test/fixtures/attr/root_test1 +1 -0
  55. data/test/fixtures/attr/root_test2 +6 -0
  56. data/test/fixtures/attr/root_test3 +19 -0
  57. data/test/fixtures/attr/root_test4.txt +14 -0
  58. data/test/fixtures/attr/sub/abc +37 -0
  59. data/test/fixtures/attr/sub/dir/file +0 -0
  60. data/test/fixtures/attr/sub/file +1 -0
  61. data/test/fixtures/attr/sub/ign/file +1 -0
  62. data/test/fixtures/attr/sub/ign/sub/file +1 -0
  63. data/test/fixtures/attr/sub/sub/dir +0 -0
  64. data/test/fixtures/attr/sub/sub/file +1 -0
  65. data/test/fixtures/attr/sub/sub/subsub.txt +1 -0
  66. data/test/fixtures/attr/sub/subdir_test1 +2 -0
  67. data/test/fixtures/attr/sub/subdir_test2.txt +1 -0
  68. data/test/fixtures/diff/another.txt +38 -0
  69. data/test/fixtures/diff/readme.txt +36 -0
  70. data/test/fixtures/mergedrepo/conflicts-one.txt +5 -0
  71. data/test/fixtures/mergedrepo/conflicts-two.txt +5 -0
  72. data/test/fixtures/mergedrepo/one.txt +10 -0
  73. data/test/fixtures/mergedrepo/two.txt +12 -0
  74. data/test/fixtures/status/current_file +1 -0
  75. data/test/fixtures/status/ignored_file +1 -0
  76. data/test/fixtures/status/modified_file +2 -0
  77. data/test/fixtures/status/new_file +1 -0
  78. data/test/fixtures/status/staged_changes +2 -0
  79. data/test/fixtures/status/staged_changes_modified_file +3 -0
  80. data/test/fixtures/status/staged_delete_modified_file +1 -0
  81. data/test/fixtures/status/staged_new_file +1 -0
  82. data/test/fixtures/status/staged_new_file_modified_file +2 -0
  83. data/test/fixtures/status/subdir.txt +2 -0
  84. data/test/fixtures/status/subdir/current_file +1 -0
  85. data/test/fixtures/status/subdir/modified_file +2 -0
  86. data/test/fixtures/status/subdir/new_file +1 -0
  87. data/test/fixtures/status//350/277/231 +1 -0
  88. data/test/fixtures/testrepo.git/config +5 -0
  89. data/test/fixtures/testrepo.git/objects/77/71329dfa3002caf8c61a0ceb62a31d09023f37 +0 -0
  90. data/test/fixtures/text_file.md +464 -0
  91. data/test/fixtures/unsymlinked.git/HEAD +1 -0
  92. data/test/fixtures/unsymlinked.git/config +6 -0
  93. data/test/fixtures/unsymlinked.git/description +1 -0
  94. data/test/fixtures/unsymlinked.git/info/exclude +2 -0
  95. data/test/fixtures/unsymlinked.git/objects/08/8b64704e0d6b8bd061dea879418cb5442a3fbf +0 -0
  96. data/test/fixtures/unsymlinked.git/objects/13/a5e939bca25940c069fd2169d993dba328e30b +0 -0
  97. data/test/fixtures/unsymlinked.git/objects/19/bf568e59e3a0b363cafb4106226e62d4a4c41c +0 -0
  98. data/test/fixtures/unsymlinked.git/objects/58/1fadd35b4cf320d102a152f918729011604773 +0 -0
  99. data/test/fixtures/unsymlinked.git/objects/5c/87b6791e8b13da658a14d1ef7e09b5dc3bac8c +0 -0
  100. data/test/fixtures/unsymlinked.git/objects/6f/e5f5398af85fb3de8a6aba0339b6d3bfa26a27 +0 -0
  101. data/test/fixtures/unsymlinked.git/objects/7f/ccd75616ec188b8f1b23d67506a334cc34a49d +0 -0
  102. data/test/fixtures/unsymlinked.git/objects/80/6999882bf91d24241e4077906b9017605eb1f3 +0 -0
  103. data/test/fixtures/unsymlinked.git/objects/83/7d176303c5005505ec1e4a30231c40930c0230 +0 -0
  104. data/test/fixtures/unsymlinked.git/objects/a8/595ccca04f40818ae0155c8f9c77a230e597b6 +2 -0
  105. data/test/fixtures/unsymlinked.git/objects/cf/8f1cf5cce859c438d6cc067284cb5e161206e7 +0 -0
  106. data/test/fixtures/unsymlinked.git/objects/d5/278d05c8607ec420bfee4cf219fbc0eeebfd6a +0 -0
  107. data/test/fixtures/unsymlinked.git/objects/f4/e16fb76536591a41454194058d048d8e4dd2e9 +0 -0
  108. data/test/fixtures/unsymlinked.git/objects/f9/e65619d93fdf2673882e0a261c5e93b1a84006 +0 -0
  109. data/test/fixtures/unsymlinked.git/refs/heads/exe-file +1 -0
  110. data/test/fixtures/unsymlinked.git/refs/heads/master +1 -0
  111. data/test/fixtures/unsymlinked.git/refs/heads/reg-file +1 -0
  112. data/test/index_test.rb +120 -0
  113. data/test/reference_test.rb +38 -3
  114. data/test/remote_test.rb +224 -3
  115. data/test/repo_reset_test.rb +2 -0
  116. data/test/repo_test.rb +147 -10
  117. data/test/test_helper.rb +5 -2
  118. data/vendor/libgit2/include/git2/attr.h +3 -3
  119. data/vendor/libgit2/include/git2/blob.h +11 -17
  120. data/vendor/libgit2/include/git2/branch.h +3 -2
  121. data/vendor/libgit2/include/git2/checkout.h +7 -0
  122. data/vendor/libgit2/include/git2/clone.h +3 -0
  123. data/vendor/libgit2/include/git2/commit.h +61 -66
  124. data/vendor/libgit2/include/git2/common.h +73 -42
  125. data/vendor/libgit2/include/git2/config.h +57 -71
  126. data/vendor/libgit2/include/git2/cred_helpers.h +2 -2
  127. data/vendor/libgit2/include/git2/diff.h +179 -30
  128. data/vendor/libgit2/include/git2/errors.h +3 -3
  129. data/vendor/libgit2/include/git2/index.h +225 -146
  130. data/vendor/libgit2/include/git2/indexer.h +2 -22
  131. data/vendor/libgit2/include/git2/inttypes.h +9 -9
  132. data/vendor/libgit2/include/git2/merge.h +123 -5
  133. data/vendor/libgit2/include/git2/odb.h +59 -38
  134. data/vendor/libgit2/include/git2/odb_backend.h +45 -104
  135. data/vendor/libgit2/include/git2/oid.h +30 -19
  136. data/vendor/libgit2/include/git2/pack.h +21 -3
  137. data/vendor/libgit2/include/git2/refdb.h +0 -35
  138. data/vendor/libgit2/include/git2/refs.h +93 -31
  139. data/vendor/libgit2/include/git2/refspec.h +17 -0
  140. data/vendor/libgit2/include/git2/remote.h +60 -20
  141. data/vendor/libgit2/include/git2/repository.h +48 -70
  142. data/vendor/libgit2/include/git2/reset.h +3 -3
  143. data/vendor/libgit2/include/git2/revparse.h +22 -0
  144. data/vendor/libgit2/include/git2/stash.h +1 -1
  145. data/vendor/libgit2/include/git2/status.h +131 -56
  146. data/vendor/libgit2/include/git2/strarray.h +2 -2
  147. data/vendor/libgit2/include/git2/submodule.h +16 -16
  148. data/vendor/libgit2/include/git2/sys/commit.h +46 -0
  149. data/vendor/libgit2/include/git2/sys/config.h +71 -0
  150. data/vendor/libgit2/include/git2/sys/index.h +179 -0
  151. data/vendor/libgit2/include/git2/sys/odb_backend.h +86 -0
  152. data/vendor/libgit2/include/git2/sys/refdb_backend.h +158 -0
  153. data/vendor/libgit2/include/git2/sys/refs.h +38 -0
  154. data/vendor/libgit2/include/git2/sys/repository.h +106 -0
  155. data/vendor/libgit2/include/git2/tag.h +44 -18
  156. data/vendor/libgit2/include/git2/trace.h +1 -2
  157. data/vendor/libgit2/include/git2/transport.h +74 -0
  158. data/vendor/libgit2/include/git2/tree.h +12 -22
  159. data/vendor/libgit2/include/git2/types.h +33 -0
  160. data/vendor/libgit2/include/git2/version.h +2 -2
  161. data/vendor/libgit2/src/array.h +66 -0
  162. data/vendor/libgit2/src/attr.c +26 -13
  163. data/vendor/libgit2/src/attr_file.c +3 -2
  164. data/vendor/libgit2/src/attr_file.h +3 -3
  165. data/vendor/libgit2/src/attrcache.h +4 -4
  166. data/vendor/libgit2/src/blob.c +13 -9
  167. data/vendor/libgit2/src/blob.h +2 -2
  168. data/vendor/libgit2/src/branch.c +67 -49
  169. data/vendor/libgit2/src/cache.c +224 -54
  170. data/vendor/libgit2/src/cache.h +33 -20
  171. data/vendor/libgit2/src/checkout.c +145 -85
  172. data/vendor/libgit2/src/clone.c +62 -50
  173. data/vendor/libgit2/src/commit.c +74 -40
  174. data/vendor/libgit2/src/commit.h +2 -3
  175. data/vendor/libgit2/src/commit_list.c +14 -8
  176. data/vendor/libgit2/src/config.c +119 -36
  177. data/vendor/libgit2/src/config.h +3 -0
  178. data/vendor/libgit2/src/config_cache.c +24 -7
  179. data/vendor/libgit2/src/config_file.c +9 -6
  180. data/vendor/libgit2/src/crlf.c +4 -2
  181. data/vendor/libgit2/src/date.c +3 -3
  182. data/vendor/libgit2/src/delta.c +1 -1
  183. data/vendor/libgit2/src/diff.c +681 -303
  184. data/vendor/libgit2/src/diff.h +34 -2
  185. data/vendor/libgit2/src/diff_driver.c +405 -0
  186. data/vendor/libgit2/src/diff_driver.h +49 -0
  187. data/vendor/libgit2/src/diff_file.c +447 -0
  188. data/vendor/libgit2/src/diff_file.h +58 -0
  189. data/vendor/libgit2/src/diff_patch.c +995 -0
  190. data/vendor/libgit2/src/diff_patch.h +46 -0
  191. data/vendor/libgit2/src/diff_print.c +430 -0
  192. data/vendor/libgit2/src/diff_tform.c +464 -203
  193. data/vendor/libgit2/src/diff_xdiff.c +166 -0
  194. data/vendor/libgit2/src/diff_xdiff.h +28 -0
  195. data/vendor/libgit2/src/fetch.c +11 -4
  196. data/vendor/libgit2/src/fileops.c +85 -61
  197. data/vendor/libgit2/src/fileops.h +4 -0
  198. data/vendor/libgit2/src/global.c +10 -2
  199. data/vendor/libgit2/src/global.h +0 -8
  200. data/vendor/libgit2/src/hash/hash_generic.h +3 -3
  201. data/vendor/libgit2/src/hash/hash_win32.h +4 -4
  202. data/vendor/libgit2/src/hashsig.c +0 -1
  203. data/vendor/libgit2/src/ignore.c +68 -28
  204. data/vendor/libgit2/src/ignore.h +10 -1
  205. data/vendor/libgit2/src/index.c +666 -84
  206. data/vendor/libgit2/src/index.h +6 -0
  207. data/vendor/libgit2/src/indexer.c +10 -28
  208. data/vendor/libgit2/src/iterator.c +427 -283
  209. data/vendor/libgit2/src/iterator.h +58 -4
  210. data/vendor/libgit2/src/merge.c +1892 -32
  211. data/vendor/libgit2/src/merge.h +132 -5
  212. data/vendor/libgit2/src/merge_file.c +174 -0
  213. data/vendor/libgit2/src/merge_file.h +71 -0
  214. data/vendor/libgit2/src/mwindow.c +1 -1
  215. data/vendor/libgit2/src/notes.c +45 -48
  216. data/vendor/libgit2/src/object.c +89 -127
  217. data/vendor/libgit2/src/object.h +0 -1
  218. data/vendor/libgit2/src/object_api.c +129 -0
  219. data/vendor/libgit2/src/odb.c +156 -59
  220. data/vendor/libgit2/src/odb.h +5 -2
  221. data/vendor/libgit2/src/odb_loose.c +31 -17
  222. data/vendor/libgit2/src/odb_pack.c +39 -43
  223. data/vendor/libgit2/src/oid.c +62 -27
  224. data/vendor/libgit2/src/oid.h +33 -0
  225. data/vendor/libgit2/src/oidmap.h +4 -6
  226. data/vendor/libgit2/src/pack-objects.c +54 -22
  227. data/vendor/libgit2/src/pack.c +98 -56
  228. data/vendor/libgit2/src/pack.h +3 -1
  229. data/vendor/libgit2/src/pathspec.c +26 -1
  230. data/vendor/libgit2/src/pathspec.h +14 -0
  231. data/vendor/libgit2/src/pool.c +5 -0
  232. data/vendor/libgit2/src/posix.c +2 -2
  233. data/vendor/libgit2/src/posix.h +3 -0
  234. data/vendor/libgit2/src/push.c +13 -10
  235. data/vendor/libgit2/src/refdb.c +82 -62
  236. data/vendor/libgit2/src/refdb.h +16 -16
  237. data/vendor/libgit2/src/refdb_fs.c +386 -133
  238. data/vendor/libgit2/src/reflog.c +3 -1
  239. data/vendor/libgit2/src/refs.c +247 -221
  240. data/vendor/libgit2/src/refs.h +2 -1
  241. data/vendor/libgit2/src/refspec.c +18 -1
  242. data/vendor/libgit2/src/refspec.h +3 -1
  243. data/vendor/libgit2/src/remote.c +434 -253
  244. data/vendor/libgit2/src/remote.h +5 -3
  245. data/vendor/libgit2/src/repository.c +197 -111
  246. data/vendor/libgit2/src/repository.h +26 -5
  247. data/vendor/libgit2/src/reset.c +1 -1
  248. data/vendor/libgit2/src/revparse.c +84 -79
  249. data/vendor/libgit2/src/revwalk.c +1 -1
  250. data/vendor/libgit2/src/signature.c +22 -10
  251. data/vendor/libgit2/src/stash.c +5 -2
  252. data/vendor/libgit2/src/status.c +311 -107
  253. data/vendor/libgit2/src/status.h +23 -0
  254. data/vendor/libgit2/src/submodule.c +21 -13
  255. data/vendor/libgit2/src/tag.c +42 -31
  256. data/vendor/libgit2/src/tag.h +2 -3
  257. data/vendor/libgit2/src/thread-utils.h +105 -3
  258. data/vendor/libgit2/src/trace.c +1 -2
  259. data/vendor/libgit2/src/trace.h +3 -3
  260. data/vendor/libgit2/src/transport.c +18 -6
  261. data/vendor/libgit2/src/transports/cred.c +103 -1
  262. data/vendor/libgit2/src/transports/local.c +19 -9
  263. data/vendor/libgit2/src/transports/smart_protocol.c +32 -12
  264. data/vendor/libgit2/src/transports/ssh.c +519 -0
  265. data/vendor/libgit2/src/transports/winhttp.c +3 -1
  266. data/vendor/libgit2/src/tree.c +26 -28
  267. data/vendor/libgit2/src/tree.h +3 -3
  268. data/vendor/libgit2/src/unix/posix.h +2 -0
  269. data/vendor/libgit2/src/util.c +43 -6
  270. data/vendor/libgit2/src/util.h +40 -12
  271. data/vendor/libgit2/src/vector.c +3 -5
  272. data/vendor/libgit2/src/vector.h +9 -0
  273. data/vendor/libgit2/src/win32/dir.c +1 -1
  274. data/vendor/libgit2/src/win32/error.c +2 -0
  275. data/vendor/libgit2/src/win32/findfile.c +3 -6
  276. data/vendor/libgit2/src/win32/posix_w32.c +85 -59
  277. data/vendor/libgit2/src/win32/pthread.c +16 -8
  278. data/vendor/libgit2/src/win32/pthread.h +7 -4
  279. metadata +407 -306
  280. data/test/coverage/HEAD.json +0 -1
  281. data/vendor/libgit2/include/git2/refdb_backend.h +0 -109
  282. data/vendor/libgit2/src/diff_output.c +0 -1819
  283. data/vendor/libgit2/src/diff_output.h +0 -93
@@ -8,31 +8,11 @@
8
8
  #define _INCLUDE_git_indexer_h__
9
9
 
10
10
  #include "common.h"
11
+ #include "types.h"
11
12
  #include "oid.h"
12
13
 
13
14
  GIT_BEGIN_DECL
14
15
 
15
- /**
16
- * This is passed as the first argument to the callback to allow the
17
- * user to see the progress.
18
- */
19
- typedef struct git_transfer_progress {
20
- unsigned int total_objects;
21
- unsigned int indexed_objects;
22
- unsigned int received_objects;
23
- size_t received_bytes;
24
- } git_transfer_progress;
25
-
26
-
27
- /**
28
- * Type for progress callbacks during indexing. Return a value less than zero
29
- * to cancel the transfer.
30
- *
31
- * @param stats Structure containing information about the state of the transfer
32
- * @param payload Payload provided by caller
33
- */
34
- typedef int (*git_transfer_progress_callback)(const git_transfer_progress *stats, void *payload);
35
-
36
16
  typedef struct git_indexer_stream git_indexer_stream;
37
17
 
38
18
  /**
@@ -41,7 +21,7 @@ typedef struct git_indexer_stream git_indexer_stream;
41
21
  * @param out where to store the indexer instance
42
22
  * @param path to the directory where the packfile should be stored
43
23
  * @param progress_cb function to call with progress information
44
- * @param progress_payload payload for the progress callback
24
+ * @param progress_cb_payload payload for the progress callback
45
25
  */
46
26
  GIT_EXTERN(int) git_indexer_stream_new(
47
27
  git_indexer_stream **out,
@@ -283,18 +283,18 @@ _inline
283
283
  #endif // STATIC_IMAXDIV ]
284
284
  imaxdiv_t __cdecl imaxdiv(intmax_t numer, intmax_t denom)
285
285
  {
286
- imaxdiv_t result;
286
+ imaxdiv_t result;
287
287
 
288
- result.quot = numer / denom;
289
- result.rem = numer % denom;
288
+ result.quot = numer / denom;
289
+ result.rem = numer % denom;
290
290
 
291
- if (numer < 0 && result.rem > 0) {
292
- // did division wrong; must fix up
293
- ++result.quot;
294
- result.rem -= denom;
295
- }
291
+ if (numer < 0 && result.rem > 0) {
292
+ // did division wrong; must fix up
293
+ ++result.quot;
294
+ result.rem -= denom;
295
+ }
296
296
 
297
- return result;
297
+ return result;
298
298
  }
299
299
 
300
300
  // 7.8.2.3 The strtoimax and strtoumax functions
@@ -7,19 +7,64 @@
7
7
  #ifndef INCLUDE_git_merge_h__
8
8
  #define INCLUDE_git_merge_h__
9
9
 
10
- #include "common.h"
11
- #include "types.h"
12
- #include "oid.h"
10
+ #include "git2/common.h"
11
+ #include "git2/types.h"
12
+ #include "git2/oid.h"
13
+ #include "git2/checkout.h"
14
+ #include "git2/index.h"
13
15
 
14
16
  /**
15
17
  * @file git2/merge.h
16
- * @brief Git merge-base routines
17
- * @defgroup git_revwalk Git merge-base routines
18
+ * @brief Git merge routines
19
+ * @defgroup git_merge Git merge routines
18
20
  * @ingroup Git
19
21
  * @{
20
22
  */
21
23
  GIT_BEGIN_DECL
22
24
 
25
+ /**
26
+ * Flags for `git_merge_tree` options. A combination of these flags can be
27
+ * passed in via the `flags` value in the `git_merge_tree_opts`.
28
+ */
29
+ typedef enum {
30
+ /** Detect renames */
31
+ GIT_MERGE_TREE_FIND_RENAMES = (1 << 0),
32
+ } git_merge_tree_flag_t;
33
+
34
+ /**
35
+ * Automerge options for `git_merge_trees_opts`.
36
+ */
37
+ typedef enum {
38
+ GIT_MERGE_AUTOMERGE_NORMAL = 0,
39
+ GIT_MERGE_AUTOMERGE_NONE = 1,
40
+ GIT_MERGE_AUTOMERGE_FAVOR_OURS = 2,
41
+ GIT_MERGE_AUTOMERGE_FAVOR_THEIRS = 3,
42
+ } git_merge_automerge_flags;
43
+
44
+
45
+ typedef struct {
46
+ unsigned int version;
47
+ git_merge_tree_flag_t flags;
48
+
49
+ /** Similarity to consider a file renamed (default 50) */
50
+ unsigned int rename_threshold;
51
+
52
+ /** Maximum similarity sources to examine (overrides the
53
+ * `merge.renameLimit` config) (default 200)
54
+ */
55
+ unsigned int target_limit;
56
+
57
+ /** Pluggable similarity metric; pass NULL to use internal metric */
58
+ git_diff_similarity_metric *metric;
59
+
60
+ /** Flags for automerging content. */
61
+ git_merge_automerge_flags automerge_flags;
62
+ } git_merge_tree_opts;
63
+
64
+ #define GIT_MERGE_TREE_OPTS_VERSION 1
65
+ #define GIT_MERGE_TREE_OPTS_INIT {GIT_MERGE_TREE_OPTS_VERSION}
66
+
67
+
23
68
  /**
24
69
  * Find a merge base between two commits
25
70
  *
@@ -50,6 +95,79 @@ GIT_EXTERN(int) git_merge_base_many(
50
95
  const git_oid input_array[],
51
96
  size_t length);
52
97
 
98
+ /**
99
+ * Creates a `git_merge_head` from the given reference
100
+ *
101
+ * @param out pointer to store the git_merge_head result in
102
+ * @param repo repository that contains the given reference
103
+ * @param ref reference to use as a merge input
104
+ * @return zero on success, -1 on failure.
105
+ */
106
+ GIT_EXTERN(int) git_merge_head_from_ref(
107
+ git_merge_head **out,
108
+ git_repository *repo,
109
+ git_reference *ref);
110
+
111
+ /**
112
+ * Creates a `git_merge_head` from the given fetch head data
113
+ *
114
+ * @param out pointer to store the git_merge_head result in
115
+ * @param repo repository that contains the given commit
116
+ * @param branch_name name of the (remote) branch
117
+ * @param remote_url url of the remote
118
+ * @param oid the commit object id to use as a merge input
119
+ * @return zero on success, -1 on failure.
120
+ */
121
+ GIT_EXTERN(int) git_merge_head_from_fetchhead(
122
+ git_merge_head **out,
123
+ git_repository *repo,
124
+ const char *branch_name,
125
+ const char *remote_url,
126
+ const git_oid *oid);
127
+
128
+ /**
129
+ * Creates a `git_merge_head` from the given commit id
130
+ *
131
+ * @param out pointer to store the git_merge_head result in
132
+ * @param repo repository that contains the given commit
133
+ * @param oid the commit object id to use as a merge input
134
+ * @return zero on success, -1 on failure.
135
+ */
136
+ GIT_EXTERN(int) git_merge_head_from_oid(
137
+ git_merge_head **out,
138
+ git_repository *repo,
139
+ const git_oid *oid);
140
+
141
+ /**
142
+ * Frees a `git_merge_head`
143
+ *
144
+ * @param head merge head to free
145
+ */
146
+ GIT_EXTERN(void) git_merge_head_free(
147
+ git_merge_head *head);
148
+
149
+ /**
150
+ * Merge two trees, producing a `git_index` that reflects the result of
151
+ * the merge.
152
+ *
153
+ * The returned index must be freed explicitly with `git_index_free`.
154
+ *
155
+ * @param out pointer to store the index result in
156
+ * @param repo repository that contains the given trees
157
+ * @param ancestor_tree the common ancestor between the trees (or null if none)
158
+ * @param our_tree the tree that reflects the destination tree
159
+ * @param their_tree the tree to merge in to `our_tree`
160
+ * @param opts the merge tree options (or null for defaults)
161
+ * @return zero on success, -1 on failure.
162
+ */
163
+ GIT_EXTERN(int) git_merge_trees(
164
+ git_index **out,
165
+ git_repository *repo,
166
+ const git_tree *ancestor_tree,
167
+ const git_tree *our_tree,
168
+ const git_tree *their_tree,
169
+ const git_merge_tree_opts *opts);
170
+
53
171
  /** @} */
54
172
  GIT_END_DECL
55
173
  #endif
@@ -10,8 +10,6 @@
10
10
  #include "common.h"
11
11
  #include "types.h"
12
12
  #include "oid.h"
13
- #include "odb_backend.h"
14
- #include "indexer.h"
15
13
 
16
14
  /**
17
15
  * @file git2/odb.h
@@ -22,6 +20,11 @@
22
20
  */
23
21
  GIT_BEGIN_DECL
24
22
 
23
+ /**
24
+ * Function type for callbacks from git_odb_foreach.
25
+ */
26
+ typedef int (*git_odb_foreach_cb)(const git_oid *id, void *payload);
27
+
25
28
  /**
26
29
  * Create a new object database with no backends.
27
30
  *
@@ -52,42 +55,6 @@ GIT_EXTERN(int) git_odb_new(git_odb **out);
52
55
  */
53
56
  GIT_EXTERN(int) git_odb_open(git_odb **out, const char *objects_dir);
54
57
 
55
- /**
56
- * Add a custom backend to an existing Object DB
57
- *
58
- * The backends are checked in relative ordering, based on the
59
- * value of the `priority` parameter.
60
- *
61
- * Read <odb_backends.h> for more information.
62
- *
63
- * @param odb database to add the backend to
64
- * @param backend pointer to a git_odb_backend instance
65
- * @param priority Value for ordering the backends queue
66
- * @return 0 on success; error code otherwise
67
- */
68
- GIT_EXTERN(int) git_odb_add_backend(git_odb *odb, git_odb_backend *backend, int priority);
69
-
70
- /**
71
- * Add a custom backend to an existing Object DB; this
72
- * backend will work as an alternate.
73
- *
74
- * Alternate backends are always checked for objects *after*
75
- * all the main backends have been exhausted.
76
- *
77
- * The backends are checked in relative ordering, based on the
78
- * value of the `priority` parameter.
79
- *
80
- * Writing is disabled on alternate backends.
81
- *
82
- * Read <odb_backends.h> for more information.
83
- *
84
- * @param odb database to add the backend to
85
- * @param backend pointer to a git_odb_backend instance
86
- * @param priority Value for ordering the backends queue
87
- * @return 0 on success; error code otherwise
88
- */
89
- GIT_EXTERN(int) git_odb_add_alternate(git_odb *odb, git_odb_backend *backend, int priority);
90
-
91
58
  /**
92
59
  * Add an on-disk alternate to an existing Object DB.
93
60
  *
@@ -406,6 +373,60 @@ GIT_EXTERN(size_t) git_odb_object_size(git_odb_object *object);
406
373
  */
407
374
  GIT_EXTERN(git_otype) git_odb_object_type(git_odb_object *object);
408
375
 
376
+ /**
377
+ * Add a custom backend to an existing Object DB
378
+ *
379
+ * The backends are checked in relative ordering, based on the
380
+ * value of the `priority` parameter.
381
+ *
382
+ * Read <odb_backends.h> for more information.
383
+ *
384
+ * @param odb database to add the backend to
385
+ * @param backend pointer to a git_odb_backend instance
386
+ * @param priority Value for ordering the backends queue
387
+ * @return 0 on success; error code otherwise
388
+ */
389
+ GIT_EXTERN(int) git_odb_add_backend(git_odb *odb, git_odb_backend *backend, int priority);
390
+
391
+ /**
392
+ * Add a custom backend to an existing Object DB; this
393
+ * backend will work as an alternate.
394
+ *
395
+ * Alternate backends are always checked for objects *after*
396
+ * all the main backends have been exhausted.
397
+ *
398
+ * The backends are checked in relative ordering, based on the
399
+ * value of the `priority` parameter.
400
+ *
401
+ * Writing is disabled on alternate backends.
402
+ *
403
+ * Read <odb_backends.h> for more information.
404
+ *
405
+ * @param odb database to add the backend to
406
+ * @param backend pointer to a git_odb_backend instance
407
+ * @param priority Value for ordering the backends queue
408
+ * @return 0 on success; error code otherwise
409
+ */
410
+ GIT_EXTERN(int) git_odb_add_alternate(git_odb *odb, git_odb_backend *backend, int priority);
411
+
412
+ /**
413
+ * Get the number of ODB backend objects
414
+ *
415
+ * @param odb object database
416
+ * @return number of backends in the ODB
417
+ */
418
+ GIT_EXTERN(size_t) git_odb_num_backends(git_odb *odb);
419
+
420
+ /**
421
+ * Lookup an ODB backend object by index
422
+ *
423
+ * @param out output pointer to ODB backend at pos
424
+ * @param odb object database
425
+ * @param pos index into object database backend list
426
+ * @return 0 on success; GIT_ENOTFOUND if pos is invalid; other errors < 0
427
+ */
428
+ GIT_EXTERN(int) git_odb_get_backend(git_odb_backend **out, git_odb *odb, size_t pos);
429
+
409
430
  /** @} */
410
431
  GIT_END_DECL
411
432
  #endif
@@ -7,143 +7,84 @@
7
7
  #ifndef INCLUDE_git_odb_backend_h__
8
8
  #define INCLUDE_git_odb_backend_h__
9
9
 
10
- #include "common.h"
11
- #include "types.h"
12
- #include "oid.h"
13
- #include "indexer.h"
10
+ #include "git2/common.h"
11
+ #include "git2/types.h"
14
12
 
15
13
  /**
16
14
  * @file git2/backend.h
17
15
  * @brief Git custom backend functions
18
- * @defgroup git_backend Git custom backend API
16
+ * @defgroup git_odb Git object database routines
19
17
  * @ingroup Git
20
18
  * @{
21
19
  */
22
20
  GIT_BEGIN_DECL
23
21
 
24
- struct git_odb_stream;
25
- struct git_odb_writepack;
22
+ /*
23
+ * Constructors for in-box ODB backends.
24
+ */
26
25
 
27
26
  /**
28
- * Function type for callbacks from git_odb_foreach.
27
+ * Create a backend for the packfiles.
28
+ *
29
+ * @param out location to store the odb backend pointer
30
+ * @param objects_dir the Git repository's objects directory
31
+ *
32
+ * @return 0 or an error code
29
33
  */
30
- typedef int (*git_odb_foreach_cb)(const git_oid *id, void *payload);
34
+ GIT_EXTERN(int) git_odb_backend_pack(git_odb_backend **out, const char *objects_dir);
31
35
 
32
36
  /**
33
- * An instance for a custom backend
37
+ * Create a backend for loose objects
38
+ *
39
+ * @param out location to store the odb backend pointer
40
+ * @param objects_dir the Git repository's objects directory
41
+ * @param compression_level zlib compression level to use
42
+ * @param do_fsync whether to do an fsync() after writing (currently ignored)
43
+ *
44
+ * @return 0 or an error code
34
45
  */
35
- struct git_odb_backend {
36
- unsigned int version;
37
- git_odb *odb;
38
-
39
- /* read and read_prefix each return to libgit2 a buffer which
40
- * will be freed later. The buffer should be allocated using
41
- * the function git_odb_backend_malloc to ensure that it can
42
- * be safely freed later. */
43
- int (* read)(
44
- void **, size_t *, git_otype *,
45
- struct git_odb_backend *,
46
- const git_oid *);
47
-
48
- /* To find a unique object given a prefix
49
- * of its oid.
50
- * The oid given must be so that the
51
- * remaining (GIT_OID_HEXSZ - len)*4 bits
52
- * are 0s.
53
- */
54
- int (* read_prefix)(
55
- git_oid *,
56
- void **, size_t *, git_otype *,
57
- struct git_odb_backend *,
58
- const git_oid *,
59
- size_t);
60
-
61
- int (* read_header)(
62
- size_t *, git_otype *,
63
- struct git_odb_backend *,
64
- const git_oid *);
65
-
66
- /* The writer may assume that the object
67
- * has already been hashed and is passed
68
- * in the first parameter.
69
- */
70
- int (* write)(
71
- git_oid *,
72
- struct git_odb_backend *,
73
- const void *,
74
- size_t,
75
- git_otype);
76
-
77
- int (* writestream)(
78
- struct git_odb_stream **,
79
- struct git_odb_backend *,
80
- size_t,
81
- git_otype);
82
-
83
- int (* readstream)(
84
- struct git_odb_stream **,
85
- struct git_odb_backend *,
86
- const git_oid *);
87
-
88
- int (* exists)(
89
- struct git_odb_backend *,
90
- const git_oid *);
91
-
92
- int (* refresh)(struct git_odb_backend *);
93
-
94
- int (* foreach)(
95
- struct git_odb_backend *,
96
- git_odb_foreach_cb cb,
97
- void *payload);
98
-
99
- int (* writepack)(
100
- struct git_odb_writepack **,
101
- struct git_odb_backend *,
102
- git_transfer_progress_callback progress_cb,
103
- void *progress_payload);
104
-
105
- void (* free)(struct git_odb_backend *);
106
- };
46
+ GIT_EXTERN(int) git_odb_backend_loose(git_odb_backend **out, const char *objects_dir, int compression_level, int do_fsync);
107
47
 
108
- #define GIT_ODB_BACKEND_VERSION 1
109
- #define GIT_ODB_BACKEND_INIT {GIT_ODB_BACKEND_VERSION}
48
+ /**
49
+ * Create a backend out of a single packfile
50
+ *
51
+ * This can be useful for inspecting the contents of a single
52
+ * packfile.
53
+ *
54
+ * @param out location to store the odb backend pointer
55
+ * @param index_file path to the packfile's .idx file
56
+ *
57
+ * @return 0 or an error code
58
+ */
59
+ GIT_EXTERN(int) git_odb_backend_one_pack(git_odb_backend **out, const char *index_file);
110
60
 
111
61
  /** Streaming mode */
112
- enum {
62
+ typedef enum {
113
63
  GIT_STREAM_RDONLY = (1 << 1),
114
64
  GIT_STREAM_WRONLY = (1 << 2),
115
65
  GIT_STREAM_RW = (GIT_STREAM_RDONLY | GIT_STREAM_WRONLY),
116
- };
66
+ } git_odb_stream_t;
117
67
 
118
68
  /** A stream to read/write from a backend */
119
69
  struct git_odb_stream {
120
- struct git_odb_backend *backend;
70
+ git_odb_backend *backend;
121
71
  unsigned int mode;
122
72
 
123
- int (*read)(struct git_odb_stream *stream, char *buffer, size_t len);
124
- int (*write)(struct git_odb_stream *stream, const char *buffer, size_t len);
125
- int (*finalize_write)(git_oid *oid_p, struct git_odb_stream *stream);
126
- void (*free)(struct git_odb_stream *stream);
73
+ int (*read)(git_odb_stream *stream, char *buffer, size_t len);
74
+ int (*write)(git_odb_stream *stream, const char *buffer, size_t len);
75
+ int (*finalize_write)(git_oid *oid_p, git_odb_stream *stream);
76
+ void (*free)(git_odb_stream *stream);
127
77
  };
128
78
 
129
79
  /** A stream to write a pack file to the ODB */
130
80
  struct git_odb_writepack {
131
- struct git_odb_backend *backend;
81
+ git_odb_backend *backend;
132
82
 
133
- int (*add)(struct git_odb_writepack *writepack, const void *data, size_t size, git_transfer_progress *stats);
134
- int (*commit)(struct git_odb_writepack *writepack, git_transfer_progress *stats);
135
- void (*free)(struct git_odb_writepack *writepack);
83
+ int (*add)(git_odb_writepack *writepack, const void *data, size_t size, git_transfer_progress *stats);
84
+ int (*commit)(git_odb_writepack *writepack, git_transfer_progress *stats);
85
+ void (*free)(git_odb_writepack *writepack);
136
86
  };
137
87
 
138
- GIT_EXTERN(void *) git_odb_backend_malloc(git_odb_backend *backend, size_t len);
139
-
140
- /**
141
- * Constructors for in-box ODB backends.
142
- */
143
- GIT_EXTERN(int) git_odb_backend_pack(git_odb_backend **out, const char *objects_dir);
144
- GIT_EXTERN(int) git_odb_backend_loose(git_odb_backend **out, const char *objects_dir, int compression_level, int do_fsync);
145
- GIT_EXTERN(int) git_odb_backend_one_pack(git_odb_backend **out, const char *index_file);
146
-
147
88
  GIT_END_DECL
148
89
 
149
90
  #endif