rugged 0.17.0.b7 → 0.18.0.b1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (310) hide show
  1. data/LICENSE +1 -1
  2. data/README.md +88 -32
  3. data/ext/rugged/extconf.rb +4 -2
  4. data/ext/rugged/rugged.c +72 -10
  5. data/ext/rugged/rugged.h +14 -10
  6. data/ext/rugged/rugged_blob.c +8 -10
  7. data/ext/rugged/rugged_branch.c +11 -14
  8. data/ext/rugged/rugged_commit.c +31 -24
  9. data/ext/rugged/rugged_config.c +2 -2
  10. data/ext/rugged/rugged_index.c +133 -198
  11. data/ext/rugged/rugged_note.c +372 -0
  12. data/ext/rugged/rugged_object.c +50 -22
  13. data/ext/rugged/rugged_reference.c +122 -130
  14. data/ext/rugged/rugged_remote.c +72 -29
  15. data/ext/rugged/rugged_repo.c +402 -20
  16. data/ext/rugged/rugged_revwalk.c +7 -3
  17. data/ext/rugged/rugged_settings.c +110 -0
  18. data/ext/rugged/rugged_signature.c +23 -7
  19. data/ext/rugged/rugged_tag.c +32 -16
  20. data/ext/rugged/rugged_tree.c +44 -15
  21. data/lib/rugged.rb +1 -0
  22. data/lib/rugged/index.rb +8 -0
  23. data/lib/rugged/remote.rb +13 -0
  24. data/lib/rugged/repository.rb +3 -3
  25. data/lib/rugged/version.rb +1 -1
  26. data/test/blob_test.rb +13 -15
  27. data/test/branch_test.rb +32 -67
  28. data/test/commit_test.rb +50 -12
  29. data/test/config_test.rb +12 -11
  30. data/test/coverage/HEAD.json +1 -1
  31. data/test/coverage/cover.rb +40 -21
  32. data/test/errors_test.rb +34 -0
  33. data/test/fixtures/alternate/objects/14/6ae76773c91e3b1d00cf7a338ec55ae58297e2 +0 -0
  34. data/test/fixtures/alternate/objects/14/9c32d47e99d0a3572ff1e70a2e0051bbf347a9 +0 -0
  35. data/test/fixtures/alternate/objects/14/fb3108588f9421bf764041e5e3ac305eb6277f +0 -0
  36. data/test/fixtures/testrepo.git/logs/refs/notes/commits +1 -0
  37. data/test/fixtures/testrepo.git/objects/44/1034f860c1d5d90e4188d11ae0d325176869a8 +1 -0
  38. data/test/fixtures/testrepo.git/objects/60/d415052a33de2150bf68757f6461df4f563ae4 +0 -0
  39. data/test/fixtures/testrepo.git/objects/68/8a8f4ef7496901d15322972f96e212a9e466cc +1 -0
  40. data/test/fixtures/testrepo.git/objects/94/eca2de348d5f672faf56b0decafa5937e3235e +0 -0
  41. data/test/fixtures/testrepo.git/objects/9b/7384fe1676186192842f5d3e129457b62db9e3 +0 -0
  42. data/test/fixtures/testrepo.git/objects/b7/4713326bc972cc15751ed504dca6f6f3b91f7a +3 -0
  43. data/test/fixtures/testrepo.git/refs/notes/commits +1 -0
  44. data/test/index_test.rb +65 -69
  45. data/test/lib_test.rb +76 -11
  46. data/test/note_test.rb +158 -0
  47. data/test/object_test.rb +8 -11
  48. data/test/reference_test.rb +77 -85
  49. data/test/remote_test.rb +86 -8
  50. data/test/repo_pack_test.rb +9 -7
  51. data/test/repo_reset_test.rb +80 -0
  52. data/test/repo_test.rb +176 -53
  53. data/test/tag_test.rb +44 -7
  54. data/test/test_helper.rb +63 -35
  55. data/test/tree_test.rb +34 -13
  56. data/test/walker_test.rb +14 -14
  57. data/vendor/libgit2/Makefile.embed +1 -1
  58. data/vendor/libgit2/deps/http-parser/http_parser.c +974 -578
  59. data/vendor/libgit2/deps/http-parser/http_parser.h +106 -70
  60. data/vendor/libgit2/deps/regex/regcomp.c +7 -6
  61. data/vendor/libgit2/deps/regex/regex_internal.c +1 -1
  62. data/vendor/libgit2/deps/regex/regex_internal.h +12 -3
  63. data/vendor/libgit2/deps/regex/regexec.c +5 -5
  64. data/vendor/libgit2/include/git2.h +5 -1
  65. data/vendor/libgit2/include/git2/attr.h +4 -2
  66. data/vendor/libgit2/include/git2/blob.h +39 -12
  67. data/vendor/libgit2/include/git2/branch.h +123 -35
  68. data/vendor/libgit2/include/git2/checkout.h +206 -48
  69. data/vendor/libgit2/include/git2/clone.h +72 -27
  70. data/vendor/libgit2/include/git2/commit.h +20 -17
  71. data/vendor/libgit2/include/git2/common.h +67 -1
  72. data/vendor/libgit2/include/git2/config.h +81 -60
  73. data/vendor/libgit2/include/git2/cred_helpers.h +53 -0
  74. data/vendor/libgit2/include/git2/diff.h +459 -150
  75. data/vendor/libgit2/include/git2/errors.h +9 -1
  76. data/vendor/libgit2/include/git2/graph.h +41 -0
  77. data/vendor/libgit2/include/git2/ignore.h +7 -6
  78. data/vendor/libgit2/include/git2/index.h +323 -97
  79. data/vendor/libgit2/include/git2/indexer.h +27 -59
  80. data/vendor/libgit2/include/git2/inttypes.h +4 -0
  81. data/vendor/libgit2/include/git2/merge.h +13 -3
  82. data/vendor/libgit2/include/git2/message.h +14 -8
  83. data/vendor/libgit2/include/git2/net.h +9 -7
  84. data/vendor/libgit2/include/git2/notes.h +88 -29
  85. data/vendor/libgit2/include/git2/object.h +16 -6
  86. data/vendor/libgit2/include/git2/odb.h +80 -17
  87. data/vendor/libgit2/include/git2/odb_backend.h +47 -11
  88. data/vendor/libgit2/include/git2/oid.h +26 -17
  89. data/vendor/libgit2/include/git2/pack.h +62 -8
  90. data/vendor/libgit2/include/git2/push.h +131 -0
  91. data/vendor/libgit2/include/git2/refdb.h +103 -0
  92. data/vendor/libgit2/include/git2/refdb_backend.h +109 -0
  93. data/vendor/libgit2/include/git2/reflog.h +30 -21
  94. data/vendor/libgit2/include/git2/refs.h +215 -193
  95. data/vendor/libgit2/include/git2/refspec.h +22 -2
  96. data/vendor/libgit2/include/git2/remote.h +158 -37
  97. data/vendor/libgit2/include/git2/repository.h +150 -31
  98. data/vendor/libgit2/include/git2/reset.h +43 -9
  99. data/vendor/libgit2/include/git2/revparse.h +48 -4
  100. data/vendor/libgit2/include/git2/revwalk.h +25 -10
  101. data/vendor/libgit2/include/git2/signature.h +20 -12
  102. data/vendor/libgit2/include/git2/stash.h +121 -0
  103. data/vendor/libgit2/include/git2/status.h +122 -53
  104. data/vendor/libgit2/include/git2/strarray.h +17 -11
  105. data/vendor/libgit2/include/git2/submodule.h +42 -7
  106. data/vendor/libgit2/include/git2/tag.h +72 -59
  107. data/vendor/libgit2/include/git2/threads.h +4 -2
  108. data/vendor/libgit2/include/git2/trace.h +68 -0
  109. data/vendor/libgit2/include/git2/transport.h +328 -0
  110. data/vendor/libgit2/include/git2/tree.h +149 -120
  111. data/vendor/libgit2/include/git2/types.h +13 -12
  112. data/vendor/libgit2/include/git2/version.h +3 -3
  113. data/vendor/libgit2/src/amiga/map.c +2 -2
  114. data/vendor/libgit2/src/attr.c +58 -48
  115. data/vendor/libgit2/src/attr.h +4 -18
  116. data/vendor/libgit2/src/attr_file.c +30 -6
  117. data/vendor/libgit2/src/attr_file.h +6 -8
  118. data/vendor/libgit2/src/attrcache.h +24 -0
  119. data/vendor/libgit2/src/blob.c +30 -7
  120. data/vendor/libgit2/src/blob.h +1 -1
  121. data/vendor/libgit2/src/branch.c +361 -68
  122. data/vendor/libgit2/src/branch.h +17 -0
  123. data/vendor/libgit2/src/bswap.h +1 -1
  124. data/vendor/libgit2/src/buf_text.c +291 -0
  125. data/vendor/libgit2/src/buf_text.h +122 -0
  126. data/vendor/libgit2/src/buffer.c +27 -101
  127. data/vendor/libgit2/src/buffer.h +54 -39
  128. data/vendor/libgit2/src/cache.c +15 -6
  129. data/vendor/libgit2/src/cache.h +1 -1
  130. data/vendor/libgit2/src/cc-compat.h +3 -1
  131. data/vendor/libgit2/src/checkout.c +1165 -222
  132. data/vendor/libgit2/src/checkout.h +24 -0
  133. data/vendor/libgit2/src/clone.c +171 -86
  134. data/vendor/libgit2/src/commit.c +44 -45
  135. data/vendor/libgit2/src/commit.h +3 -3
  136. data/vendor/libgit2/src/commit_list.c +194 -0
  137. data/vendor/libgit2/src/commit_list.h +49 -0
  138. data/vendor/libgit2/src/common.h +44 -10
  139. data/vendor/libgit2/src/compress.c +1 -1
  140. data/vendor/libgit2/src/compress.h +1 -1
  141. data/vendor/libgit2/src/config.c +211 -124
  142. data/vendor/libgit2/src/config.h +23 -4
  143. data/vendor/libgit2/src/config_cache.c +2 -2
  144. data/vendor/libgit2/src/config_file.c +129 -53
  145. data/vendor/libgit2/src/config_file.h +10 -8
  146. data/vendor/libgit2/src/crlf.c +66 -67
  147. data/vendor/libgit2/src/date.c +12 -12
  148. data/vendor/libgit2/src/delta-apply.c +14 -1
  149. data/vendor/libgit2/src/delta-apply.h +18 -1
  150. data/vendor/libgit2/src/delta.c +40 -107
  151. data/vendor/libgit2/src/delta.h +19 -17
  152. data/vendor/libgit2/src/diff.c +347 -496
  153. data/vendor/libgit2/src/diff.h +27 -1
  154. data/vendor/libgit2/src/diff_output.c +564 -249
  155. data/vendor/libgit2/src/diff_output.h +15 -8
  156. data/vendor/libgit2/src/diff_tform.c +687 -0
  157. data/vendor/libgit2/src/errors.c +27 -36
  158. data/vendor/libgit2/src/fetch.c +13 -351
  159. data/vendor/libgit2/src/fetch.h +13 -3
  160. data/vendor/libgit2/src/fetchhead.c +295 -0
  161. data/vendor/libgit2/src/fetchhead.h +34 -0
  162. data/vendor/libgit2/src/filebuf.c +42 -15
  163. data/vendor/libgit2/src/filebuf.h +4 -2
  164. data/vendor/libgit2/src/fileops.c +466 -113
  165. data/vendor/libgit2/src/fileops.h +154 -28
  166. data/vendor/libgit2/src/filter.c +3 -75
  167. data/vendor/libgit2/src/filter.h +1 -29
  168. data/vendor/libgit2/src/fnmatch.c +1 -1
  169. data/vendor/libgit2/src/fnmatch.h +1 -1
  170. data/vendor/libgit2/src/global.c +54 -10
  171. data/vendor/libgit2/src/global.h +10 -1
  172. data/vendor/libgit2/src/graph.c +178 -0
  173. data/vendor/libgit2/src/hash.c +25 -52
  174. data/vendor/libgit2/src/hash.h +21 -9
  175. data/vendor/libgit2/src/{sha1/sha1.c → hash/hash_generic.c} +20 -12
  176. data/vendor/libgit2/src/hash/hash_generic.h +24 -0
  177. data/vendor/libgit2/src/hash/hash_openssl.h +45 -0
  178. data/vendor/libgit2/src/hash/hash_win32.c +291 -0
  179. data/vendor/libgit2/src/hash/hash_win32.h +140 -0
  180. data/vendor/libgit2/src/hashsig.c +368 -0
  181. data/vendor/libgit2/src/hashsig.h +72 -0
  182. data/vendor/libgit2/src/ignore.c +22 -15
  183. data/vendor/libgit2/src/ignore.h +6 -1
  184. data/vendor/libgit2/src/index.c +770 -171
  185. data/vendor/libgit2/src/index.h +13 -5
  186. data/vendor/libgit2/src/indexer.c +286 -431
  187. data/vendor/libgit2/src/iterator.c +854 -466
  188. data/vendor/libgit2/src/iterator.h +134 -109
  189. data/vendor/libgit2/src/map.h +1 -1
  190. data/vendor/libgit2/src/merge.c +296 -0
  191. data/vendor/libgit2/src/merge.h +22 -0
  192. data/vendor/libgit2/src/message.c +1 -1
  193. data/vendor/libgit2/src/message.h +1 -1
  194. data/vendor/libgit2/src/mwindow.c +35 -30
  195. data/vendor/libgit2/src/mwindow.h +2 -2
  196. data/vendor/libgit2/src/netops.c +162 -98
  197. data/vendor/libgit2/src/netops.h +50 -15
  198. data/vendor/libgit2/src/notes.c +109 -58
  199. data/vendor/libgit2/src/notes.h +2 -1
  200. data/vendor/libgit2/src/object.c +46 -57
  201. data/vendor/libgit2/src/object.h +1 -8
  202. data/vendor/libgit2/src/odb.c +151 -40
  203. data/vendor/libgit2/src/odb.h +5 -1
  204. data/vendor/libgit2/src/odb_loose.c +4 -5
  205. data/vendor/libgit2/src/odb_pack.c +122 -80
  206. data/vendor/libgit2/src/offmap.h +65 -0
  207. data/vendor/libgit2/src/oid.c +12 -4
  208. data/vendor/libgit2/src/oidmap.h +1 -1
  209. data/vendor/libgit2/src/pack-objects.c +88 -61
  210. data/vendor/libgit2/src/pack-objects.h +8 -8
  211. data/vendor/libgit2/src/pack.c +293 -28
  212. data/vendor/libgit2/src/pack.h +49 -4
  213. data/vendor/libgit2/src/path.c +103 -14
  214. data/vendor/libgit2/src/path.h +23 -7
  215. data/vendor/libgit2/src/pathspec.c +168 -0
  216. data/vendor/libgit2/src/pathspec.h +40 -0
  217. data/vendor/libgit2/src/pool.c +29 -4
  218. data/vendor/libgit2/src/pool.h +8 -1
  219. data/vendor/libgit2/src/posix.c +26 -27
  220. data/vendor/libgit2/src/posix.h +2 -3
  221. data/vendor/libgit2/src/pqueue.c +23 -1
  222. data/vendor/libgit2/src/pqueue.h +23 -1
  223. data/vendor/libgit2/src/push.c +653 -0
  224. data/vendor/libgit2/src/push.h +51 -0
  225. data/vendor/libgit2/src/refdb.c +185 -0
  226. data/vendor/libgit2/src/refdb.h +46 -0
  227. data/vendor/libgit2/src/refdb_fs.c +1024 -0
  228. data/vendor/libgit2/src/refdb_fs.h +15 -0
  229. data/vendor/libgit2/src/reflog.c +77 -45
  230. data/vendor/libgit2/src/reflog.h +1 -3
  231. data/vendor/libgit2/src/refs.c +366 -1326
  232. data/vendor/libgit2/src/refs.h +22 -13
  233. data/vendor/libgit2/src/refspec.c +46 -7
  234. data/vendor/libgit2/src/refspec.h +11 -1
  235. data/vendor/libgit2/src/remote.c +758 -120
  236. data/vendor/libgit2/src/remote.h +10 -5
  237. data/vendor/libgit2/src/repo_template.h +6 -6
  238. data/vendor/libgit2/src/repository.c +315 -96
  239. data/vendor/libgit2/src/repository.h +5 -3
  240. data/vendor/libgit2/src/reset.c +99 -81
  241. data/vendor/libgit2/src/revparse.c +157 -84
  242. data/vendor/libgit2/src/revwalk.c +68 -470
  243. data/vendor/libgit2/src/revwalk.h +44 -0
  244. data/vendor/libgit2/src/sha1_lookup.c +1 -1
  245. data/vendor/libgit2/src/sha1_lookup.h +1 -1
  246. data/vendor/libgit2/src/signature.c +68 -200
  247. data/vendor/libgit2/src/signature.h +1 -1
  248. data/vendor/libgit2/src/stash.c +663 -0
  249. data/vendor/libgit2/src/status.c +101 -79
  250. data/vendor/libgit2/src/strmap.h +1 -1
  251. data/vendor/libgit2/src/submodule.c +67 -51
  252. data/vendor/libgit2/src/submodule.h +1 -1
  253. data/vendor/libgit2/src/tag.c +35 -29
  254. data/vendor/libgit2/src/tag.h +1 -1
  255. data/vendor/libgit2/src/thread-utils.c +1 -1
  256. data/vendor/libgit2/src/thread-utils.h +2 -2
  257. data/vendor/libgit2/src/trace.c +39 -0
  258. data/vendor/libgit2/src/trace.h +56 -0
  259. data/vendor/libgit2/src/transport.c +81 -34
  260. data/vendor/libgit2/src/transports/cred.c +60 -0
  261. data/vendor/libgit2/src/transports/cred_helpers.c +49 -0
  262. data/vendor/libgit2/src/transports/git.c +234 -127
  263. data/vendor/libgit2/src/transports/http.c +761 -433
  264. data/vendor/libgit2/src/transports/local.c +460 -64
  265. data/vendor/libgit2/src/transports/smart.c +345 -0
  266. data/vendor/libgit2/src/transports/smart.h +179 -0
  267. data/vendor/libgit2/src/{pkt.c → transports/smart_pkt.c} +131 -12
  268. data/vendor/libgit2/src/transports/smart_protocol.c +856 -0
  269. data/vendor/libgit2/src/transports/winhttp.c +1136 -0
  270. data/vendor/libgit2/src/tree-cache.c +2 -2
  271. data/vendor/libgit2/src/tree-cache.h +1 -1
  272. data/vendor/libgit2/src/tree.c +239 -166
  273. data/vendor/libgit2/src/tree.h +11 -2
  274. data/vendor/libgit2/src/tsort.c +39 -23
  275. data/vendor/libgit2/src/unix/map.c +1 -1
  276. data/vendor/libgit2/src/unix/posix.h +12 -2
  277. data/vendor/libgit2/src/unix/realpath.c +30 -0
  278. data/vendor/libgit2/src/util.c +250 -13
  279. data/vendor/libgit2/src/util.h +71 -14
  280. data/vendor/libgit2/src/vector.c +123 -60
  281. data/vendor/libgit2/src/vector.h +24 -22
  282. data/vendor/libgit2/src/win32/dir.c +1 -1
  283. data/vendor/libgit2/src/win32/dir.h +1 -1
  284. data/vendor/libgit2/src/win32/error.c +77 -0
  285. data/vendor/libgit2/src/win32/error.h +13 -0
  286. data/vendor/libgit2/src/win32/findfile.c +143 -54
  287. data/vendor/libgit2/src/win32/findfile.h +10 -6
  288. data/vendor/libgit2/src/win32/map.c +1 -1
  289. data/vendor/libgit2/src/win32/mingw-compat.h +1 -1
  290. data/vendor/libgit2/src/win32/msvc-compat.h +10 -1
  291. data/vendor/libgit2/src/win32/posix.h +10 -1
  292. data/vendor/libgit2/src/win32/posix_w32.c +132 -63
  293. data/vendor/libgit2/src/win32/precompiled.c +1 -1
  294. data/vendor/libgit2/src/win32/pthread.c +1 -1
  295. data/vendor/libgit2/src/win32/pthread.h +1 -1
  296. data/vendor/libgit2/src/win32/utf-conv.c +5 -5
  297. data/vendor/libgit2/src/win32/utf-conv.h +3 -3
  298. data/vendor/libgit2/src/win32/version.h +20 -0
  299. metadata +308 -252
  300. data/test/fixtures/testrepo.git/objects/4b/825dc642cb6eb9a060e54bf8d69288fbee4904 +0 -0
  301. data/test/fixtures/testrepo.git/objects/7f/043268ea43ce18e3540acaabf9e090c91965b0 +0 -0
  302. data/test/fixtures/testrepo.git/objects/a3/e05719b428a2d0ed7a55c4ce53dcc5768c6d5e +0 -0
  303. data/test/index_test.rb~ +0 -218
  304. data/vendor/libgit2/src/pkt.h +0 -91
  305. data/vendor/libgit2/src/ppc/sha1.c +0 -70
  306. data/vendor/libgit2/src/ppc/sha1.h +0 -26
  307. data/vendor/libgit2/src/protocol.c +0 -110
  308. data/vendor/libgit2/src/protocol.h +0 -21
  309. data/vendor/libgit2/src/sha1.h +0 -33
  310. data/vendor/libgit2/src/transport.h +0 -148
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Copyright (C) 2009-2012 the libgit2 contributors
2
+ * Copyright (C) the libgit2 contributors. All rights reserved.
3
3
  *
