rugged 0.17.0b2 → 0.17.0.b6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (374) hide show
  1. data/Rakefile +10 -11
  2. data/ext/rugged/extconf.rb +5 -13
  3. data/ext/rugged/rugged_commit.c +2 -5
  4. data/ext/rugged/rugged_reference.c +29 -28
  5. data/ext/rugged/rugged_remote.c +1 -1
  6. data/ext/rugged/rugged_repo.c +4 -1
  7. data/ext/rugged/rugged_tree.c +20 -19
  8. data/lib/rugged/commit.rb +5 -1
  9. data/lib/rugged/repository.rb +6 -4
  10. data/lib/rugged/version.rb +1 -1
  11. data/test/config_test.rb +1 -1
  12. data/test/index_test.rb +4 -2
  13. data/test/object_test.rb +3 -3
  14. data/test/reference_test.rb +66 -1
  15. data/test/repo_test.rb +4 -4
  16. data/test/tree_test.rb +1 -1
  17. data/test/walker_test.rb +1 -1
  18. data/vendor/libgit2/Makefile.embed +42 -0
  19. data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/deps/http-parser/http_parser.c +0 -0
  20. data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/deps/http-parser/http_parser.h +0 -0
  21. data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/deps/regex/config.h +0 -0
  22. data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/deps/regex/regcomp.c +0 -0
  23. data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/deps/regex/regex.c +0 -0
  24. data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/deps/regex/regex.h +0 -0
  25. data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/deps/regex/regex_internal.c +0 -0
  26. data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/deps/regex/regex_internal.h +0 -0
  27. data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/deps/regex/regexec.c +0 -0
  28. data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/deps/zlib/adler32.c +0 -0
  29. data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/deps/zlib/crc32.c +0 -0
  30. data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/deps/zlib/crc32.h +0 -0
  31. data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/deps/zlib/deflate.c +0 -0
  32. data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/deps/zlib/deflate.h +0 -0
  33. data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/deps/zlib/inffast.c +0 -0
  34. data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/deps/zlib/inffast.h +0 -0
  35. data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/deps/zlib/inffixed.h +0 -0
  36. data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/deps/zlib/inflate.c +0 -0
  37. data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/deps/zlib/inflate.h +0 -0
  38. data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/deps/zlib/inftrees.c +0 -0
  39. data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/deps/zlib/inftrees.h +0 -0
  40. data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/deps/zlib/trees.c +0 -0
  41. data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/deps/zlib/trees.h +0 -0
  42. data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/deps/zlib/zconf.h +0 -0
  43. data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/deps/zlib/zlib.h +0 -0
  44. data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/deps/zlib/zutil.c +0 -0
  45. data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/deps/zlib/zutil.h +0 -0
  46. data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/include/git2.h +6 -0
  47. data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/include/git2/attr.h +35 -20
  48. data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/include/git2/blob.h +1 -1
  49. data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/include/git2/branch.h +62 -24
  50. data/vendor/libgit2/include/git2/checkout.h +66 -0
  51. data/vendor/libgit2/include/git2/clone.h +59 -0
  52. data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/include/git2/commit.h +22 -3
  53. data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/include/git2/common.h +27 -0
  54. data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/include/git2/config.h +22 -4
  55. data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/include/git2/diff.h +20 -1
  56. data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/include/git2/errors.h +2 -37
  57. data/vendor/libgit2/include/git2/ignore.h +74 -0
  58. data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/include/git2/index.h +37 -5
  59. data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/include/git2/indexer.h +2 -2
  60. data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/include/git2/inttypes.h +0 -0
  61. data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/include/git2/merge.h +10 -0
  62. data/vendor/libgit2/include/git2/message.h +43 -0
  63. data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/include/git2/net.h +0 -0
  64. data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/include/git2/notes.h +24 -20
  65. data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/include/git2/object.h +18 -1
  66. data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/include/git2/odb.h +16 -1
  67. data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/include/git2/odb_backend.h +8 -1
  68. data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/include/git2/oid.h +26 -2
  69. data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/include/git2/reflog.h +39 -9
  70. data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/include/git2/refs.h +55 -3
  71. data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/include/git2/refspec.h +0 -0
  72. data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/include/git2/remote.h +68 -2
  73. data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/include/git2/repository.h +39 -1
  74. data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/include/git2/reset.h +0 -0
  75. data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/include/git2/revparse.h +0 -0
  76. data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/include/git2/revwalk.h +2 -2
  77. data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/include/git2/signature.h +3 -0
  78. data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/include/git2/status.h +5 -2
  79. data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/include/git2/stdint.h +0 -0
  80. data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/include/git2/submodule.h +0 -0
  81. data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/include/git2/tag.h +3 -3
  82. data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/include/git2/threads.h +0 -0
  83. data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/include/git2/tree.h +77 -20
  84. data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/include/git2/types.h +14 -0
  85. data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/include/git2/version.h +0 -0
  86. data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/include/git2/windows.h +0 -0
  87. data/vendor/libgit2/src/amiga/map.c +51 -0
  88. data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/src/attr.c +39 -6
  89. data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/src/attr.h +1 -0
  90. data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/src/attr_file.c +2 -16
  91. data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/src/attr_file.h +4 -0
  92. data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/src/blob.c +0 -0
  93. data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/src/blob.h +0 -0
  94. data/vendor/libgit2/src/branch.c +294 -0
  95. data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/src/bswap.h +0 -0
  96. data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/src/buffer.c +40 -0
  97. data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/src/buffer.h +22 -0
  98. data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/src/cache.c +1 -0
  99. data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/src/cache.h +0 -0
  100. data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/src/cc-compat.h +0 -0
  101. data/vendor/libgit2/src/checkout.c +230 -0
  102. data/vendor/libgit2/src/clone.c +254 -0
  103. data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/src/commit.c +42 -16
  104. data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/src/commit.h +0 -0
  105. data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/src/common.h +3 -9
  106. data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/src/compat/fnmatch.c +0 -0
  107. data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/src/compat/fnmatch.h +0 -0
  108. data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/src/config.c +15 -5
  109. data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/src/config.h +0 -0
  110. data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/src/config_cache.c +0 -0
  111. data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/src/config_file.c +86 -19
  112. data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/src/config_file.h +16 -1
  113. data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/src/crlf.c +92 -4
  114. data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/src/date.c +20 -20
  115. data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/src/delta-apply.c +0 -0
  116. data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/src/delta-apply.h +0 -0
  117. data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/src/diff.c +45 -18
  118. data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/src/diff.h +0 -0
  119. data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/src/diff_output.c +63 -46
  120. data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/src/errors.c +0 -0
  121. data/vendor/libgit2/src/fetch.c +380 -0
  122. data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/src/fetch.h +1 -2
  123. data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/src/filebuf.c +7 -2
  124. data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/src/filebuf.h +0 -0
  125. data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/src/fileops.c +16 -1
  126. data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/src/fileops.h +10 -0
  127. data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/src/filter.c +38 -2
  128. data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/src/filter.h +15 -0
  129. data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/src/global.c +5 -0
  130. data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/src/global.h +2 -6
  131. data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/src/hash.c +0 -0
  132. data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/src/hash.h +0 -0
  133. data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/src/ignore.c +50 -1
  134. data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/src/ignore.h +0 -0
  135. data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/src/index.c +95 -28
  136. data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/src/index.h +5 -0
  137. data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/src/indexer.c +27 -25
  138. data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/src/iterator.c +0 -0
  139. data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/src/iterator.h +0 -0
  140. data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/src/khash.h +6 -4
  141. data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/src/map.h +4 -0
  142. data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/src/message.c +27 -2
  143. data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/src/message.h +2 -1
  144. data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/src/mwindow.c +54 -10
  145. data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/src/mwindow.h +1 -1
  146. data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/src/netops.c +48 -38
  147. data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/src/netops.h +7 -4
  148. data/vendor/libgit2/src/notes.c +610 -0
  149. data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/src/notes.h +0 -0
  150. data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/src/object.c +73 -2
  151. data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/src/odb.c +20 -1
  152. data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/src/odb.h +0 -0
  153. data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/src/odb_loose.c +89 -3
  154. data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/src/odb_pack.c +61 -3
  155. data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/src/oid.c +1 -6
  156. data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/src/oidmap.h +1 -6
  157. data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/src/pack.c +49 -4
  158. data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/src/pack.h +5 -1
  159. data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/src/path.c +144 -21
  160. data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/src/path.h +46 -0
  161. data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/src/pkt.c +30 -8
  162. data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/src/pkt.h +0 -0
  163. data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/src/pool.c +7 -0
  164. data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/src/pool.h +7 -0
  165. data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/src/posix.c +92 -1
  166. data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/src/posix.h +36 -1
  167. data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/src/ppc/sha1.c +0 -0
  168. data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/src/ppc/sha1.h +0 -0
  169. data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/src/pqueue.c +0 -0
  170. data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/src/pqueue.h +0 -0
  171. data/vendor/libgit2/src/protocol.c +88 -0
  172. data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/src/protocol.h +3 -9
  173. data/vendor/libgit2/src/reflog.c +489 -0
  174. data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/src/reflog.h +3 -0
  175. data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/src/refs.c +95 -52
  176. data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/src/refs.h +0 -0
  177. data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/src/refspec.c +0 -0
  178. data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/src/refspec.h +0 -0
  179. data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/src/remote.c +130 -8
  180. data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/src/remote.h +6 -0
  181. data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/src/repository.c +167 -42
  182. data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/src/repository.h +7 -0
  183. data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/src/reset.c +1 -1
  184. data/vendor/libgit2/src/revparse.c +830 -0
  185. data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/src/revwalk.c +83 -15
  186. data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/src/sha1.c +0 -0
  187. data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/src/sha1.h +5 -0
  188. data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/src/sha1_lookup.c +0 -0
  189. data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/src/sha1_lookup.h +0 -0
  190. data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/src/signature.c +19 -5
  191. data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/src/signature.h +0 -0
  192. data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/src/status.c +24 -18
  193. data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/src/strmap.h +1 -1
  194. data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/src/submodule.c +3 -3
  195. data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/src/tag.c +2 -9
  196. data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/src/tag.h +0 -0
  197. data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/src/thread-utils.c +0 -0
  198. data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/src/thread-utils.h +0 -0
  199. data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/src/transport.c +0 -0
  200. data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/src/transport.h +13 -9
  201. data/vendor/libgit2/src/transports/git.c +245 -0
  202. data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/src/transports/http.c +93 -336
  203. data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/src/transports/local.c +35 -32
  204. data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/src/tree-cache.c +0 -0
  205. data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/src/tree-cache.h +0 -0
  206. data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/src/tree.c +214 -124
  207. data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/src/tree.h +7 -3
  208. data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/src/tsort.c +0 -0
  209. data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/src/unix/map.c +2 -0
  210. data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/src/unix/posix.h +2 -1
  211. data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/src/util.c +30 -0
  212. data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/src/util.h +13 -6
  213. data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/src/vector.c +1 -1
  214. data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/src/vector.h +5 -5
  215. data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/src/win32/dir.c +0 -0
  216. data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/src/win32/dir.h +0 -0
  217. data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/src/win32/map.c +0 -0
  218. data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/src/win32/mingw-compat.h +0 -0
  219. data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/src/win32/msvc-compat.h +0 -0
  220. data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/src/win32/posix.h +1 -0
  221. data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/src/win32/posix_w32.c +17 -1
  222. data/vendor/libgit2/src/win32/precompiled.c +1 -0
  223. data/vendor/libgit2/src/win32/precompiled.h +19 -0
  224. data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/src/win32/pthread.c +0 -0
  225. data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/src/win32/pthread.h +0 -0
  226. data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/src/win32/utf-conv.c +0 -0
  227. data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/src/win32/utf-conv.h +0 -0
  228. data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/src/xdiff/xdiff.h +0 -0
  229. data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/src/xdiff/xdiffi.c +0 -0
  230. data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/src/xdiff/xdiffi.h +0 -0
  231. data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/src/xdiff/xemit.c +0 -0
  232. data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/src/xdiff/xemit.h +0 -0
  233. data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/src/xdiff/xhistogram.c +0 -0
  234. data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/src/xdiff/xinclude.h +0 -0
  235. data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/src/xdiff/xmacros.h +0 -0
  236. data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/src/xdiff/xmerge.c +0 -0
  237. data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/src/xdiff/xpatience.c +0 -0
  238. data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/src/xdiff/xprepare.c +0 -0
  239. data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/src/xdiff/xprepare.h +0 -0
  240. data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/src/xdiff/xtypes.h +0 -0
  241. data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/src/xdiff/xutils.c +0 -0
  242. data/{ext/rugged/vendor/libgit2-dist → vendor/libgit2}/src/xdiff/xutils.h +0 -0
  243. metadata +265 -348
  244. data/ext/rugged/vendor/libgit2-dist.tar.gz +0 -0
  245. data/ext/rugged/vendor/libgit2-dist/examples/diff.c +0 -238
  246. data/ext/rugged/vendor/libgit2-dist/examples/general.c +0 -451
  247. data/ext/rugged/vendor/libgit2-dist/examples/network/common.h +0 -14
  248. data/ext/rugged/vendor/libgit2-dist/examples/network/fetch.c +0 -113
  249. data/ext/rugged/vendor/libgit2-dist/examples/network/git2.c +0 -62
  250. data/ext/rugged/vendor/libgit2-dist/examples/network/index-pack.c +0 -102
  251. data/ext/rugged/vendor/libgit2-dist/examples/network/ls-remote.c +0 -76
  252. data/ext/rugged/vendor/libgit2-dist/examples/showindex.c +0 -43
  253. data/ext/rugged/vendor/libgit2-dist/src/branch.c +0 -208
  254. data/ext/rugged/vendor/libgit2-dist/src/branch.h +0 -17
  255. data/ext/rugged/vendor/libgit2-dist/src/fetch.c +0 -200
  256. data/ext/rugged/vendor/libgit2-dist/src/notes.c +0 -548
  257. data/ext/rugged/vendor/libgit2-dist/src/protocol.c +0 -58
  258. data/ext/rugged/vendor/libgit2-dist/src/reflog.c +0 -340
  259. data/ext/rugged/vendor/libgit2-dist/src/revparse.c +0 -748
  260. data/ext/rugged/vendor/libgit2-dist/src/transports/git.c +0 -477
  261. data/ext/rugged/vendor/libgit2-dist/tests-clar/attr/attr_expect.h +0 -43
  262. data/ext/rugged/vendor/libgit2-dist/tests-clar/attr/file.c +0 -226
  263. data/ext/rugged/vendor/libgit2-dist/tests-clar/attr/flags.c +0 -108
  264. data/ext/rugged/vendor/libgit2-dist/tests-clar/attr/lookup.c +0 -262
  265. data/ext/rugged/vendor/libgit2-dist/tests-clar/attr/repo.c +0 -273
  266. data/ext/rugged/vendor/libgit2-dist/tests-clar/buf/basic.c +0 -29
  267. data/ext/rugged/vendor/libgit2-dist/tests-clar/clar_helpers.c +0 -181
  268. data/ext/rugged/vendor/libgit2-dist/tests-clar/clar_libgit2.h +0 -55
  269. data/ext/rugged/vendor/libgit2-dist/tests-clar/commit/commit.c +0 -44
  270. data/ext/rugged/vendor/libgit2-dist/tests-clar/commit/parse.c +0 -350
  271. data/ext/rugged/vendor/libgit2-dist/tests-clar/commit/signature.c +0 -65
  272. data/ext/rugged/vendor/libgit2-dist/tests-clar/commit/write.c +0 -140
  273. data/ext/rugged/vendor/libgit2-dist/tests-clar/config/add.c +0 -37
  274. data/ext/rugged/vendor/libgit2-dist/tests-clar/config/multivar.c +0 -151
  275. data/ext/rugged/vendor/libgit2-dist/tests-clar/config/new.c +0 -36
  276. data/ext/rugged/vendor/libgit2-dist/tests-clar/config/read.c +0 -221
  277. data/ext/rugged/vendor/libgit2-dist/tests-clar/config/stress.c +0 -61
  278. data/ext/rugged/vendor/libgit2-dist/tests-clar/config/write.c +0 -92
  279. data/ext/rugged/vendor/libgit2-dist/tests-clar/core/buffer.c +0 -613
  280. data/ext/rugged/vendor/libgit2-dist/tests-clar/core/dirent.c +0 -235
  281. data/ext/rugged/vendor/libgit2-dist/tests-clar/core/env.c +0 -115
  282. data/ext/rugged/vendor/libgit2-dist/tests-clar/core/errors.c +0 -60
  283. data/ext/rugged/vendor/libgit2-dist/tests-clar/core/filebuf.c +0 -92
  284. data/ext/rugged/vendor/libgit2-dist/tests-clar/core/hex.c +0 -22
  285. data/ext/rugged/vendor/libgit2-dist/tests-clar/core/oid.c +0 -18
  286. data/ext/rugged/vendor/libgit2-dist/tests-clar/core/path.c +0 -420
  287. data/ext/rugged/vendor/libgit2-dist/tests-clar/core/pool.c +0 -85
  288. data/ext/rugged/vendor/libgit2-dist/tests-clar/core/rmdir.c +0 -68
  289. data/ext/rugged/vendor/libgit2-dist/tests-clar/core/string.c +0 -28
  290. data/ext/rugged/vendor/libgit2-dist/tests-clar/core/strmap.c +0 -102
  291. data/ext/rugged/vendor/libgit2-dist/tests-clar/core/strtol.c +0 -37
  292. data/ext/rugged/vendor/libgit2-dist/tests-clar/core/vector.c +0 -191
  293. data/ext/rugged/vendor/libgit2-dist/tests-clar/date/date.c +0 -15
  294. data/ext/rugged/vendor/libgit2-dist/tests-clar/diff/blob.c +0 -254
  295. data/ext/rugged/vendor/libgit2-dist/tests-clar/diff/diff_helpers.c +0 -104
  296. data/ext/rugged/vendor/libgit2-dist/tests-clar/diff/diff_helpers.h +0 -47
  297. data/ext/rugged/vendor/libgit2-dist/tests-clar/diff/index.c +0 -92
  298. data/ext/rugged/vendor/libgit2-dist/tests-clar/diff/iterator.c +0 -572
  299. data/ext/rugged/vendor/libgit2-dist/tests-clar/diff/patch.c +0 -99
  300. data/ext/rugged/vendor/libgit2-dist/tests-clar/diff/tree.c +0 -210
  301. data/ext/rugged/vendor/libgit2-dist/tests-clar/diff/workdir.c +0 -543
  302. data/ext/rugged/vendor/libgit2-dist/tests-clar/index/read_tree.c +0 -46
  303. data/ext/rugged/vendor/libgit2-dist/tests-clar/index/rename.c +0 -50
  304. data/ext/rugged/vendor/libgit2-dist/tests-clar/index/tests.c +0 -246
  305. data/ext/rugged/vendor/libgit2-dist/tests-clar/network/createremotethenload.c +0 -33
  306. data/ext/rugged/vendor/libgit2-dist/tests-clar/network/remotelocal.c +0 -137
  307. data/ext/rugged/vendor/libgit2-dist/tests-clar/network/remotes.c +0 -183
  308. data/ext/rugged/vendor/libgit2-dist/tests-clar/notes/notes.c +0 -133
  309. data/ext/rugged/vendor/libgit2-dist/tests-clar/notes/notesref.c +0 -57
  310. data/ext/rugged/vendor/libgit2-dist/tests-clar/object/blob/filter.c +0 -125
  311. data/ext/rugged/vendor/libgit2-dist/tests-clar/object/blob/fromchunks.c +0 -87
  312. data/ext/rugged/vendor/libgit2-dist/tests-clar/object/blob/write.c +0 -69
  313. data/ext/rugged/vendor/libgit2-dist/tests-clar/object/commit/commitstagedfile.c +0 -126
  314. data/ext/rugged/vendor/libgit2-dist/tests-clar/object/lookup.c +0 -63
  315. data/ext/rugged/vendor/libgit2-dist/tests-clar/object/message.c +0 -171
  316. data/ext/rugged/vendor/libgit2-dist/tests-clar/object/raw/chars.c +0 -41
  317. data/ext/rugged/vendor/libgit2-dist/tests-clar/object/raw/compare.c +0 -124
  318. data/ext/rugged/vendor/libgit2-dist/tests-clar/object/raw/convert.c +0 -75
  319. data/ext/rugged/vendor/libgit2-dist/tests-clar/object/raw/data.h +0 -323
  320. data/ext/rugged/vendor/libgit2-dist/tests-clar/object/raw/fromstr.c +0 -30
  321. data/ext/rugged/vendor/libgit2-dist/tests-clar/object/raw/hash.c +0 -166
  322. data/ext/rugged/vendor/libgit2-dist/tests-clar/object/raw/short.c +0 -94
  323. data/ext/rugged/vendor/libgit2-dist/tests-clar/object/raw/size.c +0 -13
  324. data/ext/rugged/vendor/libgit2-dist/tests-clar/object/raw/type2string.c +0 -54
  325. data/ext/rugged/vendor/libgit2-dist/tests-clar/object/raw/write.c +0 -455
  326. data/ext/rugged/vendor/libgit2-dist/tests-clar/object/tag/peel.c +0 -56
  327. data/ext/rugged/vendor/libgit2-dist/tests-clar/object/tag/read.c +0 -130
  328. data/ext/rugged/vendor/libgit2-dist/tests-clar/object/tag/write.c +0 -192
  329. data/ext/rugged/vendor/libgit2-dist/tests-clar/object/tree/frompath.c +0 -81
  330. data/ext/rugged/vendor/libgit2-dist/tests-clar/object/tree/read.c +0 -75
  331. data/ext/rugged/vendor/libgit2-dist/tests-clar/object/tree/write.c +0 -84
  332. data/ext/rugged/vendor/libgit2-dist/tests-clar/odb/loose.c +0 -84
  333. data/ext/rugged/vendor/libgit2-dist/tests-clar/odb/loose_data.h +0 -522
  334. data/ext/rugged/vendor/libgit2-dist/tests-clar/odb/mixed.c +0 -24
  335. data/ext/rugged/vendor/libgit2-dist/tests-clar/odb/pack_data.h +0 -151
  336. data/ext/rugged/vendor/libgit2-dist/tests-clar/odb/packed.c +0 -78
  337. data/ext/rugged/vendor/libgit2-dist/tests-clar/odb/sorting.c +0 -71
  338. data/ext/rugged/vendor/libgit2-dist/tests-clar/refs/branches/create.c +0 -113
  339. data/ext/rugged/vendor/libgit2-dist/tests-clar/refs/branches/delete.c +0 -91
  340. data/ext/rugged/vendor/libgit2-dist/tests-clar/refs/branches/listall.c +0 -78
  341. data/ext/rugged/vendor/libgit2-dist/tests-clar/refs/branches/move.c +0 -72
  342. data/ext/rugged/vendor/libgit2-dist/tests-clar/refs/crashes.c +0 -17
  343. data/ext/rugged/vendor/libgit2-dist/tests-clar/refs/create.c +0 -149
  344. data/ext/rugged/vendor/libgit2-dist/tests-clar/refs/delete.c +0 -85
  345. data/ext/rugged/vendor/libgit2-dist/tests-clar/refs/list.c +0 -53
  346. data/ext/rugged/vendor/libgit2-dist/tests-clar/refs/listall.c +0 -36
  347. data/ext/rugged/vendor/libgit2-dist/tests-clar/refs/lookup.c +0 -42
  348. data/ext/rugged/vendor/libgit2-dist/tests-clar/refs/normalize.c +0 -200
  349. data/ext/rugged/vendor/libgit2-dist/tests-clar/refs/overwrite.c +0 -136
  350. data/ext/rugged/vendor/libgit2-dist/tests-clar/refs/pack.c +0 -67
  351. data/ext/rugged/vendor/libgit2-dist/tests-clar/refs/read.c +0 -194
  352. data/ext/rugged/vendor/libgit2-dist/tests-clar/refs/reflog.c +0 -123
  353. data/ext/rugged/vendor/libgit2-dist/tests-clar/refs/rename.c +0 -339
  354. data/ext/rugged/vendor/libgit2-dist/tests-clar/refs/revparse.c +0 -174
  355. data/ext/rugged/vendor/libgit2-dist/tests-clar/refs/unicode.c +0 -42
  356. data/ext/rugged/vendor/libgit2-dist/tests-clar/repo/discover.c +0 -142
  357. data/ext/rugged/vendor/libgit2-dist/tests-clar/repo/getters.c +0 -86
  358. data/ext/rugged/vendor/libgit2-dist/tests-clar/repo/init.c +0 -249
  359. data/ext/rugged/vendor/libgit2-dist/tests-clar/repo/open.c +0 -282
  360. data/ext/rugged/vendor/libgit2-dist/tests-clar/repo/setters.c +0 -80
  361. data/ext/rugged/vendor/libgit2-dist/tests-clar/reset/mixed.c +0 -47
  362. data/ext/rugged/vendor/libgit2-dist/tests-clar/reset/reset_helpers.c +0 -10
  363. data/ext/rugged/vendor/libgit2-dist/tests-clar/reset/reset_helpers.h +0 -6
  364. data/ext/rugged/vendor/libgit2-dist/tests-clar/reset/soft.c +0 -102
  365. data/ext/rugged/vendor/libgit2-dist/tests-clar/revwalk/basic.c +0 -181
  366. data/ext/rugged/vendor/libgit2-dist/tests-clar/revwalk/mergebase.c +0 -148
  367. data/ext/rugged/vendor/libgit2-dist/tests-clar/status/ignore.c +0 -147
  368. data/ext/rugged/vendor/libgit2-dist/tests-clar/status/single.c +0 -29
  369. data/ext/rugged/vendor/libgit2-dist/tests-clar/status/status_data.h +0 -202
  370. data/ext/rugged/vendor/libgit2-dist/tests-clar/status/status_helpers.c +0 -49
  371. data/ext/rugged/vendor/libgit2-dist/tests-clar/status/status_helpers.h +0 -33
  372. data/ext/rugged/vendor/libgit2-dist/tests-clar/status/submodules.c +0 -112
  373. data/ext/rugged/vendor/libgit2-dist/tests-clar/status/worktree.c +0 -649
  374. data/ext/rugged/vendor/libgit2-dist/tests-clar/threads/basic.c +0 -20
