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
@@ -15,11 +15,11 @@
15
15
  #include "posix.h"
16
16
  #include "path.h"
17
17
  #include "buffer.h"
18
+ #include "pkt.h"
18
19
 
19
20
  typedef struct {
20
21
  git_transport parent;
21
22
  git_repository *repo;
22
- git_vector refs;
23
23
  } transport_local;
24
24
 
25
25
  static int add_ref(transport_local *t, const char *name)
@@ -27,19 +27,32 @@ static int add_ref(transport_local *t, const char *name)
27
27
  const char peeled[] = "^{}";
28
28
  git_remote_head *head;
29
29
  git_object *obj = NULL, *target = NULL;
30
+ git_transport *transport = (git_transport *) t;
30
31
  git_buf buf = GIT_BUF_INIT;
32
+ git_pkt_ref *pkt;
31
33
 
32
34
  head = git__malloc(sizeof(git_remote_head));
33
35
  GITERR_CHECK_ALLOC(head);
36
+ pkt = git__malloc(sizeof(git_pkt_ref));
37
+ GITERR_CHECK_ALLOC(pkt);
34
38
 
35
39
  head->name = git__strdup(name);
36
40
  GITERR_CHECK_ALLOC(head->name);
37
41
 
38
- if (git_reference_name_to_oid(&head->oid, t->repo, name) < 0 ||
39
- git_vector_insert(&t->refs, head) < 0)
40
- {
41
- git__free(head->name);
42
+ if (git_reference_name_to_oid(&head->oid, t->repo, name) < 0) {
42
43
  git__free(head);
44
+ git__free(pkt->head.name);
45
+ git__free(pkt);
46
+ }
47
+
48
+ pkt->type = GIT_PKT_REF;
49
+ memcpy(&pkt->head, head, sizeof(git_remote_head));
50
+ git__free(head);
51
+
52
+ if (git_vector_insert(&transport->refs, pkt) < 0)
53
+ {
54
+ git__free(pkt->head.name);
55
+ git__free(pkt);
43
56
  return -1;
44
57
  }
45
58
 
@@ -47,7 +60,7 @@ static int add_ref(transport_local *t, const char *name)
47
60
  if (git__prefixcmp(name, GIT_REFS_TAGS_DIR))
48
61
  return 0;
49
62
 
50
- if (git_object_lookup(&obj, t->repo, &head->oid, GIT_OBJ_ANY) < 0)
63
+ if (git_object_lookup(&obj, t->repo, &pkt->head.oid, GIT_OBJ_ANY) < 0)
51
64
  return -1;
52
65
 
53
66
  head = NULL;
@@ -66,14 +79,20 @@ static int add_ref(transport_local *t, const char *name)
66
79
 
67
80
  head->name = git_buf_detach(&buf);
68
81
 
82
+ pkt = git__malloc(sizeof(git_pkt_ref));
83
+ GITERR_CHECK_ALLOC(pkt);
84
+ pkt->type = GIT_PKT_REF;
85
+
69
86
  if (git_tag_peel(&target, (git_tag *) obj) < 0)
70
87
  goto on_error;
71
88
 
72
89
  git_oid_cpy(&head->oid, git_object_id(target));
73
90
  git_object_free(obj);
74
91
  git_object_free(target);
92
+ memcpy(&pkt->head, head, sizeof(git_remote_head));
93
+ git__free(head);
75
94
 
76
- if (git_vector_insert(&t->refs, head) < 0)
95
+ if (git_vector_insert(&transport->refs, pkt) < 0)
77
96
  return -1;
78
97
 
79
98
  return 0;
@@ -88,11 +107,12 @@ static int store_refs(transport_local *t)
88
107
  {
89
108
  unsigned int i;
90
109
  git_strarray ref_names = {0};
110
+ git_transport *transport = (git_transport *) t;
91
111
 
92
112
  assert(t);
93
113
 
94
114
  if (git_reference_list(&ref_names, t->repo, GIT_REF_LISTALL) < 0 ||
95
- git_vector_init(&t->refs, (unsigned int)ref_names.count, NULL) < 0)
115
+ git_vector_init(&transport->refs, (unsigned int)ref_names.count, NULL) < 0)
96
116
  goto on_error;
97
117
 
98
118
  /* Sort the references first */
@@ -111,28 +131,11 @@ static int store_refs(transport_local *t)
111
131
  return 0;
112
132
 
113
133
  on_error:
114
- git_vector_free(&t->refs);
134
+ git_vector_free(&transport->refs);
115
135
  git_strarray_free(&ref_names);
116
136
  return -1;
117
137
  }