4
4
  * This file is part of libgit2, distributed under the GNU GPL v2 with
5
5
  * a Linking Exception. For full terms see the included COPYING file.
@@ -52,17 +52,37 @@ GIT_EXTERN(int) git_refspec_force(const git_refspec *refspec);
52
52
  */
53
53
  GIT_EXTERN(int) git_refspec_src_matches(const git_refspec *refspec, const char *refname);
54
54
 
55
+ /**
56
+ * Check if a refspec's destination descriptor matches a reference
57
+ *
58
+ * @param refspec the refspec
59
+ * @param refname the name of the reference to check
60
+ * @return 1 if the refspec matches, 0 otherwise
61
+ */
62
+ GIT_EXTERN(int) git_refspec_dst_matches(const git_refspec *refspec, const char *refname);
63
+
55
64
  /**
56
65
  * Transform a reference to its target following the refspec's rules
57
66
  *
58
67
  * @param out where to store the target name
59
- * @param outlen the size ouf the `out` buffer
68
+ * @param outlen the size of the `out` buffer
60
69
  * @param spec the refspec
61
70
  * @param name the name of the reference to transform
62
71
  * @return 0, GIT_EBUFS or another error
63
72
  */
64
73
  GIT_EXTERN(int) git_refspec_transform(char *out, size_t outlen, const git_refspec *spec, const char *name);
