rugged 0.16.0 → 0.17.0b1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (392) hide show
  1. data/README.md +373 -243
  2. data/Rakefile +22 -0
  3. data/ext/rugged/extconf.rb +9 -6
  4. data/ext/rugged/rugged.c +123 -31
  5. data/ext/rugged/rugged.h +11 -10
  6. data/ext/rugged/rugged_blob.c +181 -18
  7. data/ext/rugged/rugged_commit.c +196 -18
  8. data/ext/rugged/rugged_config.c +94 -5
  9. data/ext/rugged/rugged_object.c +54 -1
  10. data/ext/rugged/rugged_reference.c +203 -15
  11. data/ext/rugged/{remote.c → rugged_remote.c} +35 -10
  12. data/ext/rugged/rugged_repo.c +323 -81
  13. data/ext/rugged/rugged_revwalk.c +57 -4
  14. data/ext/rugged/rugged_signature.c +3 -3
  15. data/ext/rugged/rugged_tag.c +72 -1
  16. data/ext/rugged/rugged_tree.c +70 -2
  17. data/ext/rugged/vendor/libgit2-dist/deps/regex/config.h +7 -0
  18. data/ext/rugged/vendor/libgit2-dist/deps/regex/regcomp.c +3856 -0
  19. data/ext/rugged/vendor/libgit2-dist/deps/regex/regex.c +85 -0
  20. data/ext/rugged/vendor/libgit2-dist/deps/regex/regex.h +582 -0
  21. data/ext/rugged/vendor/libgit2-dist/deps/regex/regex_internal.c +1744 -0
  22. data/ext/rugged/vendor/libgit2-dist/deps/regex/regex_internal.h +810 -0
  23. data/ext/rugged/vendor/libgit2-dist/deps/regex/regexec.c +4369 -0
  24. data/ext/rugged/vendor/libgit2-dist/examples/diff.c +238 -0
  25. data/ext/rugged/vendor/libgit2-dist/examples/general.c +4 -4
  26. data/ext/rugged/vendor/libgit2-dist/examples/network/fetch.c +101 -85
  27. data/ext/rugged/vendor/libgit2-dist/examples/network/git2.c +7 -3
  28. data/ext/rugged/vendor/libgit2-dist/examples/network/index-pack.c +80 -25
  29. data/ext/rugged/vendor/libgit2-dist/examples/network/ls-remote.c +6 -6
  30. data/ext/rugged/vendor/libgit2-dist/include/git2/attr.h +224 -0
  31. data/ext/rugged/vendor/libgit2-dist/include/git2/blob.h +59 -5
  32. data/ext/rugged/vendor/libgit2-dist/include/git2/branch.h +114 -7
  33. data/ext/rugged/vendor/libgit2-dist/include/git2/commit.h +14 -7
  34. data/ext/rugged/vendor/libgit2-dist/include/git2/common.h +4 -3
  35. data/ext/rugged/vendor/libgit2-dist/include/git2/config.h +105 -27
  36. data/ext/rugged/vendor/libgit2-dist/include/git2/diff.h +409 -0
  37. data/ext/rugged/vendor/libgit2-dist/include/git2/errors.h +47 -82
  38. data/ext/rugged/vendor/libgit2-dist/include/git2/index.h +25 -10
  39. data/ext/rugged/vendor/libgit2-dist/include/git2/indexer.h +46 -1
  40. data/ext/rugged/vendor/libgit2-dist/include/git2/merge.h +35 -0
  41. data/ext/rugged/vendor/libgit2-dist/include/git2/net.h +1 -1
  42. data/ext/rugged/vendor/libgit2-dist/include/git2/notes.h +139 -0
  43. data/ext/rugged/vendor/libgit2-dist/include/git2/object.h +5 -5
  44. data/ext/rugged/vendor/libgit2-dist/include/git2/odb.h +13 -13
  45. data/ext/rugged/vendor/libgit2-dist/include/git2/odb_backend.h +8 -8
  46. data/ext/rugged/vendor/libgit2-dist/include/git2/oid.h +14 -9
  47. data/ext/rugged/vendor/libgit2-dist/include/git2/reflog.h +5 -5
  48. data/ext/rugged/vendor/libgit2-dist/include/git2/refs.h +37 -17
  49. data/ext/rugged/vendor/libgit2-dist/include/git2/refspec.h +17 -9
  50. data/ext/rugged/vendor/libgit2-dist/include/git2/remote.h +83 -16
  51. data/ext/rugged/vendor/libgit2-dist/include/git2/repository.h +24 -10
  52. data/ext/rugged/vendor/libgit2-dist/include/git2/reset.h +44 -0
  53. data/ext/rugged/vendor/libgit2-dist/include/git2/revparse.h +36 -0
  54. data/ext/rugged/vendor/libgit2-dist/include/git2/revwalk.h +74 -6
  55. data/ext/rugged/vendor/libgit2-dist/include/git2/signature.h +3 -3
  56. data/ext/rugged/vendor/libgit2-dist/include/git2/status.h +120 -19
  57. data/ext/rugged/vendor/libgit2-dist/include/git2/submodule.h +103 -0
  58. data/ext/rugged/vendor/libgit2-dist/include/git2/tag.h +28 -10
  59. data/ext/rugged/vendor/libgit2-dist/include/git2/threads.h +1 -1
  60. data/ext/rugged/vendor/libgit2-dist/include/git2/tree.h +13 -13
  61. data/ext/rugged/vendor/libgit2-dist/include/git2/types.h +16 -2
  62. data/ext/rugged/vendor/libgit2-dist/include/git2/version.h +3 -3
  63. data/ext/rugged/vendor/libgit2-dist/include/git2/windows.h +1 -1
  64. data/ext/rugged/vendor/libgit2-dist/include/git2.h +7 -2
  65. data/ext/rugged/vendor/libgit2-dist/src/attr.c +677 -0
  66. data/ext/rugged/vendor/libgit2-dist/src/attr.h +56 -0
  67. data/ext/rugged/vendor/libgit2-dist/src/attr_file.c +609 -0
  68. data/ext/rugged/vendor/libgit2-dist/src/attr_file.h +145 -0
  69. data/ext/rugged/vendor/libgit2-dist/src/blob.c +213 -60
  70. data/ext/rugged/vendor/libgit2-dist/src/blob.h +2 -1
  71. data/ext/rugged/vendor/libgit2-dist/src/branch.c +208 -0
  72. data/ext/rugged/vendor/libgit2-dist/src/branch.h +17 -0
  73. data/ext/rugged/vendor/libgit2-dist/src/bswap.h +1 -1
  74. data/ext/rugged/vendor/libgit2-dist/src/buffer.c +395 -46
  75. data/ext/rugged/vendor/libgit2-dist/src/buffer.h +112 -9
  76. data/ext/rugged/vendor/libgit2-dist/src/cache.c +37 -49
  77. data/ext/rugged/vendor/libgit2-dist/src/cache.h +7 -17
  78. data/ext/rugged/vendor/libgit2-dist/src/cc-compat.h +18 -16
  79. data/ext/rugged/vendor/libgit2-dist/src/commit.c +56 -90
  80. data/ext/rugged/vendor/libgit2-dist/src/commit.h +1 -1
  81. data/ext/rugged/vendor/libgit2-dist/src/common.h +12 -5
  82. data/ext/rugged/vendor/libgit2-dist/src/{win32 → compat}/fnmatch.c +1 -1
  83. data/ext/rugged/vendor/libgit2-dist/src/{win32 → compat}/fnmatch.h +3 -3
  84. data/ext/rugged/vendor/libgit2-dist/src/config.c +247 -158
  85. data/ext/rugged/vendor/libgit2-dist/src/config.h +10 -1
  86. data/ext/rugged/vendor/libgit2-dist/src/config_cache.c +94 -0
  87. data/ext/rugged/vendor/libgit2-dist/src/config_file.c +606 -496
  88. data/ext/rugged/vendor/libgit2-dist/src/config_file.h +31 -0
  89. data/ext/rugged/vendor/libgit2-dist/src/crlf.c +228 -0
  90. data/ext/rugged/vendor/libgit2-dist/src/date.c +876 -0
  91. data/ext/rugged/vendor/libgit2-dist/src/delta-apply.c +15 -9
  92. data/ext/rugged/vendor/libgit2-dist/src/delta-apply.h +2 -2
  93. data/ext/rugged/vendor/libgit2-dist/src/diff.c +814 -0
  94. data/ext/rugged/vendor/libgit2-dist/src/diff.h +43 -0
  95. data/ext/rugged/vendor/libgit2-dist/src/diff_output.c +794 -0
  96. data/ext/rugged/vendor/libgit2-dist/src/errors.c +89 -74
  97. data/ext/rugged/vendor/libgit2-dist/src/fetch.c +94 -66
  98. data/ext/rugged/vendor/libgit2-dist/src/fetch.h +5 -4
  99. data/ext/rugged/vendor/libgit2-dist/src/filebuf.c +157 -100
  100. data/ext/rugged/vendor/libgit2-dist/src/filebuf.h +22 -8
  101. data/ext/rugged/vendor/libgit2-dist/src/fileops.c +330 -206
  102. data/ext/rugged/vendor/libgit2-dist/src/fileops.h +82 -51
  103. data/ext/rugged/vendor/libgit2-dist/src/filter.c +165 -0
  104. data/ext/rugged/vendor/libgit2-dist/src/filter.h +119 -0
  105. data/ext/rugged/vendor/libgit2-dist/src/global.c +4 -4
  106. data/ext/rugged/vendor/libgit2-dist/src/global.h +4 -1
  107. data/ext/rugged/vendor/libgit2-dist/src/hash.c +1 -1
  108. data/ext/rugged/vendor/libgit2-dist/src/hash.h +1 -1
  109. data/ext/rugged/vendor/libgit2-dist/src/ignore.c +203 -0
  110. data/ext/rugged/vendor/libgit2-dist/src/ignore.h +38 -0
  111. data/ext/rugged/vendor/libgit2-dist/src/index.c +220 -169
  112. data/ext/rugged/vendor/libgit2-dist/src/index.h +5 -1
  113. data/ext/rugged/vendor/libgit2-dist/src/indexer.c +601 -102
  114. data/ext/rugged/vendor/libgit2-dist/src/iterator.c +748 -0
  115. data/ext/rugged/vendor/libgit2-dist/src/iterator.h +151 -0
  116. data/ext/rugged/vendor/libgit2-dist/src/khash.h +608 -0
  117. data/ext/rugged/vendor/libgit2-dist/src/map.h +6 -1
  118. data/ext/rugged/vendor/libgit2-dist/src/message.c +61 -0
  119. data/ext/rugged/vendor/libgit2-dist/src/message.h +14 -0
  120. data/ext/rugged/vendor/libgit2-dist/src/mwindow.c +27 -29
  121. data/ext/rugged/vendor/libgit2-dist/src/mwindow.h +4 -4
  122. data/ext/rugged/vendor/libgit2-dist/src/netops.c +375 -56
  123. data/ext/rugged/vendor/libgit2-dist/src/netops.h +12 -9
  124. data/ext/rugged/vendor/libgit2-dist/src/notes.c +548 -0
  125. data/ext/rugged/vendor/libgit2-dist/src/notes.h +28 -0
  126. data/ext/rugged/vendor/libgit2-dist/src/object.c +59 -21
  127. data/ext/rugged/vendor/libgit2-dist/src/odb.c +212 -175
  128. data/ext/rugged/vendor/libgit2-dist/src/odb.h +39 -2
  129. data/ext/rugged/vendor/libgit2-dist/src/odb_loose.c +238 -241
  130. data/ext/rugged/vendor/libgit2-dist/src/odb_pack.c +94 -106
  131. data/ext/rugged/vendor/libgit2-dist/src/oid.c +59 -60
  132. data/ext/rugged/vendor/libgit2-dist/src/oidmap.h +42 -0
  133. data/ext/rugged/vendor/libgit2-dist/src/pack.c +198 -170
  134. data/ext/rugged/vendor/libgit2-dist/src/pack.h +16 -9
  135. data/ext/rugged/vendor/libgit2-dist/src/path.c +496 -106
  136. data/ext/rugged/vendor/libgit2-dist/src/path.h +214 -20
  137. data/ext/rugged/vendor/libgit2-dist/src/pkt.c +88 -159
  138. data/ext/rugged/vendor/libgit2-dist/src/pkt.h +9 -5
  139. data/ext/rugged/vendor/libgit2-dist/src/pool.c +294 -0
  140. data/ext/rugged/vendor/libgit2-dist/src/pool.h +125 -0
  141. data/ext/rugged/vendor/libgit2-dist/src/posix.c +38 -16
  142. data/ext/rugged/vendor/libgit2-dist/src/posix.h +20 -2
  143. data/ext/rugged/vendor/libgit2-dist/src/ppc/sha1.c +1 -1
  144. data/ext/rugged/vendor/libgit2-dist/src/ppc/sha1.h +1 -1
  145. data/ext/rugged/vendor/libgit2-dist/src/pqueue.c +7 -7
  146. data/ext/rugged/vendor/libgit2-dist/src/pqueue.h +1 -1
  147. data/ext/rugged/vendor/libgit2-dist/src/protocol.c +21 -13
  148. data/ext/rugged/vendor/libgit2-dist/src/protocol.h +1 -1
  149. data/ext/rugged/vendor/libgit2-dist/src/reflog.c +125 -103
  150. data/ext/rugged/vendor/libgit2-dist/src/reflog.h +1 -1
  151. data/ext/rugged/vendor/libgit2-dist/src/refs.c +713 -640
  152. data/ext/rugged/vendor/libgit2-dist/src/refs.h +27 -3
  153. data/ext/rugged/vendor/libgit2-dist/src/refspec.c +51 -17
  154. data/ext/rugged/vendor/libgit2-dist/src/refspec.h +13 -1
  155. data/ext/rugged/vendor/libgit2-dist/src/remote.c +307 -119
  156. data/ext/rugged/vendor/libgit2-dist/src/remote.h +3 -2
  157. data/ext/rugged/vendor/libgit2-dist/src/repository.c +593 -442
  158. data/ext/rugged/vendor/libgit2-dist/src/repository.h +80 -2
  159. data/ext/rugged/vendor/libgit2-dist/src/reset.c +103 -0
  160. data/ext/rugged/vendor/libgit2-dist/src/revparse.c +753 -0
  161. data/ext/rugged/vendor/libgit2-dist/src/revwalk.c +434 -158
  162. data/ext/rugged/vendor/libgit2-dist/src/sha1.c +3 -3
  163. data/ext/rugged/vendor/libgit2-dist/src/sha1.h +2 -2
  164. data/ext/rugged/vendor/libgit2-dist/src/sha1_lookup.c +3 -2
  165. data/ext/rugged/vendor/libgit2-dist/src/sha1_lookup.h +1 -1
  166. data/ext/rugged/vendor/libgit2-dist/src/signature.c +69 -80
  167. data/ext/rugged/vendor/libgit2-dist/src/signature.h +1 -1
  168. data/ext/rugged/vendor/libgit2-dist/src/status.c +184 -638
  169. data/ext/rugged/vendor/libgit2-dist/src/strmap.h +64 -0
  170. data/ext/rugged/vendor/libgit2-dist/src/submodule.c +387 -0
  171. data/ext/rugged/vendor/libgit2-dist/src/tag.c +162 -137
  172. data/ext/rugged/vendor/libgit2-dist/src/tag.h +2 -1
  173. data/ext/rugged/vendor/libgit2-dist/src/thread-utils.c +1 -1
  174. data/ext/rugged/vendor/libgit2-dist/src/thread-utils.h +8 -8
  175. data/ext/rugged/vendor/libgit2-dist/src/transport.c +31 -19
  176. data/ext/rugged/vendor/libgit2-dist/src/transport.h +31 -11
  177. data/ext/rugged/vendor/libgit2-dist/src/transports/git.c +168 -193
  178. data/ext/rugged/vendor/libgit2-dist/src/transports/http.c +192 -241
  179. data/ext/rugged/vendor/libgit2-dist/src/transports/local.c +92 -86
  180. data/ext/rugged/vendor/libgit2-dist/src/tree-cache.c +32 -49
  181. data/ext/rugged/vendor/libgit2-dist/src/tree-cache.h +1 -1
  182. data/ext/rugged/vendor/libgit2-dist/src/tree.c +172 -145
  183. data/ext/rugged/vendor/libgit2-dist/src/tree.h +16 -2
  184. data/ext/rugged/vendor/libgit2-dist/src/tsort.c +16 -14
  185. data/ext/rugged/vendor/libgit2-dist/src/unix/map.c +8 -24
  186. data/ext/rugged/vendor/libgit2-dist/src/unix/posix.h +9 -3
  187. data/ext/rugged/vendor/libgit2-dist/src/util.c +94 -38
  188. data/ext/rugged/vendor/libgit2-dist/src/util.h +119 -13
  189. data/ext/rugged/vendor/libgit2-dist/src/vector.c +84 -31
  190. data/ext/rugged/vendor/libgit2-dist/src/vector.h +37 -4
  191. data/ext/rugged/vendor/libgit2-dist/src/win32/dir.c +81 -41
  192. data/ext/rugged/vendor/libgit2-dist/src/{dir.h → win32/dir.h} +4 -9
  193. data/ext/rugged/vendor/libgit2-dist/src/win32/map.c +19 -35
  194. data/ext/rugged/vendor/libgit2-dist/src/win32/mingw-compat.h +1 -1
  195. data/ext/rugged/vendor/libgit2-dist/src/win32/msvc-compat.h +5 -1
  196. data/ext/rugged/vendor/libgit2-dist/src/win32/posix.h +10 -8
  197. data/ext/rugged/vendor/libgit2-dist/src/win32/posix_w32.c +262 -118
  198. data/ext/rugged/vendor/libgit2-dist/src/win32/pthread.c +12 -9
  199. data/ext/rugged/vendor/libgit2-dist/src/win32/pthread.h +1 -1
  200. data/ext/rugged/vendor/libgit2-dist/src/win32/utf-conv.c +30 -26
  201. data/ext/rugged/vendor/libgit2-dist/src/win32/utf-conv.h +2 -1
  202. data/ext/rugged/vendor/libgit2-dist/src/xdiff/xdiff.h +135 -0
  203. data/ext/rugged/vendor/libgit2-dist/src/xdiff/xdiffi.c +572 -0
  204. data/ext/rugged/vendor/libgit2-dist/src/xdiff/xdiffi.h +63 -0
  205. data/ext/rugged/vendor/libgit2-dist/src/xdiff/xemit.c +253 -0
  206. data/ext/rugged/vendor/libgit2-dist/src/xdiff/xemit.h +36 -0
  207. data/ext/rugged/vendor/libgit2-dist/src/xdiff/xhistogram.c +371 -0
  208. data/ext/rugged/vendor/libgit2-dist/src/xdiff/xinclude.h +46 -0
  209. data/ext/rugged/vendor/libgit2-dist/src/xdiff/xmacros.h +54 -0
  210. data/ext/rugged/vendor/libgit2-dist/src/xdiff/xmerge.c +619 -0
  211. data/ext/rugged/vendor/libgit2-dist/src/xdiff/xpatience.c +358 -0
  212. data/ext/rugged/vendor/libgit2-dist/src/xdiff/xprepare.c +483 -0
  213. data/ext/rugged/vendor/libgit2-dist/src/xdiff/xprepare.h +34 -0
  214. data/ext/rugged/vendor/libgit2-dist/src/xdiff/xtypes.h +67 -0
  215. data/ext/rugged/vendor/libgit2-dist/src/xdiff/xutils.c +419 -0
  216. data/ext/rugged/vendor/libgit2-dist/src/xdiff/xutils.h +49 -0
  217. data/ext/rugged/vendor/libgit2-dist/tests-clar/attr/attr_expect.h +43 -0
  218. data/ext/rugged/vendor/libgit2-dist/tests-clar/attr/file.c +226 -0
  219. data/ext/rugged/vendor/libgit2-dist/tests-clar/attr/flags.c +108 -0
  220. data/ext/rugged/vendor/libgit2-dist/tests-clar/attr/lookup.c +262 -0
  221. data/ext/rugged/vendor/libgit2-dist/tests-clar/attr/repo.c +273 -0
  222. data/ext/rugged/vendor/libgit2-dist/{tests-clay → tests-clar}/buf/basic.c +5 -5
  223. data/ext/rugged/vendor/libgit2-dist/tests-clar/clar_helpers.c +181 -0
  224. data/ext/rugged/vendor/libgit2-dist/tests-clar/clar_libgit2.h +55 -0
  225. data/ext/rugged/vendor/libgit2-dist/tests-clar/commit/commit.c +44 -0
  226. data/ext/rugged/vendor/libgit2-dist/tests-clar/commit/parse.c +350 -0
  227. data/ext/rugged/vendor/libgit2-dist/tests-clar/commit/signature.c +65 -0
  228. data/ext/rugged/vendor/libgit2-dist/tests-clar/commit/write.c +140 -0
  229. data/ext/rugged/vendor/libgit2-dist/{tests-clay → tests-clar}/config/add.c +3 -3
  230. data/ext/rugged/vendor/libgit2-dist/tests-clar/config/multivar.c +151 -0
  231. data/ext/rugged/vendor/libgit2-dist/{tests-clay → tests-clar}/config/new.c +5 -5
  232. data/ext/rugged/vendor/libgit2-dist/{tests-clay → tests-clar}/config/read.c +44 -32
  233. data/ext/rugged/vendor/libgit2-dist/tests-clar/config/stress.c +61 -0
  234. data/ext/rugged/vendor/libgit2-dist/{tests-clay → tests-clar}/config/write.c +20 -5
  235. data/ext/rugged/vendor/libgit2-dist/tests-clar/core/buffer.c +613 -0
  236. data/ext/rugged/vendor/libgit2-dist/{tests-clay → tests-clar}/core/dirent.c +39 -26
  237. data/ext/rugged/vendor/libgit2-dist/tests-clar/core/env.c +115 -0
  238. data/ext/rugged/vendor/libgit2-dist/tests-clar/core/errors.c +60 -0
  239. data/ext/rugged/vendor/libgit2-dist/{tests-clay → tests-clar}/core/filebuf.c +4 -18
  240. data/ext/rugged/vendor/libgit2-dist/tests-clar/core/hex.c +22 -0
  241. data/ext/rugged/vendor/libgit2-dist/{tests-clay → tests-clar}/core/oid.c +6 -6
  242. data/ext/rugged/vendor/libgit2-dist/tests-clar/core/path.c +420 -0
  243. data/ext/rugged/vendor/libgit2-dist/tests-clar/core/pool.c +85 -0
  244. data/ext/rugged/vendor/libgit2-dist/tests-clar/core/rmdir.c +68 -0
  245. data/ext/rugged/vendor/libgit2-dist/{tests-clay → tests-clar}/core/string.c +1 -1
  246. data/ext/rugged/vendor/libgit2-dist/tests-clar/core/strmap.c +102 -0
  247. data/ext/rugged/vendor/libgit2-dist/{tests-clay → tests-clar}/core/strtol.c +1 -1
  248. data/ext/rugged/vendor/libgit2-dist/tests-clar/core/vector.c +191 -0
  249. data/ext/rugged/vendor/libgit2-dist/tests-clar/date/date.c +15 -0
  250. data/ext/rugged/vendor/libgit2-dist/tests-clar/diff/blob.c +254 -0
  251. data/ext/rugged/vendor/libgit2-dist/tests-clar/diff/diff_helpers.c +104 -0
  252. data/ext/rugged/vendor/libgit2-dist/tests-clar/diff/diff_helpers.h +47 -0
  253. data/ext/rugged/vendor/libgit2-dist/tests-clar/diff/index.c +92 -0
  254. data/ext/rugged/vendor/libgit2-dist/tests-clar/diff/iterator.c +572 -0
  255. data/ext/rugged/vendor/libgit2-dist/tests-clar/diff/patch.c +99 -0
  256. data/ext/rugged/vendor/libgit2-dist/tests-clar/diff/tree.c +210 -0
  257. data/ext/rugged/vendor/libgit2-dist/tests-clar/diff/workdir.c +543 -0
  258. data/ext/rugged/vendor/libgit2-dist/tests-clar/index/read_tree.c +46 -0
  259. data/ext/rugged/vendor/libgit2-dist/{tests-clay → tests-clar}/index/rename.c +2 -12
  260. data/ext/rugged/vendor/libgit2-dist/tests-clar/index/tests.c +246 -0
  261. data/ext/rugged/vendor/libgit2-dist/tests-clar/network/createremotethenload.c +33 -0
  262. data/ext/rugged/vendor/libgit2-dist/tests-clar/network/remotelocal.c +137 -0
  263. data/ext/rugged/vendor/libgit2-dist/tests-clar/network/remotes.c +183 -0
  264. data/ext/rugged/vendor/libgit2-dist/tests-clar/notes/notes.c +133 -0
  265. data/ext/rugged/vendor/libgit2-dist/tests-clar/notes/notesref.c +57 -0
  266. data/ext/rugged/vendor/libgit2-dist/tests-clar/object/blob/filter.c +125 -0
  267. data/ext/rugged/vendor/libgit2-dist/tests-clar/object/blob/fromchunks.c +87 -0
  268. data/ext/rugged/vendor/libgit2-dist/tests-clar/object/blob/write.c +69 -0
  269. data/ext/rugged/vendor/libgit2-dist/tests-clar/object/commit/commitstagedfile.c +126 -0
  270. data/ext/rugged/vendor/libgit2-dist/tests-clar/object/lookup.c +63 -0
  271. data/ext/rugged/vendor/libgit2-dist/tests-clar/object/message.c +171 -0
  272. data/ext/rugged/vendor/libgit2-dist/{tests-clay → tests-clar}/object/raw/chars.c +3 -14
  273. data/ext/rugged/vendor/libgit2-dist/{tests-clay → tests-clar}/object/raw/compare.c +4 -4
  274. data/ext/rugged/vendor/libgit2-dist/{tests-clay → tests-clar}/object/raw/convert.c +10 -10
  275. data/ext/rugged/vendor/libgit2-dist/{tests-clay → tests-clar}/object/raw/data.h +0 -0
  276. data/ext/rugged/vendor/libgit2-dist/{tests-clay → tests-clar}/object/raw/fromstr.c +1 -1
  277. data/ext/rugged/vendor/libgit2-dist/{tests-clay → tests-clar}/object/raw/hash.c +21 -17
  278. data/ext/rugged/vendor/libgit2-dist/{tests-clay → tests-clar}/object/raw/short.c +1 -1
  279. data/ext/rugged/vendor/libgit2-dist/{tests-clay → tests-clar}/object/raw/size.c +1 -1
  280. data/ext/rugged/vendor/libgit2-dist/{tests-clay → tests-clar}/object/raw/type2string.c +14 -14
  281. data/ext/rugged/vendor/libgit2-dist/tests-clar/object/raw/write.c +455 -0
  282. data/ext/rugged/vendor/libgit2-dist/tests-clar/object/tag/peel.c +56 -0
  283. data/ext/rugged/vendor/libgit2-dist/tests-clar/object/tag/read.c +130 -0
  284. data/ext/rugged/vendor/libgit2-dist/tests-clar/object/tag/write.c +192 -0
  285. data/ext/rugged/vendor/libgit2-dist/{tests-clay → tests-clar}/object/tree/frompath.c +22 -16
  286. data/ext/rugged/vendor/libgit2-dist/tests-clar/object/tree/read.c +75 -0
  287. data/ext/rugged/vendor/libgit2-dist/tests-clar/object/tree/write.c +84 -0
  288. data/ext/rugged/vendor/libgit2-dist/{tests-clay → tests-clar}/odb/loose.c +1 -1
  289. data/ext/rugged/vendor/libgit2-dist/{tests-clay → tests-clar}/odb/loose_data.h +0 -0
  290. data/ext/rugged/vendor/libgit2-dist/tests-clar/odb/mixed.c +24 -0
  291. data/ext/rugged/vendor/libgit2-dist/{tests-clay → tests-clar}/odb/pack_data.h +0 -0
  292. data/ext/rugged/vendor/libgit2-dist/{tests-clay → tests-clar}/odb/packed.c +1 -1
  293. data/ext/rugged/vendor/libgit2-dist/{tests-clay → tests-clar}/odb/sorting.c +1 -1
  294. data/ext/rugged/vendor/libgit2-dist/tests-clar/refs/branches/create.c +113 -0
  295. data/ext/rugged/vendor/libgit2-dist/tests-clar/refs/branches/delete.c +91 -0
  296. data/ext/rugged/vendor/libgit2-dist/tests-clar/refs/branches/listall.c +78 -0
  297. data/ext/rugged/vendor/libgit2-dist/tests-clar/refs/branches/move.c +72 -0
  298. data/ext/rugged/vendor/libgit2-dist/tests-clar/refs/crashes.c +17 -0
  299. data/ext/rugged/vendor/libgit2-dist/tests-clar/refs/create.c +149 -0
  300. data/ext/rugged/vendor/libgit2-dist/tests-clar/refs/delete.c +85 -0
  301. data/ext/rugged/vendor/libgit2-dist/tests-clar/refs/list.c +53 -0
  302. data/ext/rugged/vendor/libgit2-dist/tests-clar/refs/listall.c +36 -0
  303. data/ext/rugged/vendor/libgit2-dist/tests-clar/refs/lookup.c +42 -0
  304. data/ext/rugged/vendor/libgit2-dist/tests-clar/refs/normalize.c +200 -0
  305. data/ext/rugged/vendor/libgit2-dist/tests-clar/refs/overwrite.c +136 -0
  306. data/ext/rugged/vendor/libgit2-dist/tests-clar/refs/pack.c +67 -0
  307. data/ext/rugged/vendor/libgit2-dist/tests-clar/refs/read.c +194 -0
  308. data/ext/rugged/vendor/libgit2-dist/tests-clar/refs/reflog.c +123 -0
  309. data/ext/rugged/vendor/libgit2-dist/tests-clar/refs/rename.c +339 -0
  310. data/ext/rugged/vendor/libgit2-dist/tests-clar/refs/revparse.c +174 -0
  311. data/ext/rugged/vendor/libgit2-dist/tests-clar/refs/unicode.c +42 -0
  312. data/ext/rugged/vendor/libgit2-dist/tests-clar/repo/discover.c +142 -0
  313. data/ext/rugged/vendor/libgit2-dist/{tests-clay → tests-clar}/repo/getters.c +19 -1
  314. data/ext/rugged/vendor/libgit2-dist/tests-clar/repo/init.c +235 -0
  315. data/ext/rugged/vendor/libgit2-dist/tests-clar/repo/open.c +282 -0
  316. data/ext/rugged/vendor/libgit2-dist/tests-clar/repo/setters.c +80 -0
  317. data/ext/rugged/vendor/libgit2-dist/tests-clar/reset/mixed.c +47 -0
  318. data/ext/rugged/vendor/libgit2-dist/tests-clar/reset/reset_helpers.c +10 -0
  319. data/ext/rugged/vendor/libgit2-dist/tests-clar/reset/reset_helpers.h +6 -0
  320. data/ext/rugged/vendor/libgit2-dist/tests-clar/reset/soft.c +102 -0
  321. data/ext/rugged/vendor/libgit2-dist/{tests/t05-revwalk.c → tests-clar/revwalk/basic.c} +85 -44
  322. data/ext/rugged/vendor/libgit2-dist/tests-clar/revwalk/mergebase.c +148 -0
  323. data/ext/rugged/vendor/libgit2-dist/tests-clar/status/ignore.c +133 -0
  324. data/ext/rugged/vendor/libgit2-dist/{tests-clay → tests-clar}/status/single.c +2 -11
  325. data/ext/rugged/vendor/libgit2-dist/tests-clar/status/status_data.h +202 -0
  326. data/ext/rugged/vendor/libgit2-dist/tests-clar/status/status_helpers.c +49 -0
  327. data/ext/rugged/vendor/libgit2-dist/tests-clar/status/status_helpers.h +33 -0
  328. data/ext/rugged/vendor/libgit2-dist/tests-clar/status/submodules.c +112 -0
  329. data/ext/rugged/vendor/libgit2-dist/tests-clar/status/worktree.c +649 -0
  330. data/ext/rugged/vendor/libgit2-dist/tests-clar/threads/basic.c +20 -0
  331. data/ext/rugged/vendor/libgit2-dist.tar.gz +0 -0
  332. data/lib/rugged/commit.rb +35 -0
  333. data/lib/rugged/object.rb +7 -0
  334. data/lib/rugged/reference.rb +9 -0
  335. data/lib/rugged/repository.rb +99 -3
  336. data/lib/rugged/tag.rb +22 -0
  337. data/lib/rugged/tree.rb +8 -0
  338. data/lib/rugged/version.rb +1 -1
  339. data/lib/rugged.rb +4 -1
  340. data/test/blob_test.rb +2 -2
  341. data/test/commit_test.rb +27 -13
  342. data/test/config_test.rb +44 -0
  343. data/test/coverage/HEAD.json +1 -1
  344. data/test/fixtures/testrepo.git/config +2 -0
  345. data/test/fixtures/testrepo.git/objects/7f/043268ea43ce18e3540acaabf9e090c91965b0 +0 -0
  346. data/test/lib_test.rb +7 -0
  347. data/test/object_test.rb +3 -3
  348. data/test/reference_test.rb +46 -8
  349. data/test/remote_test.rb +8 -2
  350. data/test/repo_pack_test.rb +3 -3
  351. data/test/repo_test.rb +79 -11
  352. data/test/tag_test.rb +9 -2
  353. data/test/test_helper.rb +21 -0
  354. data/test/tree_test.rb +18 -6
  355. metadata +205 -81
  356. data/ext/rugged/vendor/libgit2-dist/include/git2/zlib.h +0 -40
  357. data/ext/rugged/vendor/libgit2-dist/src/hashtable.c +0 -243
  358. data/ext/rugged/vendor/libgit2-dist/src/hashtable.h +0 -80
  359. data/ext/rugged/vendor/libgit2-dist/tests/t00-core.c +0 -628
  360. data/ext/rugged/vendor/libgit2-dist/tests/t01-data.h +0 -322
  361. data/ext/rugged/vendor/libgit2-dist/tests/t01-rawobj.c +0 -638
  362. data/ext/rugged/vendor/libgit2-dist/tests/t03-data.h +0 -344
  363. data/ext/rugged/vendor/libgit2-dist/tests/t03-objwrite.c +0 -255
  364. data/ext/rugged/vendor/libgit2-dist/tests/t04-commit.c +0 -788
  365. data/ext/rugged/vendor/libgit2-dist/tests/t06-index.c +0 -219
  366. data/ext/rugged/vendor/libgit2-dist/tests/t07-hashtable.c +0 -192
  367. data/ext/rugged/vendor/libgit2-dist/tests/t08-tag.c +0 -357
  368. data/ext/rugged/vendor/libgit2-dist/tests/t09-tree.c +0 -221
  369. data/ext/rugged/vendor/libgit2-dist/tests/t10-refs.c +0 -1294
  370. data/ext/rugged/vendor/libgit2-dist/tests/t12-repo.c +0 -174
  371. data/ext/rugged/vendor/libgit2-dist/tests/t13-threads.c +0 -41
  372. data/ext/rugged/vendor/libgit2-dist/tests/t17-bufs.c +0 -61
  373. data/ext/rugged/vendor/libgit2-dist/tests/t18-status.c +0 -448
  374. data/ext/rugged/vendor/libgit2-dist/tests/test_helpers.c +0 -310
  375. data/ext/rugged/vendor/libgit2-dist/tests/test_helpers.h +0 -83
  376. data/ext/rugged/vendor/libgit2-dist/tests/test_lib.c +0 -198
  377. data/ext/rugged/vendor/libgit2-dist/tests/test_lib.h +0 -54
  378. data/ext/rugged/vendor/libgit2-dist/tests/test_main.c +0 -89
  379. data/ext/rugged/vendor/libgit2-dist/tests-clay/clay.h +0 -187
  380. data/ext/rugged/vendor/libgit2-dist/tests-clay/clay_libgit2.h +0 -28
  381. data/ext/rugged/vendor/libgit2-dist/tests-clay/clay_main.c +0 -1073
  382. data/ext/rugged/vendor/libgit2-dist/tests-clay/config/stress.c +0 -39
  383. data/ext/rugged/vendor/libgit2-dist/tests-clay/core/path.c +0 -139
  384. data/ext/rugged/vendor/libgit2-dist/tests-clay/core/rmdir.c +0 -50
  385. data/ext/rugged/vendor/libgit2-dist/tests-clay/core/vector.c +0 -66
  386. data/ext/rugged/vendor/libgit2-dist/tests-clay/network/remotes.c +0 -50
  387. data/ext/rugged/vendor/libgit2-dist/tests-clay/repo/init.c +0 -104
  388. data/ext/rugged/vendor/libgit2-dist/tests-clay/repo/open.c +0 -54
  389. data/ext/rugged/vendor/libgit2-dist/tests-clay/status/status_data.h +0 -48
  390. data/ext/rugged/vendor/libgit2-dist/tests-clay/status/worktree.c +0 -124
  391. data/lib/rugged/objects.rb +0 -45
  392. data/test/fixtures/testrepo.git/refs/heads/new_name +0 -1
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Copyright (C) 2009-2011 the libgit2 contributors
2
+ * Copyright (C) 2009-2012 the libgit2 contributors
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.
@@ -9,6 +9,7 @@
9
9
  #include "commit.h"