118
138
 
119
- static int local_ls(git_transport *transport, git_headlist_cb list_cb, void *payload)
120
- {
121
- transport_local *t = (transport_local *) transport;
122
- git_vector *refs = &t->refs;
123
- unsigned int i;
124
- git_remote_head *h;
125
-
126
- assert(transport && transport->connected);
127
-
128
- git_vector_foreach(refs, i, h) {
129
- if (list_cb(h, payload) < 0)
130
- return -1;
131
- }
132
-
133
- return 0;
134
- }
135
-
136
139
  /*
137
140
  * Try to open the url as a git directory. The direction doesn't
138
141
  * matter in this case because we're calulating the heads ourselves.
@@ -201,14 +204,14 @@ static void local_free(git_transport *transport)
201
204
  {
202
205
  unsigned int i;
203
206
  transport_local *t = (transport_local *) transport;
204
- git_vector *vec = &t->refs;
205
- git_remote_head *h;
207
+ git_vector *vec = &transport->refs;
208
+ git_pkt_ref *pkt;
206
209
 
207
210
  assert(transport);
208
211
 
209
- git_vector_foreach (vec, i, h) {
210
- git__free(h->name);
211
- git__free(h);
212
+ git_vector_foreach (vec, i, pkt) {
213
+ git__free(pkt->head.name);
214
+ git__free(pkt);
212
215
  }
213
216
  git_vector_free(vec);
214
217
 
@@ -229,8 +232,8 @@ int git_transport_local(git_transport **out)
229
232
 
230
233
  memset(t, 0x0, sizeof(transport_local));
231
234
 
235
+ t->parent.own_logic = 1;
232
236
  t->parent.connect = local_connect;
233
- t->parent.ls = local_ls;
234
237
  t->parent.negotiate_fetch = local_negotiate_fetch;
235
238
  t->parent.close = local_close;
236
239
  t->parent.free = local_free;
@@ -12,12 +12,16 @@
12
12
  #include "git2/object.h"
13
13
 
14
14
  #define DEFAULT_TREE_SIZE 16
15
- #define MAX_FILEMODE 0777777
16
15
  #define MAX_FILEMODE_BYTES 6
17
16
 
18
- static int valid_attributes(const int attributes)
17
+ static bool valid_filemode(const int filemode)
19
18
  {
20
- return attributes >= 0 && attributes <= MAX_FILEMODE;
19
+ return (filemode == GIT_FILEMODE_TREE
20
+ || filemode == GIT_FILEMODE_BLOB
21
+ || filemode == GIT_FILEMODE_BLOB_GROUP_WRITABLE
22
+ || filemode == GIT_FILEMODE_BLOB_EXECUTABLE
23
+ || filemode == GIT_FILEMODE_LINK
24
+ || filemode == GIT_FILEMODE_COMMIT);
21
25
  }
22
26
 
23
27
  static int valid_entry_name(const char *filename)
@@ -35,6 +39,22 @@ static int entry_sort_cmp(const void *a, const void *b)
35
39
  entry_b->filename, entry_b->filename_len, git_tree_entry__is_tree(entry_b));
36
40
  }
37
41
 
42
+ static git_tree_entry *alloc_entry(const char *filename)
43
+ {
44
+ git_tree_entry *entry = NULL;
45
+ size_t filename_len = strlen(filename);
46
+
47
+ entry = git__malloc(sizeof(git_tree_entry) + filename_len + 1);
48
+ if (!entry)
49
+ return NULL;
50
+
51
+ memset(entry, 0x0, sizeof(git_tree_entry));
52
+ memcpy(entry->filename, filename, filename_len);
53
+ entry->filename[filename_len] = 0;
54
+ entry->filename_len = filename_len;
55
+
56
+ return entry;
57
+ }
38
58
 
39
59
  struct tree_key_search {
40
60
  const char *filename;
@@ -76,7 +96,7 @@ static int homing_search_cmp(const void *key, const void *array_member)
76
96
  * ambiguous because of folder vs file sorting, we look linearly
77
97
  * around the area for our target file.
78
98
  */