65
74
 
75
+ /**
76
+ * Transform a target reference to its source reference following the refspec's rules
77
+ *
78
+ * @param out where to store the source reference name
79
+ * @param outlen the size of the `out` buffer
80
+ * @param spec the refspec
81
+ * @param name the name of the reference to transform
82
+ * @return 0, GIT_EBUFS or another error
83
+ */
84
+ GIT_EXTERN(int) git_refspec_rtransform(char *out, size_t outlen, const git_refspec *spec, const char *name);
85
+
66
86
  GIT_END_DECL
67
87
 
68
88
  #endif
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Copyright (C) 2009-2012 the libgit2 contributors
2
+ * Copyright (C) the libgit2 contributors. All rights reserved.
3
3
  *
4
4
  * This file is part of libgit2, distributed under the GNU GPL v2 with
5
5
  * a Linking Exception. For full terms see the included COPYING file.
@@ -13,6 +13,7 @@
13
13
  #include "net.h"
14
14
  #include "indexer.h"
15
15
  #include "strarray.h"
16
+ #include "transport.h"
16
17
 
17
18
  /**
18
19
  * @file git2/remote.h
@@ -23,6 +24,7 @@
23
24
  */
24
25
  GIT_BEGIN_DECL
25
26
 
27
+ typedef int (*git_remote_rename_problem_cb)(const char *problematic_refspec, void *payload);
26
28
  /*
27
29
  * TODO: This functions still need to be implemented:
28
30
  * - _listcb/_foreach
@@ -31,36 +33,65 @@ GIT_BEGIN_DECL
31
33
  * - _del (needs support from config)
32
34
  */