10
10
  #include "tag.h"
11
11
  #include "signature.h"
12
+ #include "message.h"
12
13
  #include "git2/object.h"
13
14
  #include "git2/repository.h"
14
15
  #include "git2/signature.h"
@@ -61,24 +62,32 @@ const char *git_tag_message(git_tag *t)
61
62
  return t->message;
62
63
  }
63
64
 
64
- static int parse_tag_buffer(git_tag *tag, const char *buffer, const char *buffer_end)
65
+ static int tag_error(const char *str)
66
+ {
67
+ giterr_set(GITERR_TAG, "Failed to parse tag. %s", str);
68
+ return -1;
69
+ }
70
+
71
+ int git_tag__parse_buffer(git_tag *tag, const char *buffer, size_t length)
65
72
  {
66
73
  static const char *tag_types[] = {
67
74
  NULL, "commit\n", "tree\n", "blob\n", "tag\n"
68
75
  };
69
76
 
70
- unsigned int i, text_len;
77
+ unsigned int i;
78
+ size_t text_len;
71
79
  char *search;
72
- int error;
73
80
 
74
- if ((error = git_oid__parse(&tag->target, &buffer, buffer_end, "object ")) < 0)
75
- return git__rethrow(error, "Failed to parse tag. Object field invalid");
81
+ const char *buffer_end = buffer + length;
82
+
83
+ if (git_oid__parse(&tag->target, &buffer, buffer_end, "object ") < 0)
84
+ return tag_error("Object field invalid");
76
85
 
77
86
  if (buffer + 5 >= buffer_end)
78
- return git__throw(GIT_EOBJCORRUPTED, "Failed to parse tag. Object too short");
87
+ return tag_error("Object too short");
79
88
 
80
89
  if (memcmp(buffer, "type ", 5) != 0)
81
- return git__throw(GIT_EOBJCORRUPTED, "Failed to parse tag. Type field not found");
90
+ return tag_error("Type field not found");
82
91
  buffer += 5;
83
92
 
84
93
  tag->type = GIT_OBJ_BAD;
@@ -87,7 +96,7 @@ static int parse_tag_buffer(git_tag *tag, const char *buffer, const char *buffer
87
96
  size_t type_length = strlen(tag_types[i]);
88
97
 
89
98
  if (buffer + type_length >= buffer_end)
90
- return git__throw(GIT_EOBJCORRUPTED, "Failed to parse tag. Object too short");
99
+ return tag_error("Object too short");
91
100
 
92
101
  if (memcmp(buffer, tag_types[i], type_length) == 0) {
93
102
  tag->type = i;
@@ -97,25 +106,24 @@ static int parse_tag_buffer(git_tag *tag, const char *buffer, const char *buffer
97
106
  }
98
107
 
99
108
  if (tag->type == GIT_OBJ_BAD)
100
- return git__throw(GIT_EOBJCORRUPTED, "Failed to parse tag. Invalid object type");
109
+ return tag_error("Invalid object type");
101
110
 
102
111
  if (buffer + 4 >= buffer_end)
103
- return git__throw(GIT_EOBJCORRUPTED, "Failed to parse tag. Object too short");
112
+ return tag_error("Object too short");
104
113
 
105
114
  if (memcmp(buffer, "tag ", 4) != 0)
106
- return git__throw(GIT_EOBJCORRUPTED, "Failed to parse tag. Tag field not found");
115
+ return tag_error("Tag field not found");
107
116
 
108
117
  buffer += 4;
109
118
 
110
119
  search = memchr(buffer, '\n', buffer_end - buffer);
111
120
  if (search == NULL)
112
- return git__throw(GIT_EOBJCORRUPTED, "Failed to parse tag. Object too short");
121
+ return tag_error("Object too short");
113
122
 
114
123
  text_len = search - buffer;
115
124
 
116
125
  tag->tag_name = git__malloc(text_len + 1);
117
- if (tag->tag_name == NULL)
118
- return GIT_ENOMEM;
126
+ GITERR_CHECK_ALLOC(tag->tag_name);
119
127
 
120
128
  memcpy(tag->tag_name, buffer, text_len);
121
129
  tag->tag_name[text_len] = '\0';
@@ -125,44 +133,59 @@ static int parse_tag_buffer(git_tag *tag, const char *buffer, const char *buffer
125
133
  tag->tagger = NULL;
126
134
  if (*buffer != '\n') {
127
135
  tag->tagger = git__malloc(sizeof(git_signature));
128
- if (tag->tagger == NULL)
129
- return GIT_ENOMEM;
136
+ GITERR_CHECK_ALLOC(tag->tagger);
130
137
 
131
- if ((error = git_signature__parse(tag->tagger, &buffer, buffer_end, "tagger ", '\n') != 0)) {
132
- return git__rethrow(error, "Failed to parse tag");
133
- }
138
+ if (git_signature__parse(tag->tagger, &buffer, buffer_end, "tagger ", '\n') < 0)
139
+ return -1;
134
140
  }
135
141
 
136
142
  if( *buffer != '\n' )
137
- return git__throw(GIT_EOBJCORRUPTED, "Failed to parse tag. No new line before message");
143
+ return tag_error("No new line before message");
138
144
 
139
145
  text_len = buffer_end - ++buffer;
140
146
 
141
147
  tag->message = git__malloc(text_len + 1);
142
- if (tag->message == NULL)
143
- return GIT_ENOMEM;
148
+ GITERR_CHECK_ALLOC(tag->message);
144
149
 
145
150
  memcpy(tag->message, buffer, text_len);
146
151
  tag->message[text_len] = '\0';
147
152
 
148
- return GIT_SUCCESS;
153
+ return 0;
149
154
  }
150
155
 
151
- static int retrieve_tag_reference(git_reference **tag_reference_out, char *ref_name_out, git_repository *repo, const char *tag_name)
156
+ static int retrieve_tag_reference(
157
+ git_reference **tag_reference_out,
158
+ git_buf *ref_name_out,
159
+ git_repository *repo,
160
+ const char *tag_name)
152
161
  {
153
162
  git_reference *tag_ref;
154
163
  int error;
155
164
 
156
165
  *tag_reference_out = NULL;
157
166
 
158
- git_path_join(ref_name_out, GIT_REFS_TAGS_DIR, tag_name);
159
- error = git_reference_lookup(&tag_ref, repo, ref_name_out);
160
- if (error < GIT_SUCCESS)
161
- return git__rethrow(error, "Failed to retrieve tag reference");
167
+ if (git_buf_joinpath(ref_name_out, GIT_REFS_TAGS_DIR, tag_name) < 0)
168
+ return -1;
169
+
170
+ error = git_reference_lookup(&tag_ref, repo, ref_name_out->ptr);
171
+ if (error < 0)
172
+ return error; /* Be it not foundo or corrupted */
162
173
 
163
174
  *tag_reference_out = tag_ref;
164
175
 
165
- return GIT_SUCCESS;
176
+ return 0;
177
+ }
178
+
179
+ static int retrieve_tag_reference_oid(
180
+ git_oid *oid,
181
+ git_buf *ref_name_out,
182
+ git_repository *repo,
183
+ const char *tag_name)
184
+ {
185
+ if (git_buf_joinpath(ref_name_out, GIT_REFS_TAGS_DIR, tag_name) < 0)
186
+ return -1;
187
+
188
+ return git_reference_name_to_oid(oid, repo, ref_name_out->ptr);
166
189
  }
167
190
 
168
191
  static int write_tag_annotation(
@@ -173,8 +196,7 @@ static int write_tag_annotation(
173
196
  const git_signature *tagger,
174
197
  const char *message)
175
198
  {
176
- int error = GIT_SUCCESS;
177
- git_buf tag = GIT_BUF_INIT;
199
+ git_buf tag = GIT_BUF_INIT, cleaned_message = GIT_BUF_INIT;
178
200
  git_odb *odb;
179
201
 
180
202
  git_oid__writebuf(&tag, "object ", git_object_id(target));
@@ -182,26 +204,30 @@ static int write_tag_annotation(
182
204
  git_buf_printf(&tag, "tag %s\n", tag_name);
183
205
  git_signature__writebuf(&tag, "tagger ", tagger);
184
206
  git_buf_putc(&tag, '\n');
185
- git_buf_puts(&tag, message);
186
207
 
187
- if (git_buf_oom(&tag)) {
188
- git_buf_free(&tag);
189
- return git__throw(GIT_ENOMEM, "Not enough memory to build the tag data");
190
- }
208
+ /* Remove comments by default */
209
+ if (git_message_prettify(&cleaned_message, message, 1) < 0)
210
+ goto on_error;
191
211
 
192
- error = git_repository_odb__weakptr(&odb, repo);
193
- if (error < GIT_SUCCESS) {
194
- git_buf_free(&tag);
195
- return error;
196
- }
212
+ if (git_buf_puts(&tag, git_buf_cstr(&cleaned_message)) < 0)
213
+ goto on_error;
197
214
 
198
- error = git_odb_write(oid, odb, tag.ptr, tag.size, GIT_OBJ_TAG);
199
- git_buf_free(&tag);
215
+ git_buf_free(&cleaned_message);
200
216
 
201
- if (error < GIT_SUCCESS)
202
- return git__rethrow(error, "Failed to create tag annotation");
217
+ if (git_repository_odb__weakptr(&odb, repo) < 0)
218
+ goto on_error;
203
219
 
204
- return error;
220
+ if (git_odb_write(oid, odb, tag.ptr, tag.size, GIT_OBJ_TAG) < 0)
221
+ goto on_error;
222
+
223
+ git_buf_free(&tag);
224
+ return 0;
225
+
226
+ on_error:
227
+ git_buf_free(&tag);
228
+ git_buf_free(&cleaned_message);
229
+ giterr_set(GITERR_OBJECT, "Failed to create tag annotation.");
230
+ return -1;
205
231
  }
206
232
 
207
233
  static int git_tag_create__internal(
@@ -215,56 +241,41 @@ static int git_tag_create__internal(
215
241
  int create_tag_annotation)
216
242
  {
217
243
  git_reference *new_ref = NULL;
218
- char ref_name[GIT_REFNAME_MAX];
244
+ git_buf ref_name = GIT_BUF_INIT;
219
245
 
220
- int error, should_update_ref = 0;
246
+ int error;
221
247
 
222
248
  assert(repo && tag_name && target);
223
249
  assert(!create_tag_annotation || (tagger && message));
224
250
 
225
- if (git_object_owner(target) != repo)
226
- return git__throw(GIT_EINVALIDARGS, "The given target does not belong to this repository");
227
-
228
- error = retrieve_tag_reference(&new_ref, ref_name, repo, tag_name);
229
-
230
- switch (error) {
231
- case GIT_SUCCESS:
232
- case GIT_ENOTFOUND:
233
- break;
234
-
235
- default:
236
- git_reference_free(new_ref);
237
- return git__rethrow(error, "Failed to create tag");
251
+ if (git_object_owner(target) != repo) {
252
+ giterr_set(GITERR_INVALID, "The given target does not belong to this repository");
253
+ return -1;
238
254
  }
239
255
 
256
+ error = retrieve_tag_reference_oid(oid, &ref_name, repo, tag_name);
257
+ if (error < 0 && error != GIT_ENOTFOUND)
258
+ return -1;
259
+
240
260
  /** Ensure the tag name doesn't conflict with an already existing
241
261
  * reference unless overwriting has explictly been requested **/
242
- if (new_ref != NULL) {
243
- if (!allow_ref_overwrite) {
244
- git_oid_cpy(oid, git_reference_oid(new_ref));
245
- git_reference_free(new_ref);
246
- return git__throw(GIT_EEXISTS, "Tag already exists");
247
- } else {
248
- should_update_ref = 1;
249
- }
262
+ if (error == 0 && !allow_ref_overwrite) {
263
+ git_buf_free(&ref_name);
264
+ giterr_set(GITERR_TAG, "Tag already exists");
265
+ return GIT_EEXISTS;
250
266
  }
251
267
 
252
268
  if (create_tag_annotation) {
253
- if ((error = write_tag_annotation(oid, repo, tag_name, target, tagger, message)) < GIT_SUCCESS) {
254
- git_reference_free(new_ref);
255
- return error;
256
- }
269
+ if (write_tag_annotation(oid, repo, tag_name, target, tagger, message) < 0)
270
+ return -1;
257
271
  } else
258
272
  git_oid_cpy(oid, git_object_id(target));
259
273
 
260
- if (!should_update_ref)
261
- error = git_reference_create_oid(&new_ref, repo, ref_name, oid, 0);
262
- else
263
- error = git_reference_set_oid(new_ref, oid);
274
+ error = git_reference_create_oid(&new_ref, repo, ref_name.ptr, oid, allow_ref_overwrite);
264
275
 
265
276
  git_reference_free(new_ref);
266
-
267
- return error == GIT_SUCCESS ? GIT_SUCCESS : git__rethrow(error, "Failed to create tag");
277
+ git_buf_free(&ref_name);
278
+ return error;
268
279
  }
269
280
 
270
281
  int git_tag_create(
@@ -292,98 +303,92 @@ int git_tag_create_lightweight(
292
303
  int git_tag_create_frombuffer(git_oid *oid, git_repository *repo, const char *buffer, int allow_ref_overwrite)
293
304
  {
294
305
  git_tag tag;
295
- int error, should_update_ref = 0;
306
+ int error;
296
307
  git_odb *odb;
297
308
  git_odb_stream *stream;
298
309
  git_odb_object *target_obj;
299
310
 
300
311
  git_reference *new_ref = NULL;
301
- char ref_name[GIT_REFNAME_MAX];
312
+ git_buf ref_name = GIT_BUF_INIT;
302
313
 
303
314
  assert(oid && buffer);
304
315
 
305
316
  memset(&tag, 0, sizeof(tag));
306
317
 
307
- error = git_repository_odb__weakptr(&odb, repo);
308
- if (error < GIT_SUCCESS)
309
- return error;
318
+ if (git_repository_odb__weakptr(&odb, repo) < 0)
319
+ return -1;
310
320
 
311
321
  /* validate the buffer */
312
- if ((error = parse_tag_buffer(&tag, buffer, buffer + strlen(buffer))) < GIT_SUCCESS)
313
- return git__rethrow(error, "Failed to create tag");
322
+ if (git_tag__parse_buffer(&tag, buffer, strlen(buffer)) < 0)
323
+ return -1;
314
324
 
315
325
  /* validate the target */
316
- if ((error = git_odb_read(&target_obj, odb, &tag.target)) < GIT_SUCCESS)
317
- return git__rethrow(error, "Failed to create tag");
318
-
319
- if (tag.type != target_obj->raw.type)
320
- return git__throw(error, "The type for the given target is invalid");
321
-
322
- git_odb_object_free(target_obj);
326
+ if (git_odb_read(&target_obj, odb, &tag.target) < 0)
327
+ goto on_error;
323
328
 
324
- error = retrieve_tag_reference(&new_ref, ref_name, repo, tag.tag_name);
329
+ if (tag.type != target_obj->raw.type) {
330
+ giterr_set(GITERR_TAG, "The type for the given target is invalid");
331
+ goto on_error;
332
+ }
325
333
 
326
- switch (error) {
327
- case GIT_SUCCESS:
328
- case GIT_ENOTFOUND:
329
- break;
334
+ error = retrieve_tag_reference_oid(oid, &ref_name, repo, tag.tag_name);
335
+ if (error < 0 && error != GIT_ENOTFOUND)
336
+ goto on_error;
330
337
 
331
- default:
332
- git_reference_free(new_ref);
333
- return git__rethrow(error, "Failed to create tag");
334
- }
338
+ /* We don't need these objects after this */
339
+ git_signature_free(tag.tagger);
340
+ git__free(tag.tag_name);
341
+ git__free(tag.message);
342
+ git_odb_object_free(target_obj);
335
343
 
336
344
  /** Ensure the tag name doesn't conflict with an already existing
337
345
  * reference unless overwriting has explictly been requested **/
338
- if (new_ref != NULL) {
339
- if (!allow_ref_overwrite) {
340
- git_oid_cpy(oid, git_reference_oid(new_ref));
341
- git_reference_free(new_ref);
342
- return git__throw(GIT_EEXISTS, "Tag already exists");
343
- } else {
344
- should_update_ref = 1;
345
- }
346
+ if (error == 0 && !allow_ref_overwrite) {
347
+ giterr_set(GITERR_TAG, "Tag already exists");
348
+ return GIT_EEXISTS;
346
349
  }
347
350
 
348
351
  /* write the buffer */
349
- if ((error = git_odb_open_wstream(&stream, odb, strlen(buffer), GIT_OBJ_TAG)) < GIT_SUCCESS) {
350
- git_reference_free(new_ref);
351
- return git__rethrow(error, "Failed to create tag");
352
- }
352
+ if (git_odb_open_wstream(&stream, odb, strlen(buffer), GIT_OBJ_TAG) < 0)
353
+ return -1;
353
354
 
354
355
  stream->write(stream, buffer, strlen(buffer));
355
356
 
356
357
  error = stream->finalize_write(oid, stream);
357
358
  stream->free(stream);
358
359
 
359
- if (error < GIT_SUCCESS) {
360
- git_reference_free(new_ref);
361
- return git__rethrow(error, "Failed to create tag");
360
+ if (error < 0) {
361
+ git_buf_free(&ref_name);
362
+ return -1;
362
363
  }
363
364
 
364
- if (!should_update_ref)
365
- error = git_reference_create_oid(&new_ref, repo, ref_name, oid, 0);
366
- else
367
- error = git_reference_set_oid(new_ref, oid);
365
+ error = git_reference_create_oid(&new_ref, repo, ref_name.ptr, oid, allow_ref_overwrite);
368
366
 
369
367
  git_reference_free(new_ref);
368
+ git_buf_free(&ref_name);
369
+
370
+ return error;
370
371
 
372
+ on_error:
371
373
  git_signature_free(tag.tagger);
372
374
  git__free(tag.tag_name);
373
375
  git__free(tag.message);
374
-
375
- return error == GIT_SUCCESS ? GIT_SUCCESS : git__rethrow(error, "Failed to create tag");
376
+ git_odb_object_free(target_obj);
377
+ return -1;
376
378
  }
377
379
 
378
380
  int git_tag_delete(git_repository *repo, const char *tag_name)
379
381
  {
380
382
  int error;
381
383
  git_reference *tag_ref;
382
- char ref_name[GIT_REFNAME_MAX];
384
+ git_buf ref_name = GIT_BUF_INIT;
385
+
386
+ error = retrieve_tag_reference(&tag_ref, &ref_name, repo, tag_name);
383
387
 
384
- error = retrieve_tag_reference(&tag_ref, ref_name, repo, tag_name);
385
- if (error < GIT_SUCCESS)
386
- return git__rethrow(error, "Failed to delete tag");
388
+ git_buf_free(&ref_name);
389
+
390
+ if (error < 0)
391
+ return -1;
387
392
 
388
393
  return git_reference_delete(tag_ref);
389
394
  }
@@ -391,7 +396,7 @@ int git_tag_delete(git_repository *repo, const char *tag_name)
391
396
  int git_tag__parse(git_tag *tag, git_odb_object *obj)
392
397
  {
393
398
  assert(tag);
394
- return parse_tag_buffer(tag, obj->raw.data, (char *)obj->raw.data + obj->raw.len);
399
+ return git_tag__parse_buffer(tag, obj->raw.data, obj->raw.len);
395
400
  }
396
401
 
397
402
  typedef struct {
@@ -406,13 +411,13 @@ static int tag_list_cb(const char *tag_name, void *payload)
406
411
  tag_filter_data *filter;
407
412
 
408
413
  if (git__prefixcmp(tag_name, GIT_REFS_TAGS_DIR) != 0)
409
- return GIT_SUCCESS;
414
+ return 0;
410
415
 
411
416
  filter = (tag_filter_data *)payload;
412
- if (!*filter->pattern || p_fnmatch(filter->pattern, tag_name + GIT_REFS_TAGS_DIR_LEN, 0) == GIT_SUCCESS)
417
+ if (!*filter->pattern || p_fnmatch(filter->pattern, tag_name + GIT_REFS_TAGS_DIR_LEN, 0) == 0)
413
418
  return git_vector_insert(filter->taglist, git__strdup(tag_name));
414
419
 
415
- return GIT_SUCCESS;
420
+ return 0;
416
421
  }
417
422
 
418
423
  int git_tag_list_match(git_strarray *tag_names, const char *pattern, git_repository *repo)
@@ -423,24 +428,44 @@ int git_tag_list_match(git_strarray *tag_names, const char *pattern, git_reposit
423
428
 
424
429
  assert(tag_names && repo && pattern);
425
430
 
426
- if (git_vector_init(&taglist, 8, NULL) < GIT_SUCCESS)
427
- return GIT_ENOMEM;
431
+ if (git_vector_init(&taglist, 8, NULL) < 0)
432
+ return -1;
428
433
 
429
434
  filter.taglist = &taglist;
430
435
  filter.pattern = pattern;
431
436
 
432
437
  error = git_reference_foreach(repo, GIT_REF_OID|GIT_REF_PACKED, &tag_list_cb, (void *)&filter);
433
- if (error < GIT_SUCCESS) {
438
+ if (error < 0) {
434
439
  git_vector_free(&taglist);
435
- return git__rethrow(error, "Failed to list tags");
440
+ return -1;
436
441
  }
437
442
 
438
443
  tag_names->strings = (char **)taglist.contents;
439
444
  tag_names->count = taglist.length;
440
- return GIT_SUCCESS;
445
+ return 0;
441
446
  }
442
447
 
443
448
  int git_tag_list(git_strarray *tag_names, git_repository *repo)
444
449
  {
445
450
  return git_tag_list_match(tag_names, "", repo);
446
451
  }
452
+
453
+ int git_tag_peel(git_object **tag_target, git_tag *tag)
454
+ {
455
+ int error;
456
+ git_object *target;
457
+
458
+ assert(tag_target && tag);
459
+
460
+ if (git_tag_target(&target, tag) < 0)
461
+ return -1;
462
+
463
+ if (git_object_type(target) == GIT_OBJ_TAG) {
464
+ error = git_tag_peel(tag_target, (git_tag *)target);
465
+ git_object_free(target);
466
+ return error;
467
+ }
468
+
469
+ *tag_target = target;
470
+ return 0;
471
+ }
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Copyright (C) 2009-2011 the libgit2 contributors
2
+ * Copyright (C) 2009-2012 the libgit2 contributors
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.
@@ -24,5 +24,6 @@ struct git_tag {
24
24
 
25
25
  void git_tag__free(git_tag *tag);
26
26
  int git_tag__parse(git_tag *tag, git_odb_object *obj);
27
+ int git_tag__parse_buffer(git_tag *tag, const char *data, size_t len);
27
28
 
28
29
  #endif
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Copyright (C) 2009-2011 the libgit2 contributors
2
+ * Copyright (C) 2009-2012 the libgit2 contributors
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.
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Copyright (C) 2009-2011 the libgit2 contributors
2
+ * Copyright (C) 2009-2012 the libgit2 contributors
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.
@@ -11,7 +11,7 @@
11
11
 
12
12
  /* Common operations even if threading has been disabled */
13
13
  typedef struct {
14
- #if defined(_MSC_VER)
14
+ #if defined(GIT_WIN32)
15
15
  volatile long val;
16
16
  #else
17
17
  volatile int val;
@@ -48,10 +48,10 @@ GIT_INLINE(void) git_atomic_set(git_atomic *a, int val)
48
48
 
49
49
  GIT_INLINE(int) git_atomic_inc(git_atomic *a)
50
50
  {
51
- #ifdef __GNUC__
52
- return __sync_add_and_fetch(&a->val, 1);
53
- #elif defined(_MSC_VER)
51
+ #if defined(GIT_WIN32)
54
52
  return InterlockedIncrement(&a->val);
53
+ #elif defined(__GNUC__)
54
+ return __sync_add_and_fetch(&a->val, 1);
55
55
  #else
56
56
  # error "Unsupported architecture for atomic operations"
57
57
  #endif
@@ -59,10 +59,10 @@ GIT_INLINE(int) git_atomic_inc(git_atomic *a)
59
59
 
60
60
  GIT_INLINE(int) git_atomic_dec(git_atomic *a)
61
61
  {
62
- #ifdef __GNUC__
63
- return __sync_sub_and_fetch(&a->val, 1);
64
- #elif defined(_MSC_VER)
62
+ #if defined(GIT_WIN32)
65
63
  return InterlockedDecrement(&a->val);
64
+ #elif defined(__GNUC__)
65
+ return __sync_sub_and_fetch(&a->val, 1);
66
66
  #else
67
67
  # error "Unsupported architecture for atomic operations"
68
68
  #endif
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Copyright (C) 2009-2011 the libgit2 contributors
2
+ * Copyright (C) 2009-2012 the libgit2 contributors
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.
@@ -9,6 +9,7 @@
9
9
  #include "git2/remote.h"
10
10
  #include "git2/net.h"
11
11
  #include "transport.h"
12
+ #include "path.h"
12
13
 
13
14
  static struct {
14
15
  char *prefix;
@@ -16,26 +17,33 @@ static struct {
16
17
  } transports[] = {
17
18
  {"git://", git_transport_git},
18
19
  {"http://", git_transport_http},
19
- {"https://", git_transport_dummy},
20
+ {"https://", git_transport_https},
20
21
  {"file://", git_transport_local},
21
22
  {"git+ssh://", git_transport_dummy},
22
23
  {"ssh+git://", git_transport_dummy},
23
24
  {NULL, 0}
24
25
  };
25
26
 
26
- #define GIT_TRANSPORT_COUNT (sizeof(transports)/sizeof(transports[0]))
27
+ #define GIT_TRANSPORT_COUNT (sizeof(transports)/sizeof(transports[0])) - 1
27
28
 
28
29
  static git_transport_cb transport_find_fn(const char *url)
29
30
  {
30
31
  size_t i = 0;
31
32
 
32
- /* TODO: Parse "example.com:project.git" as an SSH URL */
33
-
33
+ // First, check to see if it's an obvious URL, which a URL scheme
34
34
  for (i = 0; i < GIT_TRANSPORT_COUNT; ++i) {
35
35
  if (!strncasecmp(url, transports[i].prefix, strlen(transports[i].prefix)))
36
36
  return transports[i].fn;
37
37
  }
38
38
 
39
+ /* still here? Check to see if the path points to a file on the local file system */
40
+ if ((git_path_exists(url) == 0) && git_path_isdir(url))
41
+ return &git_transport_local;
42
+
43
+ /* It could be a SSH remote path. Check to see if there's a : */
44
+ if (strrchr(url, ':'))
45
+ return &git_transport_dummy; /* SSH is an unsupported transport mechanism in this version of libgit2 */
46
+
39
47
  return NULL;
40
48
  }
41
49
 
@@ -43,10 +51,11 @@ static git_transport_cb transport_find_fn(const char *url)
43
51
  * Public API *
44
52
  **************/
45
53
 
46
- int git_transport_dummy(git_transport **GIT_UNUSED(transport))
54
+ int git_transport_dummy(git_transport **transport)
47
55
  {
48
- GIT_UNUSED_ARG(transport);
49
- return git__throw(GIT_ENOTIMPLEMENTED, "This protocol isn't implemented. Sorry");
56
+ GIT_UNUSED(transport);
57
+ giterr_set(GITERR_NET, "This transport isn't implemented. Sorry");
58
+ return -1;
50
59
  }
51
60
 
52
61
  int git_transport_new(git_transport **out, const char *url)
@@ -57,24 +66,21 @@ int git_transport_new(git_transport **out, const char *url)
57
66
 
58
67
  fn = transport_find_fn(url);
59
68
 
60
- /*
61
- * If we haven't found the transport, we assume we mean a
62
- * local file.
63
- */
64
- if (fn == NULL)
65
- fn = &git_transport_local;
69
+ if (fn == NULL) {
70
+ giterr_set(GITERR_NET, "Unsupported URL protocol");
71
+ return -1;
72
+ }
66
73
 
67
74
  error = fn(&transport);
68
- if (error < GIT_SUCCESS)
69
- return git__rethrow(error, "Failed to create new transport");
75
+ if (error < 0)
76
+ return error;
70
77
 
71
78
  transport->url = git__strdup(url);
72
- if (transport->url == NULL)
73
- return GIT_ENOMEM;
79
+ GITERR_CHECK_ALLOC(transport->url);
74
80
 
75
81
  *out = transport;
76
82
 
77
- return GIT_SUCCESS;
83
+ return 0;
78
84
  }
79
85
 
80
86
  /* from remote.h */
@@ -83,3 +89,9 @@ int git_remote_valid_url(const char *url)
83
89
  return transport_find_fn(url) != NULL;
84
90
  }
85
91
 
92
+ int git_remote_supported_url(const char* url)
93
+ {
94
+ git_transport_cb transport_fn = transport_find_fn(url);
95
+
96
+ return ((transport_fn != NULL) && (transport_fn != &git_transport_dummy));
97
+ }