79
- static int tree_key_search(git_vector *entries, const char *filename)
99
+ static int tree_key_search(git_vector *entries, const char *filename, size_t filename_len)
80
100
  {
81
101
  struct tree_key_search ksearch;
82
102
  const git_tree_entry *entry;
@@ -84,7 +104,7 @@ static int tree_key_search(git_vector *entries, const char *filename)
84
104
  int homing, i;
85
105
 
86
106
  ksearch.filename = filename;
87
- ksearch.filename_len = strlen(filename);
107
+ ksearch.filename_len = filename_len;
88
108
 
89
109
  /* Initial homing search; find an entry on the tree with
90
110
  * the same prefix as the filename we're looking for */
@@ -100,7 +120,8 @@ static int tree_key_search(git_vector *entries, const char *filename)
100
120
  if (homing_search_cmp(&ksearch, entry) < 0)
101
121
  break;
102
122
 
103
- if (strcmp(filename, entry->filename) == 0)
123
+ if (entry->filename_len == filename_len &&
124
+ memcmp(filename, entry->filename, filename_len) == 0)
104
125
  return i;
105
126
  }
106
127
 
@@ -112,7 +133,8 @@ static int tree_key_search(git_vector *entries, const char *filename)
112
133
  if (homing_search_cmp(&ksearch, entry) > 0)
113
134
  break;
114
135
 
115
- if (strcmp(filename, entry->filename) == 0)
136
+ if (entry->filename_len == filename_len &&
137
+ memcmp(filename, entry->filename, filename_len) == 0)
116
138
  return i;
117
139
  }
118
140
 
@@ -120,16 +142,38 @@ static int tree_key_search(git_vector *entries, const char *filename)
120
142
  return GIT_ENOTFOUND;
121
143
  }
122
144
 
145
+ void git_tree_entry_free(git_tree_entry *entry)
146
+ {
147
+ if (entry == NULL)
148
+ return;
149
+
150
+ git__free(entry);
151
+ }
152
+
153
+ git_tree_entry *git_tree_entry_dup(const git_tree_entry *entry)
154
+ {
155
+ size_t total_size;
156
+ git_tree_entry *copy;
157
+
158
+ assert(entry);
159
+
160
+ total_size = sizeof(git_tree_entry) + entry->filename_len + 1;
161
+
162
+ copy = git__malloc(total_size);
163
+ if (!copy)
164
+ return NULL;
165
+
166
+ memcpy(copy, entry, total_size);
167
+ return copy;
168
+ }
169
+
123
170
  void git_tree__free(git_tree *tree)
124
171
  {
125
172
  unsigned int i;
126
173
 
127
174
  for (i = 0; i < tree->entries.length; ++i) {
128
- git_tree_entry *e;
129
- e = git_vector_get(&tree->entries, i);
130
-
131
- git__free(e->filename);
132
- git__free(e);
175
+ git_tree_entry *e = git_vector_get(&tree->entries, i);
176
+ git_tree_entry_free(e);
133
177
  }
134
178
 
135
179
  git_vector_free(&tree->entries);
@@ -141,9 +185,9 @@ const git_oid *git_tree_id(git_tree *c)
141
185
  return git_object_id((git_object *)c);
142
186
  }
143
187
 
144
- unsigned int git_tree_entry_attributes(const git_tree_entry *entry)
188
+ git_filemode_t git_tree_entry_filemode(const git_tree_entry *entry)
145
189
  {
146
- return entry->attr;
190
+ return (git_filemode_t)entry->attr;
147
191
  }
148
192
 
149
193
  const char *git_tree_entry_name(const git_tree_entry *entry)
@@ -179,25 +223,42 @@ int git_tree_entry_to_object(
179
223
  return git_object_lookup(object_out, repo, &entry->oid, GIT_OBJ_ANY);
180
224
  }
181
225
 
182
- const git_tree_entry *git_tree_entry_byname(git_tree *tree, const char *filename)
226
+ static git_tree_entry *entry_fromname(git_tree *tree, const char *name, size_t name_len)
183
227
  {
184
- int idx;
185
-
186
- assert(tree && filename);
187
-
188
- idx = tree_key_search(&tree->entries, filename);
189
- if (idx == GIT_ENOTFOUND)
228
+ int idx = tree_key_search(&tree->entries, name, name_len);
229
+ if (idx < 0)
190
230
  return NULL;
191
231
 
192
232
  return git_vector_get(&tree->entries, idx);
193
233
  }