33
35
 
36
+ /**
37
+ * Add a remote with the default fetch refspec to the repository's configuration. This
38
+ * calls git_remote_save before returning.
39
+ *
40
+ * @param out the resulting remote
41
+ * @param repo the repository in which to create the remote
42
+ * @param name the remote's name
43
+ * @param url the remote's url
44
+ * @return 0, GIT_EINVALIDSPEC, GIT_EEXISTS or an error code
45
+ */
46
+ GIT_EXTERN(int) git_remote_create(
47
+ git_remote **out,
48
+ git_repository *repo,
49
+ const char *name,
50
+ const char *url);
51
+
34
52
  /**
35
53
  * Create a remote in memory
36
54
  *
37
- * Create a remote with the default refspecs in memory. You can use
38
- * this when you have a URL instead of a remote's name.
55
+ * Create a remote with the given refspec in memory. You can use
56
+ * this when you have a URL instead of a remote's name. Note that in-memory
57
+ * remotes cannot be converted to persisted remotes.
58
+ *
59
+ * The name, when provided, will be checked for validity.
60
+ * See `git_tag_create()` for rules about valid names.
39
61
  *
40
62
  * @param out pointer to the new remote object
41
63
  * @param repo the associated repository
42
- * @param name the remote's name
64
+ * @param fetch the fetch refspec to use for this remote. May be NULL for defaults.
43
65
  * @param url the remote repository's URL
44
- * @param fetch the fetch refspec to use for this remote
45
66
  * @return 0 or an error code
46
67
  */
47
- GIT_EXTERN(int) git_remote_new(git_remote **out, git_repository *repo, const char *name, const char *url, const char *fetch);
68
+ GIT_EXTERN(int) git_remote_create_inmemory(
69
+ git_remote **out,
70
+ git_repository *repo,
71
+ const char *fetch,
72
+ const char *url);
48
73
 
49
74
  /**
50
75
  * Get the information for a particular remote
51
76
  *
77
+ * The name will be checked for validity.
78
+ * See `git_tag_create()` for rules about valid names.
79
+ *
52
80
  * @param out pointer to the new remote object
53
- * @param cfg the repository's configuration
81
+ * @param repo the associated repository
54
82
  * @param name the remote's name
55
- * @return 0 or an error code
83
+ * @return 0, GIT_ENOTFOUND, GIT_EINVALIDSPEC or an error code
56
84
  */
57
85
  GIT_EXTERN(int) git_remote_load(git_remote **out, git_repository *repo, const char *name);
58
86
 
59
87
  /**
60
88
  * Save a remote to its repository's configuration
61
89
  *
90
+ * One can't save a in-memory remote. Doing so will
91
+ * result in a GIT_EINVALIDSPEC being returned.
92
+ *
62
93
  * @param remote the remote to save to config
63
- * @return 0 or an error code
94
+ * @return 0, GIT_EINVALIDSPEC or an error code
64
95
  */
65
96
  GIT_EXTERN(int) git_remote_save(const git_remote *remote);
66
97
 
@@ -68,9 +99,9 @@ GIT_EXTERN(int) git_remote_save(const git_remote *remote);
68
99
  * Get the remote's name
69
100
  *
70
101
  * @param remote the remote
71
- * @return a pointer to the name
102
+ * @return a pointer to the name or NULL for in-memory remotes
72
103
  */
73
- GIT_EXTERN(const char *) git_remote_name(git_remote *remote);
104
+ GIT_EXTERN(const char *) git_remote_name(const git_remote *remote);
74
105
 
75
106
  /**
76
107
  * Get the remote's url
@@ -78,7 +109,7 @@ GIT_EXTERN(const char *) git_remote_name(git_remote *remote);
78
109
  * @param remote the remote
79
110
  * @return a pointer to the url
80
111
  */
81
- GIT_EXTERN(const char *) git_remote_url(git_remote *remote);
112
+ GIT_EXTERN(const char *) git_remote_url(const git_remote *remote);
82
113
 
83
114
  /**
84
115
  * Get the remote's url for pushing
@@ -86,7 +117,7 @@ GIT_EXTERN(const char *) git_remote_url(git_remote *remote);
86
117
  * @param remote the remote
87
118
  * @return a pointer to the url or NULL if no special url for pushing is set
88
119
  */
89
- GIT_EXTERN(const char *) git_remote_pushurl(git_remote *remote);
120
+ GIT_EXTERN(const char *) git_remote_pushurl(const git_remote *remote);
90
121
 