@@ -0,0 +1,245 @@
1
+ /*
2
+ * Copyright (C) 2009-2012 the libgit2 contributors
3
+ *
4
+ * This file is part of libgit2, distributed under the GNU GPL v2 with
5
+ * a Linking Exception. For full terms see the included COPYING file.
6
+ */
7
+
8
+ #include "git2/net.h"
9
+ #include "git2/common.h"
10
+ #include "git2/types.h"
11
+ #include "git2/errors.h"
12
+ #include "git2/net.h"
13
+ #include "git2/revwalk.h"
14
+
15
+ #include "vector.h"
16
+ #include "transport.h"
17
+ #include "pkt.h"
18
+ #include "common.h"
19
+ #include "netops.h"
20
+ #include "filebuf.h"
21
+ #include "repository.h"
22
+ #include "fetch.h"
23
+ #include "protocol.h"
24
+
25
+ typedef struct {
26
+ git_transport parent;
27
+ char buff[1024];
28
+ #ifdef GIT_WIN32
29
+ WSADATA wsd;
30
+ #endif
31
+ } transport_git;
32
+
33
+ /*
34
+ * Create a git procol request.
35
+ *
36
+ * For example: 0035git-upload-pack /libgit2/libgit2\0host=github.com\0
37
+ */
38
+ static int gen_proto(git_buf *request, const char *cmd, const char *url)
39
+ {
40
+ char *delim, *repo;
41
+ char default_command[] = "git-upload-pack";
42
+ char host[] = "host=";
43
+ size_t len;
44
+
45
+ delim = strchr(url, '/');
46
+ if (delim == NULL) {
47
+ giterr_set(GITERR_NET, "Malformed URL");
48
+ return -1;
49
+ }
50
+
51
+ repo = delim;
52
+
53
+ delim = strchr(url, ':');
54
+ if (delim == NULL)
55
+ delim = strchr(url, '/');
56
+
57
+ if (cmd == NULL)
58
+ cmd = default_command;
59
+
60
+ len = 4 + strlen(cmd) + 1 + strlen(repo) + 1 + strlen(host) + (delim - url) + 1;
61
+
62
+ git_buf_grow(request, len);
63
+ git_buf_printf(request, "%04x%s %s%c%s",
64
+ (unsigned int)(len & 0x0FFFF), cmd, repo, 0, host);
65
+ git_buf_put(request, url, delim - url);
66
+ git_buf_putc(request, '\0');
67
+
68
+ if (git_buf_oom(request))
69
+ return -1;
70
+
71
+ return 0;
72
+ }
73
+
74
+ static int send_request(git_transport *t, const char *cmd, const char *url)
75
+ {
76
+ int error;
77
+ git_buf request = GIT_BUF_INIT;
78
+
79
+ error = gen_proto(&request, cmd, url);
80
+ if (error < 0)
81
+ goto cleanup;
82
+
83
+ error = gitno_send(t, request.ptr, request.size, 0);
84
+
85
+ cleanup:
86
+ git_buf_free(&request);
87
+ return error;
88
+ }
89
+
90
+ /*
91
+ * Parse the URL and connect to a server, storing the socket in
92
+ * out. For convenience this also takes care of asking for the remote
93
+ * refs
94
+ */
95
+ static int do_connect(transport_git *t, const char *url)
96
+ {
97
+ char *host, *port;
98
+ const char prefix[] = "git://";
99
+
100
+ if (!git__prefixcmp(url, prefix))
101
+ url += strlen(prefix);
102
+
103
+ if (gitno_extract_host_and_port(&host, &port, url, GIT_DEFAULT_PORT) < 0)
104
+ return -1;
105
+
106
+ if (gitno_connect((git_transport *)t, host, port) < 0)
107
+ goto on_error;
108
+
109
+ if (send_request((git_transport *)t, NULL, url) < 0)
110
+ goto on_error;
111
+
112
+ git__free(host);
113
+ git__free(port);
114
+
115
+ return 0;
116
+
117
+ on_error:
118
+ git__free(host);
119
+ git__free(port);
120
+ gitno_close(t->parent.socket);
121
+ return -1;
122
+ }
123
+
124
+ /*
125
+ * Since this is a network connection, we need to parse and store the
126
+ * pkt-lines at this stage and keep them there.
127
+ */
128
+ static int git_connect(git_transport *transport, int direction)
129
+ {
130
+ transport_git *t = (transport_git *) transport;
131
+
132
+ if (direction == GIT_DIR_PUSH) {
133
+ giterr_set(GITERR_NET, "Pushing over git:// is not supported");
134
+ return -1;
135
+ }
136
+
137
+ t->parent.direction = direction;
138
+
139
+ /* Connect and ask for the refs */
140
+ if (do_connect(t, transport->url) < 0)
141
+ return -1;
142
+
143
+ gitno_buffer_setup(transport, &transport->buffer, t->buff, sizeof(t->buff));
144
+
145
+ t->parent.connected = 1;
146
+ if (git_protocol_store_refs(transport, 1) < 0)
147
+ return -1;
148
+
149
+ if (git_protocol_detect_caps(git_vector_get(&transport->refs, 0), &transport->caps) < 0)
150
+ return -1;
151
+
152
+ return 0;
153
+ }
154
+
155
+ static int git_negotiation_step(struct git_transport *transport, void *data, size_t len)
156
+ {
157
+ return gitno_send(transport, data, len, 0);
158
+ }
159
+
160
+ static int git_close(git_transport *t)
161
+ {
162
+ git_buf buf = GIT_BUF_INIT;
163
+
164
+ if (git_pkt_buffer_flush(&buf) < 0)
165
+ return -1;
166
+ /* Can't do anything if there's an error, so don't bother checking */
167
+ gitno_send(t, buf.ptr, buf.size, 0);
168
+ git_buf_free(&buf);
169
+
170
+ if (gitno_close(t->socket) < 0) {
171
+ giterr_set(GITERR_NET, "Failed to close socket");
172
+ return -1;
173
+ }
174
+
175
+ t->connected = 0;
176
+
177
+ #ifdef GIT_WIN32
178
+ WSACleanup();
179
+ #endif
180
+
181
+ return 0;
182
+ }
183
+
184
+ static void git_free(git_transport *transport)
185
+ {
186
+ transport_git *t = (transport_git *) transport;
187
+ git_vector *refs = &transport->refs;
188
+ unsigned int i;
189
+
190
+ for (i = 0; i < refs->length; ++i) {
191
+ git_pkt *p = git_vector_get(refs, i);
192
+ git_pkt_free(p);
193
+ }
194
+ git_vector_free(refs);
195
+
196
+ refs = &transport->common;
197
+ for (i = 0; i < refs->length; ++i) {
198
+ git_pkt *p = git_vector_get(refs, i);
199
+ git_pkt_free(p);
200
+ }
201
+ git_vector_free(refs);
202
+
203
+ git__free(t->parent.url);
204
+ git__free(t);
205
+ }
206
+
207
+ int git_transport_git(git_transport **out)
208
+ {
209
+ transport_git *t;
210
+ #ifdef GIT_WIN32
211
+ int ret;
212
+ #endif
213
+
214
+ t = git__malloc(sizeof(transport_git));
215
+ GITERR_CHECK_ALLOC(t);
216
+
217
+ memset(t, 0x0, sizeof(transport_git));
218
+ if (git_vector_init(&t->parent.common, 8, NULL))
219
+ goto on_error;
220
+
221
+ if (git_vector_init(&t->parent.refs, 16, NULL) < 0)
222
+ goto on_error;
223
+
224
+ t->parent.connect = git_connect;
225
+ t->parent.negotiation_step = git_negotiation_step;
226
+ t->parent.close = git_close;
227
+ t->parent.free = git_free;
228
+
229
+ *out = (git_transport *) t;
230
+
231
+ #ifdef GIT_WIN32
232
+ ret = WSAStartup(MAKEWORD(2,2), &t->wsd);
233
+ if (ret != 0) {
234
+ git_free(*out);
235
+ giterr_set(GITERR_NET, "Winsock init failed");
236
+ return -1;
237
+ }
238
+ #endif
239
+
240
+ return 0;
241
+
242
+ on_error:
243
+ git__free(t);
244
+ return -1;
245
+ }
@@ -29,11 +29,8 @@ enum last_cb {
29
29
 
30
30
  typedef struct {
31
31
  git_transport parent;
32
- git_protocol proto;
33
- git_vector refs;
34
- git_vector common;
32
+ http_parser_settings settings;
35
33
  git_buf buf;
36
- git_remote_head **heads;
37
34
  int error;
38
35
  int transfer_finished :1,
39
36
  ct_found :1,
@@ -46,7 +43,7 @@ typedef struct {
46
43
  char *host;
47
44
  char *port;
48
45
  char *service;
49
- git_transport_caps caps;
46
+ char buffer[4096];
50
47
  #ifdef GIT_WIN32
51
48
  WSADATA wsd;
52
49
  #endif
@@ -183,17 +180,6 @@ static int on_headers_complete(http_parser *parser)
183
180
  return 0;
184
181
  }
185
182
 
186
- static int on_body_store_refs(http_parser *parser, const char *str, size_t len)
187
- {
188
- transport_http *t = (transport_http *) parser->data;
189
-
190
- if (parser->status_code == 404) {
191
- return git_buf_put(&t->buf, str, len);
192
- }
193
-
194
- return git_protocol_store_refs(&t->proto, str, len);
195
- }
196
-
197
183
  static int on_message_complete(http_parser *parser)
198
184
  {
199
185
  transport_http *t = (transport_http *) parser->data;
@@ -208,51 +194,64 @@ static int on_message_complete(http_parser *parser)
208
194
  return 0;
209
195
  }
210
196
 
211
- static int store_refs(transport_http *t)
197
+ static int on_body_fill_buffer(http_parser *parser, const char *str, size_t len)
212
198
  {
213
- http_parser_settings settings;
214
- char buffer[1024];
215
- gitno_buffer buf;
216
- git_pkt *pkt;
217
- int ret;
199
+ git_transport *transport = (git_transport *) parser->data;
200
+ transport_http *t = (transport_http *) parser->data;
201
+ gitno_buffer *buf = &transport->buffer;
218
202
 
219
- http_parser_init(&t->parser, HTTP_RESPONSE);
220
- t->parser.data = t;
221
- memset(&settings, 0x0, sizeof(http_parser_settings));
222
- settings.on_header_field = on_header_field;
223
- settings.on_header_value = on_header_value;
224
- settings.on_headers_complete = on_headers_complete;
225
- settings.on_body = on_body_store_refs;
226
- settings.on_message_complete = on_message_complete;
203
+ if (buf->len - buf->offset < len) {
204
+ giterr_set(GITERR_NET, "Can't fit data in the buffer");
205
+ return t->error = -1;
206
+ }
207
+
208
+ memcpy(buf->data + buf->offset, str, len);
209
+ buf->offset += len;
210
+
211
+ return 0;
212
+ }
227
213
 
228
- gitno_buffer_setup((git_transport *)t, &buf, buffer, sizeof(buffer));
214
+ static int http_recv_cb(gitno_buffer *buf)
215
+ {
216
+ git_transport *transport = (git_transport *) buf->cb_data;
217
+ transport_http *t = (transport_http *) transport;
218
+ size_t old_len;
219
+ gitno_buffer inner;
220
+ char buffer[2048];
221
+ int error;
229
222
 
230
- while(1) {
231
- size_t parsed;
223
+ if (t->transfer_finished)
224
+ return 0;
232
225
 
233
- if ((ret = gitno_recv(&buf)) < 0)
234
- return -1;
226
+ gitno_buffer_setup(transport, &inner, buffer, sizeof(buffer));
235
227
 
236
- parsed = http_parser_execute(&t->parser, &settings, buf.data, buf.offset);
237
- /* Both should happen at the same time */
238
- if (parsed != buf.offset || t->error < 0)
239
- return t->error;
228
+ if ((error = gitno_recv(&inner)) < 0)
229
+ return -1;
240
230
 
241
- gitno_consume_n(&buf, parsed);
231
+ old_len = buf->offset;
232
+ http_parser_execute(&t->parser, &t->settings, inner.data, inner.offset);
233
+ if (t->error < 0)
234
+ return t->error;
242
235
 
243
- if (ret == 0 || t->transfer_finished)
244
- return 0;
245
- }
236
+ return buf->offset - old_len;
237
+ }
246
238
 
247
- pkt = git_vector_get(&t->refs, 0);
248
- if (pkt == NULL || pkt->type != GIT_PKT_COMMENT) {
249
- giterr_set(GITERR_NET, "Invalid HTTP response");
250
- return t->error = -1;
251
- } else {
252
- git_vector_remove(&t->refs, 0);
253
- }
239
+ /* Set up the gitno_buffer so calling gitno_recv() grabs data from the HTTP response */
240
+ static void setup_gitno_buffer(git_transport *transport)
241
+ {
242
+ transport_http *t = (transport_http *) transport;
254
243
 
255
- return 0;
244
+ http_parser_init(&t->parser, HTTP_RESPONSE);
245
+ t->parser.data = t;
246
+ t->transfer_finished = 0;
247
+ memset(&t->settings, 0x0, sizeof(http_parser_settings));
248
+ t->settings.on_header_field = on_header_field;
249
+ t->settings.on_header_value = on_header_value;
250
+ t->settings.on_headers_complete = on_headers_complete;
251
+ t->settings.on_body = on_body_fill_buffer;
252
+ t->settings.on_message_complete = on_message_complete;
253
+
254
+ gitno_buffer_setup_callback(transport, &transport->buffer, t->buffer, sizeof(t->buffer), http_recv_cb, t);
256
255
  }
257
256
 
258
257
  static int http_connect(git_transport *transport, int direction)
@@ -263,6 +262,7 @@ static int http_connect(git_transport *transport, int direction)
263
262
  const char *service = "upload-pack";
264
263
  const char *url = t->parent.url, *prefix_http = "http://", *prefix_https = "https://";
265
264
  const char *default_port;
265
+ git_pkt *pkt;
266
266
 
267
267
  if (direction == GIT_DIR_PUSH) {
268
268
  giterr_set(GITERR_NET, "Pushing over HTTP is not implemented");
@@ -270,8 +270,6 @@ static int http_connect(git_transport *transport, int direction)
270
270
  }
271
271
 
272
272
  t->parent.direction = direction;
273
- if (git_vector_init(&t->refs, 16, NULL) < 0)
274
- return -1;
275
273
 
276
274
  if (!git__prefixcmp(url, prefix_http)) {
277
275
  url = t->parent.url + strlen(prefix_http);
@@ -304,302 +302,61 @@ static int http_connect(git_transport *transport, int direction)
304
302
  if (gitno_send(transport, request.ptr, request.size, 0) < 0)
305
303
  goto cleanup;
306
304
 
307
- ret = store_refs(t);
308
-
309
- cleanup:
310
- git_buf_free(&request);
311
- git_buf_clear(&t->buf);
312
-
313
- return ret;
314
- }
315
-
316
- static int http_ls(git_transport *transport, git_headlist_cb list_cb, void *opaque)
317
- {
318
- transport_http *t = (transport_http *) transport;
319
- git_vector *refs = &t->refs;
320
- unsigned int i;
321
- git_pkt_ref *p;
322
-
323
- git_vector_foreach(refs, i, p) {
324
- if (p->type != GIT_PKT_REF)
325
- continue;
326
-
327
- if (list_cb(&p->head, opaque) < 0) {
328
- giterr_set(GITERR_NET, "The user callback returned error");
329
- return -1;
330
- }
331
- }
332
-
333
- return 0;
334
- }
335
-
336
- static int on_body_parse_response(http_parser *parser, const char *str, size_t len)
337
- {
338
- transport_http *t = (transport_http *) parser->data;
339
- git_buf *buf = &t->buf;
340
- git_vector *common = &t->common;
341
- int error;
342
- const char *line_end, *ptr;
343
-
344
- if (len == 0) { /* EOF */
345
- if (git_buf_len(buf) != 0) {
346
- giterr_set(GITERR_NET, "Unexpected EOF");
347
- return t->error = -1;
348
- } else {
349
- return 0;
350
- }
351
- }
352
-
353
- git_buf_put(buf, str, len);
354
- ptr = buf->ptr;
355
- while (1) {
356
- git_pkt *pkt;
357
-
358
- if (git_buf_len(buf) == 0)
359
- return 0;
360
-
361
- error = git_pkt_parse_line(&pkt, ptr, &line_end, git_buf_len(buf));
362
- if (error == GIT_EBUFS) {
363
- return 0; /* Ask for more */
364
- }
365
- if (error < 0)
366
- return t->error = -1;
367
-
368
- git_buf_consume(buf, line_end);
369
-
370
- if (pkt->type == GIT_PKT_PACK) {
371
- git__free(pkt);
372
- t->pack_ready = 1;
373
- return 0;
374
- }
375
-
376
- if (pkt->type == GIT_PKT_NAK) {
377
- git__free(pkt);
378
- return 0;
379
- }
380
-
381
- if (pkt->type != GIT_PKT_ACK) {
382
- git__free(pkt);
383
- continue;
384
- }
385
-
386
- if (git_vector_insert(common, pkt) < 0)
387
- return -1;
388
- }
389
-
390
- return error;
391
-
392
- }
393
-
394
- static int parse_response(transport_http *t)
395
- {
396
- int ret = 0;
397
- http_parser_settings settings;
398
- char buffer[1024];
399
- gitno_buffer buf;
400
-
401
- http_parser_init(&t->parser, HTTP_RESPONSE);
402
- t->parser.data = t;
403
- t->transfer_finished = 0;
404
- memset(&settings, 0x0, sizeof(http_parser_settings));
405
- settings.on_header_field = on_header_field;
406
- settings.on_header_value = on_header_value;
407
- settings.on_headers_complete = on_headers_complete;
408
- settings.on_body = on_body_parse_response;
409
- settings.on_message_complete = on_message_complete;
410
-
411
- gitno_buffer_setup((git_transport *)t, &buf, buffer, sizeof(buffer));
412
-
413
- while(1) {
414
- size_t parsed;
415
-
416
- if ((ret = gitno_recv(&buf)) < 0)
417
- return -1;
418
-
419
- parsed = http_parser_execute(&t->parser, &settings, buf.data, buf.offset);
420
- /* Both should happen at the same time */
421
- if (parsed != buf.offset || t->error < 0)
422
- return t->error;
423
-
424
- gitno_consume_n(&buf, parsed);
305
+ setup_gitno_buffer(transport);
306
+ if ((ret = git_protocol_store_refs(transport, 2)) < 0)
307
+ goto cleanup;
425
308
 
426
- if (ret == 0 || t->transfer_finished || t->pack_ready) {
427
- return 0;
428
- }
309
+ pkt = git_vector_get(&transport->refs, 0);
310
+ if (pkt == NULL || pkt->type != GIT_PKT_COMMENT) {
311
+ giterr_set(GITERR_NET, "Invalid HTTP response");
312
+ return t->error = -1;
313
+ } else {
314
+ /* Remove the comment and flush pkts */
315
+ git_vector_remove(&transport->refs, 0);
316
+ git__free(pkt);
317
+ pkt = git_vector_get(&transport->refs, 0);
318
+ git_vector_remove(&transport->refs, 0);
319
+ git__free(pkt);
429
320
  }
430
321
 
431
- return ret;
432
- }
433
-
434
- static int http_negotiate_fetch(git_transport *transport, git_repository *repo, const git_vector *wants)
435
- {
436
- transport_http *t = (transport_http *) transport;
437
- int ret;
438
- unsigned int i;
439
- char buff[128];
440
- gitno_buffer buf;
441
- git_revwalk *walk = NULL;
442
- git_oid oid;
443
- git_pkt_ack *pkt;
444
- git_vector *common = &t->common;
445
- git_buf request = GIT_BUF_INIT, data = GIT_BUF_INIT;
446
-
447
- gitno_buffer_setup(transport, &buf, buff, sizeof(buff));
448
-
449
- if (git_vector_init(common, 16, NULL) < 0)
450
- return -1;
451
-
452
- if (git_fetch_setup_walk(&walk, repo) < 0)
453
- return -1;
454
-
455
- do {
456
- if ((ret = do_connect(t, t->host, t->port)) < 0)
457
- goto cleanup;
458
-
459
- if ((ret = git_pkt_buffer_wants(wants, &t->caps, &data)) < 0)
460
- goto cleanup;
461
-
462
- /* We need to send these on each connection */
463
- git_vector_foreach (common, i, pkt) {
464
- if ((ret = git_pkt_buffer_have(&pkt->oid, &data)) < 0)
465
- goto cleanup;
466
- }
467
-
468
- i = 0;
469
- while ((i < 20) && ((ret = git_revwalk_next(&oid, walk)) == 0)) {
470
- if ((ret = git_pkt_buffer_have(&oid, &data)) < 0)
471
- goto cleanup;
472
-
473
- i++;
474
- }
475
-
476
- git_pkt_buffer_done(&data);
477
-
478
- if ((ret = gen_request(&request, t->path, t->host, "POST", "upload-pack", data.size, 0)) < 0)
479
- goto cleanup;
480
-
481
- if ((ret = gitno_send(transport, request.ptr, request.size, 0)) < 0)
482
- goto cleanup;
483
-
484
- if ((ret = gitno_send(transport, data.ptr, data.size, 0)) < 0)
485
- goto cleanup;
486
-
487
- git_buf_clear(&request);
488
- git_buf_clear(&data);
489
-
490
- if (ret < 0 || i >= 256)
491
- break;
492
-
493
- if ((ret = parse_response(t)) < 0)
494
- goto cleanup;
495
-
496
- if (t->pack_ready) {
497
- ret = 0;
498
- goto cleanup;
499
- }
500
-
501
- } while(1);
322
+ if (git_protocol_detect_caps(git_vector_get(&transport->refs, 0), &transport->caps) < 0)
323
+ return t->error = -1;
502
324
 
503
325
  cleanup:
504
326
  git_buf_free(&request);
505
- git_buf_free(&data);
506
- git_revwalk_free(walk);
507
- return ret;
508
- }
509
-
510
- typedef struct {
511
- git_indexer_stream *idx;
512
- git_indexer_stats *stats;
513
- transport_http *transport;
514
- } download_pack_cbdata;
515
-
516
- static int on_message_complete_download_pack(http_parser *parser)
517
- {
518
- download_pack_cbdata *data = (download_pack_cbdata *) parser->data;
519
-
520
- data->transport->transfer_finished = 1;
521
-
522
- return 0;
523
- }
524
- static int on_body_download_pack(http_parser *parser, const char *str, size_t len)
525
- {
526
- download_pack_cbdata *data = (download_pack_cbdata *) parser->data;
527
- transport_http *t = data->transport;
528
- git_indexer_stream *idx = data->idx;
529
- git_indexer_stats *stats = data->stats;
327
+ git_buf_clear(&t->buf);
530
328
 
531
- return t->error = git_indexer_stream_add(idx, str, len, stats);
329
+ return ret;
532
330
  }
533
331
 
534
- /*
535
- * As the server is probably using Transfer-Encoding: chunked, we have
536
- * to use the HTTP parser to download the pack instead of giving it to
537
- * the simple downloader. Furthermore, we're using keep-alive
538
- * connections, so the simple downloader would just hang.
539
- */
540
- static int http_download_pack(git_transport *transport, git_repository *repo, git_off_t *bytes, git_indexer_stats *stats)
332
+ static int http_negotiation_step(struct git_transport *transport, void *data, size_t len)
541
333
  {
542
334
  transport_http *t = (transport_http *) transport;
543
- git_buf *oldbuf = &t->buf;
544
- int recvd;
545
- http_parser_settings settings;
546
- char buffer[1024];
547
- gitno_buffer buf;
548
- git_indexer_stream *idx = NULL;
549
- download_pack_cbdata data;
550
-
551
- gitno_buffer_setup(transport, &buf, buffer, sizeof(buffer));
552
-
553
- if (memcmp(oldbuf->ptr, "PACK", strlen("PACK"))) {
554
- giterr_set(GITERR_NET, "The pack doesn't start with a pack signature");
555
- return -1;
556
- }
335
+ git_buf request = GIT_BUF_INIT;
336
+ int ret;
557
337
 
558
- if (git_indexer_stream_new(&idx, git_repository_path(repo)) < 0)
338
+ /* First, send the data as a HTTP POST request */
339
+ if ((ret = do_connect(t, t->host, t->port)) < 0)
559
340
  return -1;
560
341
 
561
- /*
562
- * This is part of the previous response, so we don't want to
563
- * re-init the parser, just set these two callbacks.
564
- */
565
- memset(stats, 0, sizeof(git_indexer_stats));
566
- data.stats = stats;
567
- data.idx = idx;
568
- data.transport = t;
569
- t->parser.data = &data;
570
- t->transfer_finished = 0;
571
- memset(&settings, 0x0, sizeof(settings));
572
- settings.on_message_complete = on_message_complete_download_pack;
573
- settings.on_body = on_body_download_pack;
574
- *bytes = git_buf_len(oldbuf);
575
-
576
- if (git_indexer_stream_add(idx, git_buf_cstr(oldbuf), git_buf_len(oldbuf), stats) < 0)
342
+ if ((ret = gen_request(&request, t->path, t->host, "POST", "upload-pack", len, 0)) < 0)
577
343
  goto on_error;
578
344
 
579
- gitno_buffer_setup(transport, &buf, buffer, sizeof(buffer));
580
-
581
- do {
582
- size_t parsed;
583
-
584
- if ((recvd = gitno_recv(&buf)) < 0)
585
- goto on_error;
345
+ if ((ret = gitno_send(transport, request.ptr, request.size, 0)) < 0)
346
+ goto on_error;
586
347
 
587
- parsed = http_parser_execute(&t->parser, &settings, buf.data, buf.offset);
588
- if (parsed != buf.offset || t->error < 0)
589
- goto on_error;
348
+ if ((ret = gitno_send(transport, data, len, 0)) < 0)
349
+ goto on_error;
590
350
 
591
- *bytes += recvd;
592
- gitno_consume_n(&buf, parsed);
593
- } while (recvd > 0 && !t->transfer_finished);
351
+ git_buf_free(&request);
594
352
 
595
- if (git_indexer_stream_finalize(idx, stats) < 0)
596
- goto on_error;
353
+ /* Then we need to set up the buffer to grab data from the HTTP response */
354
+ setup_gitno_buffer(transport);
597
355
 
598
- git_indexer_stream_free(idx);
599
356
  return 0;
600
357
 
601
358
  on_error:
602
- git_indexer_stream_free(idx);
359
+ git_buf_free(&request);
603
360
  return -1;
604
361
  }
605
362
 
@@ -622,8 +379,8 @@ static int http_close(git_transport *transport)
622
379
  static void http_free(git_transport *transport)
623
380
  {
624
381
  transport_http *t = (transport_http *) transport;
625
- git_vector *refs = &t->refs;
626
- git_vector *common = &t->common;
382
+ git_vector *refs = &transport->refs;
383
+ git_vector *common = &transport->common;
627
384
  unsigned int i;
628
385
  git_pkt *p;
629
386
 
@@ -644,8 +401,6 @@ static void http_free(git_transport *transport)
644
401
  }
645
402
  git_vector_free(common);
646
403
  git_buf_free(&t->buf);
647
- git_buf_free(&t->proto.buf);
648
- git__free(t->heads);
649
404
  git__free(t->content_type);
650
405
  git__free(t->host);
651
406
  git__free(t->port);
@@ -664,13 +419,15 @@ int git_transport_http(git_transport **out)
664
419
  memset(t, 0x0, sizeof(transport_http));
665
420
 
666
421
  t->parent.connect = http_connect;
667
- t->parent.ls = http_ls;
668
- t->parent.negotiate_fetch = http_negotiate_fetch;
669
- t->parent.download_pack = http_download_pack;
422
+ t->parent.negotiation_step = http_negotiation_step;
670
423
  t->parent.close = http_close;
671
424
  t->parent.free = http_free;
672
- t->proto.refs = &t->refs;
673
- t->proto.transport = (git_transport *) t;
425
+ t->parent.rpc = 1;
426
+
427
+ if (git_vector_init(&t->parent.refs, 16, NULL) < 0) {
428
+ git__free(t);
429
+ return -1;
430
+ }
674
431
 
675
432
  #ifdef GIT_WIN32
676
433
  /* on win32, the WSA context needs to be initialized
@@ -693,7 +450,7 @@ int git_transport_https(git_transport **out)
693
450
  if (git_transport_http((git_transport **)&t) < 0)
694
451
  return -1;
695
452
 
696
- t->parent.encrypt = 1;
453
+ t->parent.use_ssl = 1;
697
454
  t->parent.check_cert = 1;
698
455
  *out = (git_transport *) t;
699
456