194
234
 
195
- const git_tree_entry *git_tree_entry_byindex(git_tree *tree, unsigned int idx)
235
+ const git_tree_entry *git_tree_entry_byname(git_tree *tree, const char *filename)
236
+ {
237
+ assert(tree && filename);
238
+ return entry_fromname(tree, filename, strlen(filename));
239
+ }
240
+
241
+ const git_tree_entry *git_tree_entry_byindex(git_tree *tree, size_t idx)
196
242
  {
197
243
  assert(tree);
198
244
  return git_vector_get(&tree->entries, idx);
199
245
  }
200
246
 
247
+ const git_tree_entry *git_tree_entry_byoid(git_tree *tree, const git_oid *oid)
248
+ {
249
+ unsigned int i;
250
+ git_tree_entry *e;
251
+
252
+ assert(tree);
253
+
254
+ git_vector_foreach(&tree->entries, i, e) {
255
+ if (memcmp(&e->oid.id, &oid->id, sizeof(oid->id)) == 0)
256
+ return e;
257
+ }
258
+
259
+ return NULL;
260
+ }
261
+
201
262
  int git_tree__prefix_position(git_tree *tree, const char *path)
202
263
  {
203
264
  git_vector *entries = &tree->entries;
@@ -228,7 +289,7 @@ int git_tree__prefix_position(git_tree *tree, const char *path)
228
289
  unsigned int git_tree_entrycount(git_tree *tree)
229
290
  {
230
291
  assert(tree);
231
- return tree->entries.length;
292
+ return (unsigned int)tree->entries.length;
232
293
  }
233
294
 
234
295
  static int tree_error(const char *str)
@@ -244,19 +305,11 @@ static int tree_parse_buffer(git_tree *tree, const char *buffer, const char *buf
244
305
 
245
306
  while (buffer < buffer_end) {
246
307
  git_tree_entry *entry;
247
- int tmp;
248
-
249
- entry = git__calloc(1, sizeof(git_tree_entry));
250
- GITERR_CHECK_ALLOC(entry);
251
-
252
- if (git_vector_insert(&tree->entries, entry) < 0)
253
- return -1;
254
-
255
- if (git__strtol32(&tmp, buffer, &buffer, 8) < 0 ||
256
- !buffer || !valid_attributes(tmp))
257
- return tree_error("Failed to parse tree. Can't parse attributes");
308
+ int attr;
258
309
 
259
- entry->attr = tmp;
310
+ if (git__strtol32(&attr, buffer, &buffer, 8) < 0 ||
311
+ !buffer || !valid_filemode(attr))
312
+ return tree_error("Failed to parse tree. Can't parse filemode");
260
313
 
261
314
  if (*buffer++ != ' ')
262
315
  return tree_error("Failed to parse tree. Object is corrupted");
@@ -264,8 +317,16 @@ static int tree_parse_buffer(git_tree *tree, const char *buffer, const char *buf
264
317
  if (memchr(buffer, 0, buffer_end - buffer) == NULL)
265
318
  return tree_error("Failed to parse tree. Object is corrupted");
266
319
 
267
- entry->filename = git__strdup(buffer);
268
- entry->filename_len = strlen(buffer);
320
+ /** Allocate the entry and store it in the entries vector */
321
+ {
322
+ entry = alloc_entry(buffer);
323
+ GITERR_CHECK_ALLOC(entry);
324
+
325
+ if (git_vector_insert(&tree->entries, entry) < 0)
326
+ return -1;
327
+
328
+ entry->attr = attr;
329
+ }
269
330
 
270
331
  while (buffer < buffer_end && *buffer != 0)
271
332
  buffer++;
@@ -303,18 +364,19 @@ static unsigned int find_next_dir(const char *dirname, git_index *index, unsigne
303
364
  return i;
304
365
  }
305
366
 
306
- static int append_entry(git_treebuilder *bld, const char *filename, const git_oid *id, unsigned int attributes)
367
+ static int append_entry(
368
+ git_treebuilder *bld,
369
+ const char *filename,
370
+ const git_oid *id,
371
+ git_filemode_t filemode)
307
372
  {
308
373
  git_tree_entry *entry;
309
374
 
310
- entry = git__calloc(1, sizeof(git_tree_entry));
375
+ entry = alloc_entry(filename);
311
376
  GITERR_CHECK_ALLOC(entry);
312
377
 
313
- entry->filename = git__strdup(filename);
314
- entry->filename_len = strlen(entry->filename);
315
-
316
378
  git_oid_cpy(&entry->oid, id);
317
- entry->attr = attributes;
379
+ entry->attr = (uint16_t)filemode;
318
380
 
319
381
  if (git_vector_insert(&bld->entries, entry) < 0)
320
382
  return -1;
@@ -455,10 +517,23 @@ static void sort_entries(git_treebuilder *bld)
455
517
  git_vector_sort(&bld->entries);
456
518
  }
457
519
 
520
+ GIT_INLINE(git_filemode_t) normalize_filemode(git_filemode_t filemode)
521
+ {
522
+ /* 100664 mode is an early design mistake. Tree entries may bear
523
+ * this mode in some old git repositories, but it's now deprecated.
524
+ * We silently normalize while inserting new entries in a tree
525
+ * being built.
526
+ */
527
+ if (filemode == GIT_FILEMODE_BLOB_GROUP_WRITABLE)
528
+ return GIT_FILEMODE_BLOB;
529
+
530
+ return filemode;
531
+ }
532
+
458
533
  int git_treebuilder_create(git_treebuilder **builder_p, const git_tree *source)
459
534
  {
460
535
  git_treebuilder *bld;
461
- unsigned int i, source_entries = DEFAULT_TREE_SIZE;
536
+ size_t i, source_entries = DEFAULT_TREE_SIZE;
462
537
 
463
538
  assert(builder_p);
464
539
 
@@ -475,7 +550,10 @@ int git_treebuilder_create(git_treebuilder **builder_p, const git_tree *source)
475
550
  for (i = 0; i < source->entries.length; ++i) {
476
551
  git_tree_entry *entry_src = source->entries.contents[i];
477
552
 
478
- if (append_entry(bld, entry_src->filename, &entry_src->oid, entry_src->attr) < 0)
553
+ if (append_entry(
554
+ bld, entry_src->filename,
555
+ &entry_src->oid,
556
+ normalize_filemode((git_filemode_t)entry_src->attr)) < 0)
479
557
  goto on_error;
480
558
  }
481
559
  }
@@ -488,43 +566,48 @@ on_error:
488
566
  return -1;
489
567
  }
490
568
 
491
- int git_treebuilder_insert(git_tree_entry **entry_out, git_treebuilder *bld, const char *filename, const git_oid *id, unsigned int attributes)
569
+ int git_treebuilder_insert(
570
+ const git_tree_entry **entry_out,
571
+ git_treebuilder *bld,
572
+ const char *filename,
573
+ const git_oid *id,
574
+ git_filemode_t filemode)
492
575
  {
493
576
  git_tree_entry *entry;
494
577
  int pos;
495
578
 
496
579
  assert(bld && id && filename);
497
580
 
498
- if (!valid_attributes(attributes))
499
- return tree_error("Failed to insert entry. Invalid attributes");
581
+ if (!valid_filemode(filemode))
582
+ return tree_error("Failed to insert entry. Invalid filemode");
583
+
584
+ filemode = normalize_filemode(filemode);
500
585
 
501
586
  if (!valid_entry_name(filename))
502
587
  return tree_error("Failed to insert entry. Invalid name for a tree entry");
503
588
 
504
- pos = tree_key_search(&bld->entries, filename);
589
+ pos = tree_key_search(&bld->entries, filename, strlen(filename));
505
590
 
506
591
  if (pos >= 0) {
507
592
  entry = git_vector_get(&bld->entries, pos);
508
593
  if (entry->removed)
509
594
  entry->removed = 0;
510
595
  } else {
511
- entry = git__calloc(1, sizeof(git_tree_entry));
596
+ entry = alloc_entry(filename);
512
597
  GITERR_CHECK_ALLOC(entry);
513
-
514
- entry->filename = git__strdup(filename);
515
- entry->filename_len = strlen(entry->filename);
516
598
  }
517
599
 
518
600
  git_oid_cpy(&entry->oid, id);
519
- entry->attr = attributes;
601
+ entry->attr = filemode;
520
602
 
521
- if (pos == GIT_ENOTFOUND) {
603
+ if (pos < 0) {
522
604
  if (git_vector_insert(&bld->entries, entry) < 0)
523
605
  return -1;
524
606
  }
525
607
 
526
- if (entry_out != NULL)
608
+ if (entry_out != NULL) {
527
609
  *entry_out = entry;
610
+ }
528
611
 
529
612
  return 0;
530
613
  }
@@ -536,7 +619,7 @@ static git_tree_entry *treebuilder_get(git_treebuilder *bld, const char *filenam
536
619
 
537
620
  assert(bld && filename);
538
621
 
539
- idx = tree_key_search(&bld->entries, filename);
622
+ idx = tree_key_search(&bld->entries, filename, strlen(filename));
540
623
  if (idx < 0)
541
624
  return NULL;
542
625
 
@@ -625,8 +708,7 @@ void git_treebuilder_clear(git_treebuilder *bld)
625
708
 
626
709
  for (i = 0; i < bld->entries.length; ++i) {
627
710
  git_tree_entry *e = bld->entries.contents[i];
628
- git__free(e->filename);
629
- git__free(e);
711
+ git_tree_entry_free(e);
630
712
  }
631
713
 
632
714
  git_vector_clear(&bld->entries);
@@ -634,95 +716,92 @@ void git_treebuilder_clear(git_treebuilder *bld)
634
716
 
635
717
  void git_treebuilder_free(git_treebuilder *bld)
636
718
  {
719
+ if (bld == NULL)
720
+ return;
721
+
637
722
  git_treebuilder_clear(bld);
638
723
  git_vector_free(&bld->entries);
639
724
  git__free(bld);
640
725
  }
641
726
 
642
- static int tree_frompath(
643
- git_tree **parent_out,
727
+ static size_t subpath_len(const char *path)
728
+ {
729
+ const char *slash_pos = strchr(path, '/');
730
+ if (slash_pos == NULL)
731
+ return strlen(path);
732
+
733
+ return slash_pos - path;
734
+ }
735
+
736
+ int git_tree_entry_bypath(
737
+ git_tree_entry **entry_out,
644
738
  git_tree *root,
645
- git_buf *treeentry_path,
646
- size_t offset)
739
+ const char *path)
647
740
  {
648
- char *slash_pos = NULL;
649
- const git_tree_entry* entry;
650
741
  int error = 0;
651
742
  git_tree *subtree;
743
+ const git_tree_entry *entry;
744
+ size_t filename_len;
652
745
 
653
- if (!*(treeentry_path->ptr + offset)) {
654
- giterr_set(GITERR_INVALID,
655
- "Invalid relative path to a tree entry '%s'.", treeentry_path->ptr);
656
- return -1;
657
- }
658
-
659
- slash_pos = (char *)strchr(treeentry_path->ptr + offset, '/');
746
+ /* Find how long is the current path component (i.e.
747
+ * the filename between two slashes */
748
+ filename_len = subpath_len(path);
660
749
 
661
- if (slash_pos == NULL)
662
- return git_tree_lookup(
663
- parent_out,
664
- root->object.repo,
665
- git_object_id((const git_object *)root)
666
- );
667
-
668
- if (slash_pos == treeentry_path->ptr + offset) {
669
- giterr_set(GITERR_INVALID,
670
- "Invalid relative path to a tree entry '%s'.", treeentry_path->ptr);
671
- return -1;
750
+ if (filename_len == 0) {
751
+ giterr_set(GITERR_TREE, "Invalid tree path given");
752
+ return GIT_ENOTFOUND;
672
753
  }
673
754
 
674
- *slash_pos = '\0';
675
-
676
- entry = git_tree_entry_byname(root, treeentry_path->ptr + offset);
677
-
678
- if (slash_pos != NULL)
679
- *slash_pos = '/';
755
+ entry = entry_fromname(root, path, filename_len);
680
756
 
681
757
  if (entry == NULL) {
682
758
  giterr_set(GITERR_TREE,
683
- "No tree entry can be found from "
684
- "the given tree and relative path '%s'.", treeentry_path->ptr);
759
+ "The path '%s' does not exist in the given tree", path);
685
760
  return GIT_ENOTFOUND;
686
761
  }
687
762
 
763
+ switch (path[filename_len]) {
764
+ case '/':
765
+ /* If there are more components in the path...
766
+ * then this entry *must* be a tree */
767
+ if (!git_tree_entry__is_tree(entry)) {
768
+ giterr_set(GITERR_TREE,
769
+ "The path '%s' does not exist in the given tree", path);
770
+ return GIT_ENOTFOUND;
771
+ }
772
+
773
+ /* If there's only a slash left in the path, we
774
+ * return the current entry; otherwise, we keep
775
+ * walking down the path */
776
+ if (path[filename_len + 1] != '\0')
777
+ break;
778
+
779
+ case '\0':
780
+ /* If there are no more components in the path, return
781
+ * this entry */
782
+ *entry_out = git_tree_entry_dup(entry);
783
+ return 0;
784
+ }
688
785
 
689
786
  if (git_tree_lookup(&subtree, root->object.repo, &entry->oid) < 0)
690
- return error;
787
+ return -1;
691
788
 
692
- error = tree_frompath(
693
- parent_out,
789
+ error = git_tree_entry_bypath(
790
+ entry_out,
694
791
  subtree,
695
- treeentry_path,
696
- (slash_pos - treeentry_path->ptr) + 1
792
+ path + filename_len + 1
697
793
  );
698
794
 
699
795
  git_tree_free(subtree);
700
796
  return error;
701
797
  }
702
798
 
703
- int git_tree_get_subtree(
704
- git_tree **subtree,
705
- git_tree *root,
706
- const char *subtree_path)
707
- {
708
- int error;
709
- git_buf buffer = GIT_BUF_INIT;
710
-
711
- assert(subtree && root && subtree_path);
712
-
713
- if ((error = git_buf_sets(&buffer, subtree_path)) == 0)
714
- error = tree_frompath(subtree, root, &buffer, 0);
715
-
716
- git_buf_free(&buffer);
717
-
718
- return error;
719
- }
720
-
721
- static int tree_walk_post(
799
+ static int tree_walk(
722
800
  git_tree *tree,
723
801
  git_treewalk_cb callback,
724
802
  git_buf *path,
725
- void *payload)
803
+ void *payload,
804
+ bool preorder)
726
805
  {
727
806
  int error = 0;
728
807
  unsigned int i;
@@ -730,8 +809,13 @@ static int tree_walk_post(
730
809
  for (i = 0; i < tree->entries.length; ++i) {
731
810
  git_tree_entry *entry = tree->entries.contents[i];
732
811
 
733
- if (callback(path->ptr, entry, payload) < 0)
734
- continue;
812
+ if (preorder) {
813
+ error = callback(path->ptr, entry, payload);
814
+ if (error > 0)
815
+ continue;
816
+ if (error < 0)
817
+ return GIT_EUSER;
818
+ }
735
819
 
736
820
  if (git_tree_entry__is_tree(entry)) {
737
821
  git_tree *subtree;
@@ -748,15 +832,21 @@ static int tree_walk_post(
748
832
  if (git_buf_oom(path))
749
833
  return -1;
750
834
 
751
- if (tree_walk_post(subtree, callback, path, payload) < 0)
752
- return -1;
835
+ error = tree_walk(subtree, callback, path, payload, preorder);
836
+ if (error != 0)
837
+ break;
753
838
 
754
839
  git_buf_truncate(path, path_len);
755
840
  git_tree_free(subtree);
756
841
  }
842
+
843
+ if (!preorder && callback(path->ptr, entry, payload) < 0) {
844
+ error = GIT_EUSER;
845
+ break;
846
+ }
757
847
  }
758
848
 
759
- return 0;
849
+ return error;
760
850
  }
761
851
 
762
852
  int git_tree_walk(git_tree *tree, git_treewalk_cb callback, int mode, void *payload)
@@ -766,12 +856,12 @@ int git_tree_walk(git_tree *tree, git_treewalk_cb callback, int mode, void *payl
766
856
 
767
857
  switch (mode) {
768
858
  case GIT_TREEWALK_POST:
769
- error = tree_walk_post(tree, callback, &root_path, payload);
859
+ error = tree_walk(tree, callback, &root_path, payload, false);
770
860
  break;
771
861
 
772
862
  case GIT_TREEWALK_PRE:
773
- tree_error("Preorder tree walking is still not implemented");
774
- return -1;
863
+ error = tree_walk(tree, callback, &root_path, payload, true);
864
+ break;
775
865
 
776
866
  default:
777
867
  giterr_set(GITERR_INVALID, "Invalid walking mode for tree walk");