91
122
  /**
92
123
  * Set the remote's url
@@ -125,7 +156,7 @@ GIT_EXTERN(int) git_remote_set_fetchspec(git_remote *remote, const char *spec);
125
156
  * @param remote the remote
126
157
  * @return a pointer to the fetch refspec or NULL if it doesn't exist
127
158
  */
128
- GIT_EXTERN(const git_refspec *) git_remote_fetchspec(git_remote *remote);
159
+ GIT_EXTERN(const git_refspec *) git_remote_fetchspec(const git_remote *remote);
129
160
 
130
161
  /**
131
162
  * Set the remote's push refspec
@@ -143,7 +174,7 @@ GIT_EXTERN(int) git_remote_set_pushspec(git_remote *remote, const char *spec);
143
174
  * @return a pointer to the push refspec or NULL if it doesn't exist
144
175
  */
145
176
 
146
- GIT_EXTERN(const git_refspec *) git_remote_pushspec(git_remote *remote);
177
+ GIT_EXTERN(const git_refspec *) git_remote_pushspec(const git_remote *remote);
147
178
 
148
179
  /**
149
180
  * Open a connection to a remote
@@ -156,7 +187,7 @@ GIT_EXTERN(const git_refspec *) git_remote_pushspec(git_remote *remote);
156
187
  * @param direction whether you want to receive or send data
157
188
  * @return 0 or an error code
158
189
  */
159
- GIT_EXTERN(int) git_remote_connect(git_remote *remote, int direction);
190
+ GIT_EXTERN(int) git_remote_connect(git_remote *remote, git_direction direction);
160
191
 
161
192
  /**
162
193
  * Get a list of refs at the remote
@@ -167,8 +198,9 @@ GIT_EXTERN(int) git_remote_connect(git_remote *remote, int direction);
167
198
  * If you a return a non-zero value from the callback, this will stop
168
199
  * looping over the refs.
169
200
  *
170
- * @param refs where to store the refs
171
201
  * @param remote the remote
202
+ * @param list_cb function to call with each ref discovered at the remote
203
+ * @param payload additional data to pass to the callback
172
204
  * @return 0 on success, GIT_EUSER on non-zero callback, or error code
173
205
  */
174
206
  GIT_EXTERN(int) git_remote_ls(git_remote *remote, git_headlist_cb list_cb, void *payload);
@@ -183,10 +215,16 @@ GIT_EXTERN(int) git_remote_ls(git_remote *remote, git_headlist_cb list_cb, void
183
215
  * filename will be NULL and the function will return success.
184
216
  *
185
217
  * @param remote the remote to download from
186
- * @param filename where to store the temporary filename
218
+ * @param progress_cb function to call with progress information. Be aware that
219
+ * this is called inline with network and indexing operations, so performance
220
+ * may be affected.
221
+ * @param progress_payload payload for the progress callback
187
222
  * @return 0 or an error code
188
223
  */
189
- GIT_EXTERN(int) git_remote_download(git_remote *remote, git_off_t *bytes, git_indexer_stats *stats);
224
+ GIT_EXTERN(int) git_remote_download(
225
+ git_remote *remote,
226
+ git_transfer_progress_callback progress_cb,
227
+ void *payload);
190
228
 
191
229
  /**
192
230
  * Check whether the remote is connected
@@ -194,6 +232,7 @@ GIT_EXTERN(int) git_remote_download(git_remote *remote, git_off_t *bytes, git_in
194
232
  * Check whether the remote's underlying transport is connected to the
195
233
  * remote host.
196
234
  *
235
+ * @param remote the remote
197
236
  * @return 1 if it's connected, 0 otherwise.
198
237
  */
199
238
  GIT_EXTERN(int) git_remote_connected(git_remote *remote);
@@ -203,6 +242,8 @@ GIT_EXTERN(int) git_remote_connected(git_remote *remote);
203
242
  *
204
243
  * At certain points in its operation, the network code checks whether
205
244
  * the operation has been cancelled and if so stops the operation.
245
+ *
246
+ * @param remote the remote
206
247
  */
207
248
  GIT_EXTERN(void) git_remote_stop(git_remote *remote);
208
249
 
@@ -230,7 +271,7 @@ GIT_EXTERN(void) git_remote_free(git_remote *remote);
230
271
  * Update the tips to the new state
231
272
  *
232
273
  * @param remote the remote to update
233
- * @param cb callback to run on each ref update. 'a' is the old value, 'b' is then new value
274
+ * @return 0 or an error code
234
275
  */
235
276
  GIT_EXTERN(int) git_remote_update_tips(git_remote *remote);
236
277
 
@@ -255,30 +296,50 @@ GIT_EXTERN(int) git_remote_supported_url(const char* url);
255
296
  *
256
297
  * The string array must be freed by the user.
257
298
  *
258
- * @param remotes_list a string array with the names of the remotes
299
+ * @param out a string array which receives the names of the remotes
259
300
  * @param repo the repository to query
260
301
  * @return 0 or an error code
261
302
  */
262
- GIT_EXTERN(int) git_remote_list(git_strarray *remotes_list, git_repository *repo);
303
+ GIT_EXTERN(int) git_remote_list(git_strarray *out, git_repository *repo);
263
304
 
264
305
  /**
265
- * Add a remote with the default fetch refspec to the repository's configuration
306
+ * Choose whether to check the server's certificate (applies to HTTPS only)
266
307
  *
267
- * @param out the resulting remote
268
- * @param repo the repository in which to create the remote
269
- * @param name the remote's name
270
- * @param url the remote's url
308
+ * @param remote the remote to configure
309
+ * @param check whether to check the server's certificate (defaults to yes)
271
310
  */
272
- GIT_EXTERN(int) git_remote_add(git_remote **out, git_repository *repo, const char *name, const char *url);
311
+ GIT_EXTERN(void) git_remote_check_cert(git_remote *remote, int check);
273
312
 
274
313
  /**
275
- * Choose whether to check the server's certificate (applies to HTTPS only)
314
+ * Set a credentials acquisition callback for this remote. If the remote is
315
+ * not available for anonymous access, then you must set this callback in order
316
+ * to provide credentials to the transport at the time of authentication
317
+ * failure so that retry can be performed.
276
318
  *
277
319
  * @param remote the remote to configure
278
- * @param check whether to check the server's certificate (defaults to yes)
320
+ * @param cred_acquire_cb The credentials acquisition callback to use (defaults
321
+ * to NULL)
279
322
  */
323
+ GIT_EXTERN(void) git_remote_set_cred_acquire_cb(
324
+ git_remote *remote,
325
+ git_cred_acquire_cb cred_acquire_cb,
326
+ void *payload);
280
327
 
281
- GIT_EXTERN(void) git_remote_check_cert(git_remote *remote, int check);
328
+ /**
329
+ * Sets a custom transport for the remote. The caller can use this function
330
+ * to bypass the automatic discovery of a transport by URL scheme (i.e.
331
+ * http://, https://, git://) and supply their own transport to be used
332
+ * instead. After providing the transport to a remote using this function,
333
+ * the transport object belongs exclusively to that remote, and the remote will
334
+ * free it when it is freed with git_remote_free.
335
+ *
336
+ * @param remote the remote to configure
337
+ * @param transport the transport object for the remote to use
338
+ * @return 0 or an error code
339
+ */
340
+ GIT_EXTERN(int) git_remote_set_transport(
341
+ git_remote *remote,
342
+ git_transport *transport);
282
343
 
283
344
  /**
284
345
  * Argument to the completion callback which tells it which operation
@@ -296,12 +357,16 @@ typedef enum git_remote_completion_type {
296
357
  * Set the calbacks to be called by the remote.
297
358
  */
298
359
  struct git_remote_callbacks {
360
+ unsigned int version;
299
361
  void (*progress)(const char *str, int len, void *data);
300
362
  int (*completion)(git_remote_completion_type type, void *data);
301
363
  int (*update_tips)(const char *refname, const git_oid *a, const git_oid *b, void *data);
302
- void *data;
364
+ void *payload;
303
365
  };
304
366
 
367
+ #define GIT_REMOTE_CALLBACKS_VERSION 1
368
+ #define GIT_REMOTE_CALLBACKS_INIT {GIT_REMOTE_CALLBACKS_VERSION}
369
+
305
370
  /**
306
371
  * Set the callbacks for a remote
307
372
  *
@@ -310,15 +375,21 @@ struct git_remote_callbacks {
310
375
  *
311
376
  * @param remote the remote to configure
312
377
  * @param callbacks a pointer to the user's callback settings
378
+ * @return 0 or an error code
313
379
  */
314
- GIT_EXTERN(void) git_remote_set_callbacks(git_remote *remote, git_remote_callbacks *callbacks);
380
+ GIT_EXTERN(int) git_remote_set_callbacks(git_remote *remote, git_remote_callbacks *callbacks);
315
381
 
316
- enum {
382
+ /**
383
+ * Get the statistics structure that is filled in by the fetch operation.
384
+ */
385
+ GIT_EXTERN(const git_transfer_progress *) git_remote_stats(git_remote *remote);
386
+
387
+ typedef enum {
317
388
  GIT_REMOTE_DOWNLOAD_TAGS_UNSET,
318
389
  GIT_REMOTE_DOWNLOAD_TAGS_NONE,
319
390
  GIT_REMOTE_DOWNLOAD_TAGS_AUTO,
320
391
  GIT_REMOTE_DOWNLOAD_TAGS_ALL
321
- };
392
+ } git_remote_autotag_option_t;
322
393
 
323
394
  /**
324
395
  * Retrieve the tag auto-follow setting
@@ -326,7 +397,7 @@ enum {
326
397
  * @param remote the remote to query
327
398
  * @return the auto-follow setting
328
399
  */
329
- GIT_EXTERN(int) git_remote_autotag(git_remote *remote);
400
+ GIT_EXTERN(git_remote_autotag_option_t) git_remote_autotag(git_remote *remote);
330
401
 
331
402
  /**
332
403
  * Set the tag auto-follow setting
@@ -334,8 +405,58 @@ GIT_EXTERN(int) git_remote_autotag(git_remote *remote);
334
405
  * @param remote the remote to configure
335
406
  * @param value a GIT_REMOTE_DOWNLOAD_TAGS value
336
407
  */
337
- GIT_EXTERN(void) git_remote_set_autotag(git_remote *remote, int value);
408
+ GIT_EXTERN(void) git_remote_set_autotag(
409
+ git_remote *remote,
410
+ git_remote_autotag_option_t value);
411
+
412
+ /**
413
+ * Give the remote a new name
414
+ *
415
+ * All remote-tracking branches and configuration settings
416
+ * for the remote are updated.
417
+ *
418
+ * The new name will be checked for validity.
419
+ * See `git_tag_create()` for rules about valid names.
420
+ *
421
+ * A temporary in-memory remote cannot be given a name with this method.
422
+ *
423
+ * @param remote the remote to rename
424
+ * @param new_name the new name the remote should bear
425
+ * @param callback Optional callback to notify the consumer of fetch refspecs
426
+ * that haven't been automatically updated and need potential manual tweaking.
427
+ * @param payload Additional data to pass to the callback
428
+ * @return 0, GIT_EINVALIDSPEC, GIT_EEXISTS or an error code
429
+ */
430
+ GIT_EXTERN(int) git_remote_rename(
431
+ git_remote *remote,
432
+ const char *new_name,
433
+ git_remote_rename_problem_cb callback,
434
+ void *payload);
435
+
436
+ /**
437
+ * Retrieve the update FETCH_HEAD setting.
438
+ *
439
+ * @param remote the remote to query
440
+ * @return the update FETCH_HEAD setting
441
+ */
442
+ GIT_EXTERN(int) git_remote_update_fetchhead(git_remote *remote);
338
443
 
444
+ /**
445
+ * Sets the update FETCH_HEAD setting. By default, FETCH_HEAD will be
446
+ * updated on every fetch. Set to 0 to disable.
447
+ *
448
+ * @param remote the remote to configure
449
+ * @param value 0 to disable updating FETCH_HEAD
450
+ */
451
+ GIT_EXTERN(void) git_remote_set_update_fetchhead(git_remote *remote, int value);
452
+
453
+ /**
454
+ * Ensure the remote name is well-formed.
455
+ *
456
+ * @param remote_name name to be checked.
457
+ * @return 1 if the reference name is acceptable; 0 if it isn't
458
+ */
459
+ GIT_EXTERN(int) git_remote_is_valid_name(const char *remote_name);
339
460
 
340
461
  /** @} */
341
462
  GIT_END_DECL
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Copyright (C) 2009-2012 the libgit2 contributors
2
+ * Copyright (C) the libgit2 contributors. All rights reserved.
3
3
  *
4
4
  * This file is part of libgit2, distributed under the GNU GPL v2 with
5
5
  * a Linking Exception. For full terms see the included COPYING file.
@@ -29,11 +29,11 @@ GIT_BEGIN_DECL
29
29
  * The method will automatically detect if 'path' is a normal
30
30
  * or bare repository or fail is 'path' is neither.
31
31
  *
32
- * @param repository pointer to the repo which will be opened
32
+ * @param out pointer to the repo which will be opened
33
33
  * @param path the path to the repository
34
34
  * @return 0 or an error code
35
35
  */
36
- GIT_EXTERN(int) git_repository_open(git_repository **repository, const char *path);
36
+ GIT_EXTERN(int) git_repository_open(git_repository **out, const char *path);
37
37
 
38
38
  /**
39
39
  * Create a "fake" repository to wrap an object database
@@ -42,11 +42,11 @@ GIT_EXTERN(int) git_repository_open(git_repository **repository, const char *pat
42
42
  * with the API when all you have is an object database. This doesn't
43
43
  * have any paths associated with it, so use with care.
44
44
  *
45
- * @param repository pointer to the repo
45
+ * @param out pointer to the repo
46
46
  * @param odb the object database to wrap
47
47
  * @return 0 or an error code
48
48
  */
49
- GIT_EXTERN(int) git_repository_wrap_odb(git_repository **repository, git_odb *odb);
49
+ GIT_EXTERN(int) git_repository_wrap_odb(git_repository **out, git_odb *odb);
50
50
 
51
51
  /**
52
52
  * Look for a git repository and copy its path in the given buffer.
@@ -58,10 +58,10 @@ GIT_EXTERN(int) git_repository_wrap_odb(git_repository **repository, git_odb *od
58
58
  * The method will automatically detect if the repository is bare
59
59
  * (if there is a repository).
60
60
  *
61
- * @param repository_path The user allocated buffer which will
61
+ * @param path_out The user allocated buffer which will
62
62
  * contain the found path.
63
63
  *
64
- * @param size repository_path size
64
+ * @param path_size repository_path size
65
65
  *
66
66
  * @param start_path The base path where the lookup starts.
67
67
  *
@@ -77,8 +77,8 @@ GIT_EXTERN(int) git_repository_wrap_odb(git_repository **repository, git_odb *od
77
77
  * @return 0 or an error code
78
78
  */
79
79
  GIT_EXTERN(int) git_repository_discover(
80
- char *repository_path,
81
- size_t size,
80
+ char *path_out,
81
+ size_t path_size,
82
82
  const char *start_path,
83
83
  int across_fs,
84
84
  const char *ceiling_dirs);
@@ -95,18 +95,18 @@ GIT_EXTERN(int) git_repository_discover(
95
95
  * directory "/home/user/source/" will not return "/.git/" as the found
96
96
  * repo if "/" is a different filesystem than "/home".)
97
97
  */
98
- enum {
98
+ typedef enum {
99
99
  GIT_REPOSITORY_OPEN_NO_SEARCH = (1 << 0),
100
100
  GIT_REPOSITORY_OPEN_CROSS_FS = (1 << 1),
101
- };
101
+ } git_repository_open_flag_t;
102
102
 
103
103
  /**
104
104
  * Find and open a repository with extended controls.
105
105
  *
106
- * @param repo_out Pointer to the repo which will be opened. This can
106
+ * @param out Pointer to the repo which will be opened. This can
107
107
  * actually be NULL if you only want to use the error code to
108
108
  * see if a repo at this path could be opened.
109
- * @param start_path Path to open as git repository. If the flags
109
+ * @param path Path to open as git repository. If the flags
110
110
  * permit "searching", then this can be a path to a subdirectory
111
111
  * inside the working directory of the repository.
112
112
  * @param flags A combination of the GIT_REPOSITORY_OPEN flags above.
@@ -118,11 +118,24 @@ enum {
118
118
  * (such as repo corruption or system errors).
119
119
  */
120
120
  GIT_EXTERN(int) git_repository_open_ext(
121
- git_repository **repo,
122
- const char *start_path,
123
- uint32_t flags,
121
+ git_repository **out,
122
+ const char *path,
123
+ unsigned int flags,
124
124
  const char *ceiling_dirs);
125
125
 
126
+ /**
127
+ * Open a bare repository on the serverside.
128
+ *
129
+ * This is a fast open for bare repositories that will come in handy
130
+ * if you're e.g. hosting git repositories and need to access them
131
+ * efficiently
132
+ *
133
+ * @param out Pointer to the repo which will be opened.
134
+ * @param bare_path Direct path to the bare repository
135
+ * @return 0 on success, or an error code
136
+ */
137
+ GIT_EXTERN(int) git_repository_open_bare(git_repository **out, const char *bare_path);
138
+
126
139
  /**
127
140
  * Free a previously allocated repository
128
141
  *
@@ -142,7 +155,7 @@ GIT_EXTERN(void) git_repository_free(git_repository *repo);
142
155
  * TODO:
143
156
  * - Reinit the repository
144
157
  *
145
- * @param repo_out pointer to the repo which will be created or reinitialized
158
+ * @param out pointer to the repo which will be created or reinitialized
146
159
  * @param path the path to the repository
147
160
  * @param is_bare if true, a Git repository without a working directory is
148
161
  * created at the pointed path. If false, provided path will be
@@ -152,7 +165,7 @@ GIT_EXTERN(void) git_repository_free(git_repository *repo);
152
165
  * @return 0 or an error code
153
166
  */
154
167
  GIT_EXTERN(int) git_repository_init(
155
- git_repository **repo_out,
168
+ git_repository **out,
156
169
  const char *path,
157
170
  unsigned is_bare);
158
171
 
@@ -182,14 +195,14 @@ GIT_EXTERN(int) git_repository_init(
182
195
  * `init.templatedir` global config if not, or falling back on
183
196
  * "/usr/share/git-core/templates" if it exists.
184
197
  */
185
- enum {
198
+ typedef enum {
186
199
  GIT_REPOSITORY_INIT_BARE = (1u << 0),
187
200
  GIT_REPOSITORY_INIT_NO_REINIT = (1u << 1),
188
201
  GIT_REPOSITORY_INIT_NO_DOTGIT_DIR = (1u << 2),
189
202
  GIT_REPOSITORY_INIT_MKDIR = (1u << 3),
190
203
  GIT_REPOSITORY_INIT_MKPATH = (1u << 4),
191
204
  GIT_REPOSITORY_INIT_EXTERNAL_TEMPLATE = (1u << 5),
192
- };
205
+ } git_repository_init_flag_t;
193
206
 
194
207
  /**
195
208
  * Mode options for `git_repository_init_ext`.
@@ -204,11 +217,11 @@ enum {
204
217
  * * SHARED_ALL - Use "--shared=all" behavior, adding world readability.
205
218
  * * Anything else - Set to custom value.
206
219
  */
207
- enum {
220
+ typedef enum {
208
221
  GIT_REPOSITORY_INIT_SHARED_UMASK = 0,
209
222
  GIT_REPOSITORY_INIT_SHARED_GROUP = 0002775,
210
223
  GIT_REPOSITORY_INIT_SHARED_ALL = 0002777,
211
- };
224
+ } git_repository_init_mode_t;
212
225
 
213
226
  /**
214
227
  * Extended options structure for `git_repository_init_ext`.
@@ -239,6 +252,7 @@ enum {
239
252
  * will be added pointing to this URL.
240
253
  */
241
254
  typedef struct {
255
+ unsigned int version;
242
256
  uint32_t flags;
243
257
  uint32_t mode;
244
258
  const char *workdir_path;
@@ -248,6 +262,9 @@ typedef struct {
248
262
  const char *origin_url;
249
263
  } git_repository_init_options;
250
264
 
265
+ #define GIT_REPOSITORY_INIT_OPTIONS_VERSION 1
266
+ #define GIT_REPOSITORY_INIT_OPTIONS_INIT {GIT_REPOSITORY_INIT_OPTIONS_VERSION}
267
+
251
268
  /**
252
269
  * Create a new Git repository in the given folder with extended controls.
253
270
  *
@@ -256,26 +273,30 @@ typedef struct {
256
273
  * auto-detect the case sensitivity of the file system and if the
257
274
  * file system supports file mode bits correctly.
258
275
  *
259
- * @param repo_out Pointer to the repo which will be created or reinitialized.
276
+ * @param out Pointer to the repo which will be created or reinitialized.
260
277
  * @param repo_path The path to the repository.
261
278
  * @param opts Pointer to git_repository_init_options struct.
262
279
  * @return 0 or an error code on failure.
263
280
  */
264
281
  GIT_EXTERN(int) git_repository_init_ext(
265
- git_repository **repo_out,
282
+ git_repository **out,
266
283
  const char *repo_path,
267
284
  git_repository_init_options *opts);
268
285
 
269
286
  /**
270
287
  * Retrieve and resolve the reference pointed at by HEAD.
271
288
  *
272
- * @param head_out pointer to the reference which will be retrieved
289
+ * The returned `git_reference` will be owned by caller and
290
+ * `git_reference_free()` must be called when done with it to release the
291
+ * allocated memory and prevent a leak.
292
+ *
293
+ * @param out pointer to the reference which will be retrieved
273
294
  * @param repo a repository object
274
295
  *
275
296
  * @return 0 on success, GIT_EORPHANEDHEAD when HEAD points to a non existing
276
- * branch, an error code otherwise
297
+ * branch, GIT_ENOTFOUND when HEAD is missing; an error code otherwise
277
298
  */
278
- GIT_EXTERN(int) git_repository_head(git_reference **head_out, git_repository *repo);
299
+ GIT_EXTERN(int) git_repository_head(git_reference **out, git_repository *repo);
279
300
 
280
301
  /**
281
302
  * Check if a repository's HEAD is detached
@@ -305,7 +326,7 @@ GIT_EXTERN(int) git_repository_head_orphan(git_repository *repo);
305
326
  * Check if a repository is empty
306
327
  *
307
328
  * An empty repository has just been initialized and contains
308
- * no commits.
329
+ * no references.
309
330
  *
310
331
  * @param repo Repo to test
311
332
  * @return 1 if the repository is empty, 0 if it isn't, error code
@@ -425,6 +446,39 @@ GIT_EXTERN(int) git_repository_odb(git_odb **out, git_repository *repo);
425
446
  */
426
447
  GIT_EXTERN(void) git_repository_set_odb(git_repository *repo, git_odb *odb);
427
448
 
449
+ /**
450
+ * Get the Reference Database Backend for this repository.
451
+ *
452
+ * If a custom refsdb has not been set, the default database for
453
+ * the repository will be returned (the one that manipulates loose
454
+ * and packed references in the `.git` directory).
455
+ *
456
+ * The refdb must be freed once it's no longer being used by
457
+ * the user.
458
+ *
459
+ * @param out Pointer to store the loaded refdb
460
+ * @param repo A repository object
461
+ * @return 0, or an error code
462
+ */
463
+ GIT_EXTERN(int) git_repository_refdb(git_refdb **out, git_repository *repo);
464
+
465
+ /**
466
+ * Set the Reference Database Backend for this repository
467
+ *
468
+ * The refdb will be used for all reference related operations
469
+ * involving this repository.
470
+ *
471
+ * The repository will keep a reference to the refdb; the user
472
+ * must still free the refdb object after setting it to the
473
+ * repository, or it will leak.
474
+ *
475
+ * @param repo A repository object
476
+ * @param refdb An refdb object
477
+ */
478
+ GIT_EXTERN(void) git_repository_set_refdb(
479
+ git_repository *repo,
480
+ git_refdb *refdb);
481
+
428
482
  /**
429
483
  * Get the Index file for this repository.
430
484
  *
@@ -468,12 +522,12 @@ GIT_EXTERN(void) git_repository_set_index(git_repository *repo, git_index *index
468
522
  * Use this function to get the contents of this file. Don't forget to
469
523
  * remove the file after you create the commit.
470
524
  *
471
- * @param buffer Buffer to write data into or NULL to just read required size
525
+ * @param out Buffer to write data into or NULL to just read required size
472
526
  * @param len Length of buffer in bytes
473
527
  * @param repo Repository to read prepared message from
474
528
  * @return Bytes written to buffer, GIT_ENOTFOUND if no message, or -1 on error
475
529
  */
476
- GIT_EXTERN(int) git_repository_message(char *buffer, size_t len, git_repository *repo);
530
+ GIT_EXTERN(int) git_repository_message(char *out, size_t len, git_repository *repo);
477
531
 
478
532
  /**
479
533
  * Remove git's prepared message.
@@ -482,6 +536,49 @@ GIT_EXTERN(int) git_repository_message(char *buffer, size_t len, git_repository
482
536
  */
483
537
  GIT_EXTERN(int) git_repository_message_remove(git_repository *repo);
484
538
 
539
+ /**
540
+ * Remove all the metadata associated with an ongoing git merge, including
541
+ * MERGE_HEAD, MERGE_MSG, etc.
542
+ *
543
+ * @param repo A repository object
544
+ * @return 0 on success, or error
545
+ */
546
+ GIT_EXTERN(int) git_repository_merge_cleanup(git_repository *repo);
547
+
548
+ typedef int (*git_repository_fetchhead_foreach_cb)(const char *ref_name,
549
+ const char *remote_url,
550
+ const git_oid *oid,
551
+ unsigned int is_merge,
552
+ void *payload);
553
+
554
+ /**
555
+ * Call callback 'callback' for each entry in the given FETCH_HEAD file.
556
+ *
557
+ * @param repo A repository object
558
+ * @param callback Callback function
559
+ * @param payload Pointer to callback data (optional)
560
+ * @return 0 on success, GIT_ENOTFOUND, GIT_EUSER or error
561
+ */
562
+ GIT_EXTERN(int) git_repository_fetchhead_foreach(git_repository *repo,
563
+ git_repository_fetchhead_foreach_cb callback,
564
+ void *payload);
565
+
566
+ typedef int (*git_repository_mergehead_foreach_cb)(const git_oid *oid,
567
+ void *payload);
568
+
569
+ /**
570
+ * If a merge is in progress, call callback 'cb' for each commit ID in the
571
+ * MERGE_HEAD file.
572
+ *
573
+ * @param repo A repository object
574
+ * @param callback Callback function
575
+ * @param apyload Pointer to callback data (optional)
576
+ * @return 0 on success, GIT_ENOTFOUND, GIT_EUSER or error
577
+ */
578
+ GIT_EXTERN(int) git_repository_mergehead_foreach(git_repository *repo,
579
+ git_repository_mergehead_foreach_cb callback,
580
+ void *payload);
581
+
485
582
  /**
486
583
  * Calculate hash of file using repository filtering rules.
487
584
  *
@@ -558,7 +655,7 @@ GIT_EXTERN(int) git_repository_set_head_detached(
558
655
  * updated into making it point to the peeled Commit, and 0 is returned.
559
656
  *
560
657
  * If the HEAD is already detached and points to a non commitish, the HEAD is
561
- * unaletered, and -1 is returned.
658
+ * unaltered, and -1 is returned.
562
659
  *
563
660
  * Otherwise, the HEAD will be detached and point to the peeled Commit.
564
661
  *
@@ -569,6 +666,28 @@ GIT_EXTERN(int) git_repository_set_head_detached(
569
666
  GIT_EXTERN(int) git_repository_detach_head(
570
667
  git_repository* repo);
571
668
 
669
+ typedef enum {
670
+ GIT_REPOSITORY_STATE_NONE,
671
+ GIT_REPOSITORY_STATE_MERGE,
672
+ GIT_REPOSITORY_STATE_REVERT,
673
+ GIT_REPOSITORY_STATE_CHERRY_PICK,
674
+ GIT_REPOSITORY_STATE_BISECT,
675
+ GIT_REPOSITORY_STATE_REBASE,
676
+ GIT_REPOSITORY_STATE_REBASE_INTERACTIVE,
677
+ GIT_REPOSITORY_STATE_REBASE_MERGE,
678
+ GIT_REPOSITORY_STATE_APPLY_MAILBOX,
679
+ GIT_REPOSITORY_STATE_APPLY_MAILBOX_OR_REBASE,
680
+ } git_repository_state_t;
681
+
682
+ /**
683
+ * Determines the status of a git repository - ie, whether an operation
684
+ * (merge, cherry-pick, etc) is in progress.
685
+ *
686
+ * @param repo Repository pointer
687
+ * @return The state of the repository
688
+ */
689
+ GIT_EXTERN(int) git_repository_state(git_repository *repo);
690
+
572
691
  /** @} */
573
692
  GIT_END_DECL
574
693
  #endif