rugged 0.16.0 → 0.17.0b1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (392) hide show
  1. data/README.md +373 -243
  2. data/Rakefile +22 -0
  3. data/ext/rugged/extconf.rb +9 -6
  4. data/ext/rugged/rugged.c +123 -31
  5. data/ext/rugged/rugged.h +11 -10
  6. data/ext/rugged/rugged_blob.c +181 -18
  7. data/ext/rugged/rugged_commit.c +196 -18
  8. data/ext/rugged/rugged_config.c +94 -5
  9. data/ext/rugged/rugged_object.c +54 -1
  10. data/ext/rugged/rugged_reference.c +203 -15
  11. data/ext/rugged/{remote.c → rugged_remote.c} +35 -10
  12. data/ext/rugged/rugged_repo.c +323 -81
  13. data/ext/rugged/rugged_revwalk.c +57 -4
  14. data/ext/rugged/rugged_signature.c +3 -3
  15. data/ext/rugged/rugged_tag.c +72 -1
  16. data/ext/rugged/rugged_tree.c +70 -2
  17. data/ext/rugged/vendor/libgit2-dist/deps/regex/config.h +7 -0
  18. data/ext/rugged/vendor/libgit2-dist/deps/regex/regcomp.c +3856 -0
  19. data/ext/rugged/vendor/libgit2-dist/deps/regex/regex.c +85 -0
  20. data/ext/rugged/vendor/libgit2-dist/deps/regex/regex.h +582 -0
  21. data/ext/rugged/vendor/libgit2-dist/deps/regex/regex_internal.c +1744 -0
  22. data/ext/rugged/vendor/libgit2-dist/deps/regex/regex_internal.h +810 -0
  23. data/ext/rugged/vendor/libgit2-dist/deps/regex/regexec.c +4369 -0
  24. data/ext/rugged/vendor/libgit2-dist/examples/diff.c +238 -0
  25. data/ext/rugged/vendor/libgit2-dist/examples/general.c +4 -4
  26. data/ext/rugged/vendor/libgit2-dist/examples/network/fetch.c +101 -85
  27. data/ext/rugged/vendor/libgit2-dist/examples/network/git2.c +7 -3
  28. data/ext/rugged/vendor/libgit2-dist/examples/network/index-pack.c +80 -25
  29. data/ext/rugged/vendor/libgit2-dist/examples/network/ls-remote.c +6 -6
  30. data/ext/rugged/vendor/libgit2-dist/include/git2/attr.h +224 -0
  31. data/ext/rugged/vendor/libgit2-dist/include/git2/blob.h +59 -5
  32. data/ext/rugged/vendor/libgit2-dist/include/git2/branch.h +114 -7
  33. data/ext/rugged/vendor/libgit2-dist/include/git2/commit.h +14 -7
  34. data/ext/rugged/vendor/libgit2-dist/include/git2/common.h +4 -3
  35. data/ext/rugged/vendor/libgit2-dist/include/git2/config.h +105 -27
  36. data/ext/rugged/vendor/libgit2-dist/include/git2/diff.h +409 -0
  37. data/ext/rugged/vendor/libgit2-dist/include/git2/errors.h +47 -82
  38. data/ext/rugged/vendor/libgit2-dist/include/git2/index.h +25 -10
  39. data/ext/rugged/vendor/libgit2-dist/include/git2/indexer.h +46 -1
  40. data/ext/rugged/vendor/libgit2-dist/include/git2/merge.h +35 -0
  41. data/ext/rugged/vendor/libgit2-dist/include/git2/net.h +1 -1
  42. data/ext/rugged/vendor/libgit2-dist/include/git2/notes.h +139 -0
  43. data/ext/rugged/vendor/libgit2-dist/include/git2/object.h +5 -5
  44. data/ext/rugged/vendor/libgit2-dist/include/git2/odb.h +13 -13
  45. data/ext/rugged/vendor/libgit2-dist/include/git2/odb_backend.h +8 -8
  46. data/ext/rugged/vendor/libgit2-dist/include/git2/oid.h +14 -9
  47. data/ext/rugged/vendor/libgit2-dist/include/git2/reflog.h +5 -5
  48. data/ext/rugged/vendor/libgit2-dist/include/git2/refs.h +37 -17
  49. data/ext/rugged/vendor/libgit2-dist/include/git2/refspec.h +17 -9
  50. data/ext/rugged/vendor/libgit2-dist/include/git2/remote.h +83 -16
  51. data/ext/rugged/vendor/libgit2-dist/include/git2/repository.h +24 -10
  52. data/ext/rugged/vendor/libgit2-dist/include/git2/reset.h +44 -0
  53. data/ext/rugged/vendor/libgit2-dist/include/git2/revparse.h +36 -0
  54. data/ext/rugged/vendor/libgit2-dist/include/git2/revwalk.h +74 -6
  55. data/ext/rugged/vendor/libgit2-dist/include/git2/signature.h +3 -3
  56. data/ext/rugged/vendor/libgit2-dist/include/git2/status.h +120 -19
  57. data/ext/rugged/vendor/libgit2-dist/include/git2/submodule.h +103 -0
  58. data/ext/rugged/vendor/libgit2-dist/include/git2/tag.h +28 -10
  59. data/ext/rugged/vendor/libgit2-dist/include/git2/threads.h +1 -1
  60. data/ext/rugged/vendor/libgit2-dist/include/git2/tree.h +13 -13
  61. data/ext/rugged/vendor/libgit2-dist/include/git2/types.h +16 -2
  62. data/ext/rugged/vendor/libgit2-dist/include/git2/version.h +3 -3
  63. data/ext/rugged/vendor/libgit2-dist/include/git2/windows.h +1 -1
  64. data/ext/rugged/vendor/libgit2-dist/include/git2.h +7 -2
  65. data/ext/rugged/vendor/libgit2-dist/src/attr.c +677 -0
  66. data/ext/rugged/vendor/libgit2-dist/src/attr.h +56 -0
  67. data/ext/rugged/vendor/libgit2-dist/src/attr_file.c +609 -0
  68. data/ext/rugged/vendor/libgit2-dist/src/attr_file.h +145 -0
  69. data/ext/rugged/vendor/libgit2-dist/src/blob.c +213 -60
  70. data/ext/rugged/vendor/libgit2-dist/src/blob.h +2 -1
  71. data/ext/rugged/vendor/libgit2-dist/src/branch.c +208 -0
  72. data/ext/rugged/vendor/libgit2-dist/src/branch.h +17 -0
  73. data/ext/rugged/vendor/libgit2-dist/src/bswap.h +1 -1
  74. data/ext/rugged/vendor/libgit2-dist/src/buffer.c +395 -46
  75. data/ext/rugged/vendor/libgit2-dist/src/buffer.h +112 -9
  76. data/ext/rugged/vendor/libgit2-dist/src/cache.c +37 -49
  77. data/ext/rugged/vendor/libgit2-dist/src/cache.h +7 -17
  78. data/ext/rugged/vendor/libgit2-dist/src/cc-compat.h +18 -16
  79. data/ext/rugged/vendor/libgit2-dist/src/commit.c +56 -90
  80. data/ext/rugged/vendor/libgit2-dist/src/commit.h +1 -1
  81. data/ext/rugged/vendor/libgit2-dist/src/common.h +12 -5
  82. data/ext/rugged/vendor/libgit2-dist/src/{win32 → compat}/fnmatch.c +1 -1
  83. data/ext/rugged/vendor/libgit2-dist/src/{win32 → compat}/fnmatch.h +3 -3
  84. data/ext/rugged/vendor/libgit2-dist/src/config.c +247 -158
  85. data/ext/rugged/vendor/libgit2-dist/src/config.h +10 -1
  86. data/ext/rugged/vendor/libgit2-dist/src/config_cache.c +94 -0
  87. data/ext/rugged/vendor/libgit2-dist/src/config_file.c +606 -496
  88. data/ext/rugged/vendor/libgit2-dist/src/config_file.h +31 -0
  89. data/ext/rugged/vendor/libgit2-dist/src/crlf.c +228 -0
  90. data/ext/rugged/vendor/libgit2-dist/src/date.c +876 -0
  91. data/ext/rugged/vendor/libgit2-dist/src/delta-apply.c +15 -9
  92. data/ext/rugged/vendor/libgit2-dist/src/delta-apply.h +2 -2
  93. data/ext/rugged/vendor/libgit2-dist/src/diff.c +814 -0
  94. data/ext/rugged/vendor/libgit2-dist/src/diff.h +43 -0
  95. data/ext/rugged/vendor/libgit2-dist/src/diff_output.c +794 -0
  96. data/ext/rugged/vendor/libgit2-dist/src/errors.c +89 -74
  97. data/ext/rugged/vendor/libgit2-dist/src/fetch.c +94 -66
  98. data/ext/rugged/vendor/libgit2-dist/src/fetch.h +5 -4
  99. data/ext/rugged/vendor/libgit2-dist/src/filebuf.c +157 -100
  100. data/ext/rugged/vendor/libgit2-dist/src/filebuf.h +22 -8
  101. data/ext/rugged/vendor/libgit2-dist/src/fileops.c +330 -206
  102. data/ext/rugged/vendor/libgit2-dist/src/fileops.h +82 -51
  103. data/ext/rugged/vendor/libgit2-dist/src/filter.c +165 -0
  104. data/ext/rugged/vendor/libgit2-dist/src/filter.h +119 -0
  105. data/ext/rugged/vendor/libgit2-dist/src/global.c +4 -4
  106. data/ext/rugged/vendor/libgit2-dist/src/global.h +4 -1
  107. data/ext/rugged/vendor/libgit2-dist/src/hash.c +1 -1
  108. data/ext/rugged/vendor/libgit2-dist/src/hash.h +1 -1
  109. data/ext/rugged/vendor/libgit2-dist/src/ignore.c +203 -0
  110. data/ext/rugged/vendor/libgit2-dist/src/ignore.h +38 -0
  111. data/ext/rugged/vendor/libgit2-dist/src/index.c +220 -169
  112. data/ext/rugged/vendor/libgit2-dist/src/index.h +5 -1
  113. data/ext/rugged/vendor/libgit2-dist/src/indexer.c +601 -102
  114. data/ext/rugged/vendor/libgit2-dist/src/iterator.c +748 -0
  115. data/ext/rugged/vendor/libgit2-dist/src/iterator.h +151 -0
  116. data/ext/rugged/vendor/libgit2-dist/src/khash.h +608 -0
  117. data/ext/rugged/vendor/libgit2-dist/src/map.h +6 -1
  118. data/ext/rugged/vendor/libgit2-dist/src/message.c +61 -0
  119. data/ext/rugged/vendor/libgit2-dist/src/message.h +14 -0
  120. data/ext/rugged/vendor/libgit2-dist/src/mwindow.c +27 -29
  121. data/ext/rugged/vendor/libgit2-dist/src/mwindow.h +4 -4
  122. data/ext/rugged/vendor/libgit2-dist/src/netops.c +375 -56
  123. data/ext/rugged/vendor/libgit2-dist/src/netops.h +12 -9
  124. data/ext/rugged/vendor/libgit2-dist/src/notes.c +548 -0
  125. data/ext/rugged/vendor/libgit2-dist/src/notes.h +28 -0
  126. data/ext/rugged/vendor/libgit2-dist/src/object.c +59 -21
  127. data/ext/rugged/vendor/libgit2-dist/src/odb.c +212 -175
  128. data/ext/rugged/vendor/libgit2-dist/src/odb.h +39 -2
  129. data/ext/rugged/vendor/libgit2-dist/src/odb_loose.c +238 -241
  130. data/ext/rugged/vendor/libgit2-dist/src/odb_pack.c +94 -106
  131. data/ext/rugged/vendor/libgit2-dist/src/oid.c +59 -60
  132. data/ext/rugged/vendor/libgit2-dist/src/oidmap.h +42 -0
  133. data/ext/rugged/vendor/libgit2-dist/src/pack.c +198 -170
  134. data/ext/rugged/vendor/libgit2-dist/src/pack.h +16 -9
  135. data/ext/rugged/vendor/libgit2-dist/src/path.c +496 -106
  136. data/ext/rugged/vendor/libgit2-dist/src/path.h +214 -20
  137. data/ext/rugged/vendor/libgit2-dist/src/pkt.c +88 -159
  138. data/ext/rugged/vendor/libgit2-dist/src/pkt.h +9 -5
  139. data/ext/rugged/vendor/libgit2-dist/src/pool.c +294 -0
  140. data/ext/rugged/vendor/libgit2-dist/src/pool.h +125 -0
  141. data/ext/rugged/vendor/libgit2-dist/src/posix.c +38 -16
  142. data/ext/rugged/vendor/libgit2-dist/src/posix.h +20 -2
  143. data/ext/rugged/vendor/libgit2-dist/src/ppc/sha1.c +1 -1
  144. data/ext/rugged/vendor/libgit2-dist/src/ppc/sha1.h +1 -1
  145. data/ext/rugged/vendor/libgit2-dist/src/pqueue.c +7 -7
  146. data/ext/rugged/vendor/libgit2-dist/src/pqueue.h +1 -1
  147. data/ext/rugged/vendor/libgit2-dist/src/protocol.c +21 -13
  148. data/ext/rugged/vendor/libgit2-dist/src/protocol.h +1 -1
  149. data/ext/rugged/vendor/libgit2-dist/src/reflog.c +125 -103
  150. data/ext/rugged/vendor/libgit2-dist/src/reflog.h +1 -1
  151. data/ext/rugged/vendor/libgit2-dist/src/refs.c +713 -640
  152. data/ext/rugged/vendor/libgit2-dist/src/refs.h +27 -3
  153. data/ext/rugged/vendor/libgit2-dist/src/refspec.c +51 -17
  154. data/ext/rugged/vendor/libgit2-dist/src/refspec.h +13 -1
  155. data/ext/rugged/vendor/libgit2-dist/src/remote.c +307 -119
  156. data/ext/rugged/vendor/libgit2-dist/src/remote.h +3 -2
  157. data/ext/rugged/vendor/libgit2-dist/src/repository.c +593 -442
  158. data/ext/rugged/vendor/libgit2-dist/src/repository.h +80 -2
  159. data/ext/rugged/vendor/libgit2-dist/src/reset.c +103 -0
  160. data/ext/rugged/vendor/libgit2-dist/src/revparse.c +753 -0
  161. data/ext/rugged/vendor/libgit2-dist/src/revwalk.c +434 -158
  162. data/ext/rugged/vendor/libgit2-dist/src/sha1.c +3 -3
  163. data/ext/rugged/vendor/libgit2-dist/src/sha1.h +2 -2
  164. data/ext/rugged/vendor/libgit2-dist/src/sha1_lookup.c +3 -2
  165. data/ext/rugged/vendor/libgit2-dist/src/sha1_lookup.h +1 -1
  166. data/ext/rugged/vendor/libgit2-dist/src/signature.c +69 -80
  167. data/ext/rugged/vendor/libgit2-dist/src/signature.h +1 -1
  168. data/ext/rugged/vendor/libgit2-dist/src/status.c +184 -638
  169. data/ext/rugged/vendor/libgit2-dist/src/strmap.h +64 -0
  170. data/ext/rugged/vendor/libgit2-dist/src/submodule.c +387 -0
  171. data/ext/rugged/vendor/libgit2-dist/src/tag.c +162 -137
  172. data/ext/rugged/vendor/libgit2-dist/src/tag.h +2 -1
  173. data/ext/rugged/vendor/libgit2-dist/src/thread-utils.c +1 -1
  174. data/ext/rugged/vendor/libgit2-dist/src/thread-utils.h +8 -8
  175. data/ext/rugged/vendor/libgit2-dist/src/transport.c +31 -19
  176. data/ext/rugged/vendor/libgit2-dist/src/transport.h +31 -11
  177. data/ext/rugged/vendor/libgit2-dist/src/transports/git.c +168 -193
  178. data/ext/rugged/vendor/libgit2-dist/src/transports/http.c +192 -241
  179. data/ext/rugged/vendor/libgit2-dist/src/transports/local.c +92 -86
  180. data/ext/rugged/vendor/libgit2-dist/src/tree-cache.c +32 -49
  181. data/ext/rugged/vendor/libgit2-dist/src/tree-cache.h +1 -1
  182. data/ext/rugged/vendor/libgit2-dist/src/tree.c +172 -145
  183. data/ext/rugged/vendor/libgit2-dist/src/tree.h +16 -2
  184. data/ext/rugged/vendor/libgit2-dist/src/tsort.c +16 -14
  185. data/ext/rugged/vendor/libgit2-dist/src/unix/map.c +8 -24
  186. data/ext/rugged/vendor/libgit2-dist/src/unix/posix.h +9 -3
  187. data/ext/rugged/vendor/libgit2-dist/src/util.c +94 -38
  188. data/ext/rugged/vendor/libgit2-dist/src/util.h +119 -13
  189. data/ext/rugged/vendor/libgit2-dist/src/vector.c +84 -31
  190. data/ext/rugged/vendor/libgit2-dist/src/vector.h +37 -4
  191. data/ext/rugged/vendor/libgit2-dist/src/win32/dir.c +81 -41
  192. data/ext/rugged/vendor/libgit2-dist/src/{dir.h → win32/dir.h} +4 -9
  193. data/ext/rugged/vendor/libgit2-dist/src/win32/map.c +19 -35
  194. data/ext/rugged/vendor/libgit2-dist/src/win32/mingw-compat.h +1 -1
  195. data/ext/rugged/vendor/libgit2-dist/src/win32/msvc-compat.h +5 -1
  196. data/ext/rugged/vendor/libgit2-dist/src/win32/posix.h +10 -8
  197. data/ext/rugged/vendor/libgit2-dist/src/win32/posix_w32.c +262 -118
  198. data/ext/rugged/vendor/libgit2-dist/src/win32/pthread.c +12 -9
  199. data/ext/rugged/vendor/libgit2-dist/src/win32/pthread.h +1 -1
  200. data/ext/rugged/vendor/libgit2-dist/src/win32/utf-conv.c +30 -26
  201. data/ext/rugged/vendor/libgit2-dist/src/win32/utf-conv.h +2 -1
  202. data/ext/rugged/vendor/libgit2-dist/src/xdiff/xdiff.h +135 -0
  203. data/ext/rugged/vendor/libgit2-dist/src/xdiff/xdiffi.c +572 -0
  204. data/ext/rugged/vendor/libgit2-dist/src/xdiff/xdiffi.h +63 -0
  205. data/ext/rugged/vendor/libgit2-dist/src/xdiff/xemit.c +253 -0
  206. data/ext/rugged/vendor/libgit2-dist/src/xdiff/xemit.h +36 -0
  207. data/ext/rugged/vendor/libgit2-dist/src/xdiff/xhistogram.c +371 -0
  208. data/ext/rugged/vendor/libgit2-dist/src/xdiff/xinclude.h +46 -0
  209. data/ext/rugged/vendor/libgit2-dist/src/xdiff/xmacros.h +54 -0
  210. data/ext/rugged/vendor/libgit2-dist/src/xdiff/xmerge.c +619 -0
  211. data/ext/rugged/vendor/libgit2-dist/src/xdiff/xpatience.c +358 -0
  212. data/ext/rugged/vendor/libgit2-dist/src/xdiff/xprepare.c +483 -0
  213. data/ext/rugged/vendor/libgit2-dist/src/xdiff/xprepare.h +34 -0
  214. data/ext/rugged/vendor/libgit2-dist/src/xdiff/xtypes.h +67 -0
  215. data/ext/rugged/vendor/libgit2-dist/src/xdiff/xutils.c +419 -0
  216. data/ext/rugged/vendor/libgit2-dist/src/xdiff/xutils.h +49 -0
  217. data/ext/rugged/vendor/libgit2-dist/tests-clar/attr/attr_expect.h +43 -0
  218. data/ext/rugged/vendor/libgit2-dist/tests-clar/attr/file.c +226 -0
  219. data/ext/rugged/vendor/libgit2-dist/tests-clar/attr/flags.c +108 -0
  220. data/ext/rugged/vendor/libgit2-dist/tests-clar/attr/lookup.c +262 -0
  221. data/ext/rugged/vendor/libgit2-dist/tests-clar/attr/repo.c +273 -0
  222. data/ext/rugged/vendor/libgit2-dist/{tests-clay → tests-clar}/buf/basic.c +5 -5
  223. data/ext/rugged/vendor/libgit2-dist/tests-clar/clar_helpers.c +181 -0
  224. data/ext/rugged/vendor/libgit2-dist/tests-clar/clar_libgit2.h +55 -0
  225. data/ext/rugged/vendor/libgit2-dist/tests-clar/commit/commit.c +44 -0
  226. data/ext/rugged/vendor/libgit2-dist/tests-clar/commit/parse.c +350 -0
  227. data/ext/rugged/vendor/libgit2-dist/tests-clar/commit/signature.c +65 -0
  228. data/ext/rugged/vendor/libgit2-dist/tests-clar/commit/write.c +140 -0
  229. data/ext/rugged/vendor/libgit2-dist/{tests-clay → tests-clar}/config/add.c +3 -3
  230. data/ext/rugged/vendor/libgit2-dist/tests-clar/config/multivar.c +151 -0
  231. data/ext/rugged/vendor/libgit2-dist/{tests-clay → tests-clar}/config/new.c +5 -5
  232. data/ext/rugged/vendor/libgit2-dist/{tests-clay → tests-clar}/config/read.c +44 -32
  233. data/ext/rugged/vendor/libgit2-dist/tests-clar/config/stress.c +61 -0
  234. data/ext/rugged/vendor/libgit2-dist/{tests-clay → tests-clar}/config/write.c +20 -5
  235. data/ext/rugged/vendor/libgit2-dist/tests-clar/core/buffer.c +613 -0
  236. data/ext/rugged/vendor/libgit2-dist/{tests-clay → tests-clar}/core/dirent.c +39 -26
  237. data/ext/rugged/vendor/libgit2-dist/tests-clar/core/env.c +115 -0
  238. data/ext/rugged/vendor/libgit2-dist/tests-clar/core/errors.c +60 -0
  239. data/ext/rugged/vendor/libgit2-dist/{tests-clay → tests-clar}/core/filebuf.c +4 -18
  240. data/ext/rugged/vendor/libgit2-dist/tests-clar/core/hex.c +22 -0
  241. data/ext/rugged/vendor/libgit2-dist/{tests-clay → tests-clar}/core/oid.c +6 -6
  242. data/ext/rugged/vendor/libgit2-dist/tests-clar/core/path.c +420 -0
  243. data/ext/rugged/vendor/libgit2-dist/tests-clar/core/pool.c +85 -0
  244. data/ext/rugged/vendor/libgit2-dist/tests-clar/core/rmdir.c +68 -0
  245. data/ext/rugged/vendor/libgit2-dist/{tests-clay → tests-clar}/core/string.c +1 -1
  246. data/ext/rugged/vendor/libgit2-dist/tests-clar/core/strmap.c +102 -0
  247. data/ext/rugged/vendor/libgit2-dist/{tests-clay → tests-clar}/core/strtol.c +1 -1
  248. data/ext/rugged/vendor/libgit2-dist/tests-clar/core/vector.c +191 -0
  249. data/ext/rugged/vendor/libgit2-dist/tests-clar/date/date.c +15 -0
  250. data/ext/rugged/vendor/libgit2-dist/tests-clar/diff/blob.c +254 -0
  251. data/ext/rugged/vendor/libgit2-dist/tests-clar/diff/diff_helpers.c +104 -0
  252. data/ext/rugged/vendor/libgit2-dist/tests-clar/diff/diff_helpers.h +47 -0
  253. data/ext/rugged/vendor/libgit2-dist/tests-clar/diff/index.c +92 -0
  254. data/ext/rugged/vendor/libgit2-dist/tests-clar/diff/iterator.c +572 -0
  255. data/ext/rugged/vendor/libgit2-dist/tests-clar/diff/patch.c +99 -0
  256. data/ext/rugged/vendor/libgit2-dist/tests-clar/diff/tree.c +210 -0
  257. data/ext/rugged/vendor/libgit2-dist/tests-clar/diff/workdir.c +543 -0
  258. data/ext/rugged/vendor/libgit2-dist/tests-clar/index/read_tree.c +46 -0
  259. data/ext/rugged/vendor/libgit2-dist/{tests-clay → tests-clar}/index/rename.c +2 -12
  260. data/ext/rugged/vendor/libgit2-dist/tests-clar/index/tests.c +246 -0
  261. data/ext/rugged/vendor/libgit2-dist/tests-clar/network/createremotethenload.c +33 -0
  262. data/ext/rugged/vendor/libgit2-dist/tests-clar/network/remotelocal.c +137 -0
  263. data/ext/rugged/vendor/libgit2-dist/tests-clar/network/remotes.c +183 -0
  264. data/ext/rugged/vendor/libgit2-dist/tests-clar/notes/notes.c +133 -0
  265. data/ext/rugged/vendor/libgit2-dist/tests-clar/notes/notesref.c +57 -0
  266. data/ext/rugged/vendor/libgit2-dist/tests-clar/object/blob/filter.c +125 -0
  267. data/ext/rugged/vendor/libgit2-dist/tests-clar/object/blob/fromchunks.c +87 -0
  268. data/ext/rugged/vendor/libgit2-dist/tests-clar/object/blob/write.c +69 -0
  269. data/ext/rugged/vendor/libgit2-dist/tests-clar/object/commit/commitstagedfile.c +126 -0
  270. data/ext/rugged/vendor/libgit2-dist/tests-clar/object/lookup.c +63 -0
  271. data/ext/rugged/vendor/libgit2-dist/tests-clar/object/message.c +171 -0
  272. data/ext/rugged/vendor/libgit2-dist/{tests-clay → tests-clar}/object/raw/chars.c +3 -14
  273. data/ext/rugged/vendor/libgit2-dist/{tests-clay → tests-clar}/object/raw/compare.c +4 -4
  274. data/ext/rugged/vendor/libgit2-dist/{tests-clay → tests-clar}/object/raw/convert.c +10 -10
  275. data/ext/rugged/vendor/libgit2-dist/{tests-clay → tests-clar}/object/raw/data.h +0 -0
  276. data/ext/rugged/vendor/libgit2-dist/{tests-clay → tests-clar}/object/raw/fromstr.c +1 -1
  277. data/ext/rugged/vendor/libgit2-dist/{tests-clay → tests-clar}/object/raw/hash.c +21 -17
  278. data/ext/rugged/vendor/libgit2-dist/{tests-clay → tests-clar}/object/raw/short.c +1 -1
  279. data/ext/rugged/vendor/libgit2-dist/{tests-clay → tests-clar}/object/raw/size.c +1 -1
  280. data/ext/rugged/vendor/libgit2-dist/{tests-clay → tests-clar}/object/raw/type2string.c +14 -14
  281. data/ext/rugged/vendor/libgit2-dist/tests-clar/object/raw/write.c +455 -0
  282. data/ext/rugged/vendor/libgit2-dist/tests-clar/object/tag/peel.c +56 -0
  283. data/ext/rugged/vendor/libgit2-dist/tests-clar/object/tag/read.c +130 -0
  284. data/ext/rugged/vendor/libgit2-dist/tests-clar/object/tag/write.c +192 -0
  285. data/ext/rugged/vendor/libgit2-dist/{tests-clay → tests-clar}/object/tree/frompath.c +22 -16
  286. data/ext/rugged/vendor/libgit2-dist/tests-clar/object/tree/read.c +75 -0
  287. data/ext/rugged/vendor/libgit2-dist/tests-clar/object/tree/write.c +84 -0
  288. data/ext/rugged/vendor/libgit2-dist/{tests-clay → tests-clar}/odb/loose.c +1 -1
  289. data/ext/rugged/vendor/libgit2-dist/{tests-clay → tests-clar}/odb/loose_data.h +0 -0
  290. data/ext/rugged/vendor/libgit2-dist/tests-clar/odb/mixed.c +24 -0
  291. data/ext/rugged/vendor/libgit2-dist/{tests-clay → tests-clar}/odb/pack_data.h +0 -0
  292. data/ext/rugged/vendor/libgit2-dist/{tests-clay → tests-clar}/odb/packed.c +1 -1
  293. data/ext/rugged/vendor/libgit2-dist/{tests-clay → tests-clar}/odb/sorting.c +1 -1
  294. data/ext/rugged/vendor/libgit2-dist/tests-clar/refs/branches/create.c +113 -0
  295. data/ext/rugged/vendor/libgit2-dist/tests-clar/refs/branches/delete.c +91 -0
  296. data/ext/rugged/vendor/libgit2-dist/tests-clar/refs/branches/listall.c +78 -0
  297. data/ext/rugged/vendor/libgit2-dist/tests-clar/refs/branches/move.c +72 -0
  298. data/ext/rugged/vendor/libgit2-dist/tests-clar/refs/crashes.c +17 -0
  299. data/ext/rugged/vendor/libgit2-dist/tests-clar/refs/create.c +149 -0
  300. data/ext/rugged/vendor/libgit2-dist/tests-clar/refs/delete.c +85 -0
  301. data/ext/rugged/vendor/libgit2-dist/tests-clar/refs/list.c +53 -0
  302. data/ext/rugged/vendor/libgit2-dist/tests-clar/refs/listall.c +36 -0
  303. data/ext/rugged/vendor/libgit2-dist/tests-clar/refs/lookup.c +42 -0
  304. data/ext/rugged/vendor/libgit2-dist/tests-clar/refs/normalize.c +200 -0
  305. data/ext/rugged/vendor/libgit2-dist/tests-clar/refs/overwrite.c +136 -0
  306. data/ext/rugged/vendor/libgit2-dist/tests-clar/refs/pack.c +67 -0
  307. data/ext/rugged/vendor/libgit2-dist/tests-clar/refs/read.c +194 -0
  308. data/ext/rugged/vendor/libgit2-dist/tests-clar/refs/reflog.c +123 -0
  309. data/ext/rugged/vendor/libgit2-dist/tests-clar/refs/rename.c +339 -0
  310. data/ext/rugged/vendor/libgit2-dist/tests-clar/refs/revparse.c +174 -0
  311. data/ext/rugged/vendor/libgit2-dist/tests-clar/refs/unicode.c +42 -0
  312. data/ext/rugged/vendor/libgit2-dist/tests-clar/repo/discover.c +142 -0
  313. data/ext/rugged/vendor/libgit2-dist/{tests-clay → tests-clar}/repo/getters.c +19 -1
  314. data/ext/rugged/vendor/libgit2-dist/tests-clar/repo/init.c +235 -0
  315. data/ext/rugged/vendor/libgit2-dist/tests-clar/repo/open.c +282 -0
  316. data/ext/rugged/vendor/libgit2-dist/tests-clar/repo/setters.c +80 -0
  317. data/ext/rugged/vendor/libgit2-dist/tests-clar/reset/mixed.c +47 -0
  318. data/ext/rugged/vendor/libgit2-dist/tests-clar/reset/reset_helpers.c +10 -0
  319. data/ext/rugged/vendor/libgit2-dist/tests-clar/reset/reset_helpers.h +6 -0
  320. data/ext/rugged/vendor/libgit2-dist/tests-clar/reset/soft.c +102 -0
  321. data/ext/rugged/vendor/libgit2-dist/{tests/t05-revwalk.c → tests-clar/revwalk/basic.c} +85 -44
  322. data/ext/rugged/vendor/libgit2-dist/tests-clar/revwalk/mergebase.c +148 -0
  323. data/ext/rugged/vendor/libgit2-dist/tests-clar/status/ignore.c +133 -0
  324. data/ext/rugged/vendor/libgit2-dist/{tests-clay → tests-clar}/status/single.c +2 -11
  325. data/ext/rugged/vendor/libgit2-dist/tests-clar/status/status_data.h +202 -0
  326. data/ext/rugged/vendor/libgit2-dist/tests-clar/status/status_helpers.c +49 -0
  327. data/ext/rugged/vendor/libgit2-dist/tests-clar/status/status_helpers.h +33 -0
  328. data/ext/rugged/vendor/libgit2-dist/tests-clar/status/submodules.c +112 -0
  329. data/ext/rugged/vendor/libgit2-dist/tests-clar/status/worktree.c +649 -0
  330. data/ext/rugged/vendor/libgit2-dist/tests-clar/threads/basic.c +20 -0
  331. data/ext/rugged/vendor/libgit2-dist.tar.gz +0 -0
  332. data/lib/rugged/commit.rb +35 -0
  333. data/lib/rugged/object.rb +7 -0
  334. data/lib/rugged/reference.rb +9 -0
  335. data/lib/rugged/repository.rb +99 -3
  336. data/lib/rugged/tag.rb +22 -0
  337. data/lib/rugged/tree.rb +8 -0
  338. data/lib/rugged/version.rb +1 -1
  339. data/lib/rugged.rb +4 -1
  340. data/test/blob_test.rb +2 -2
  341. data/test/commit_test.rb +27 -13
  342. data/test/config_test.rb +44 -0
  343. data/test/coverage/HEAD.json +1 -1
  344. data/test/fixtures/testrepo.git/config +2 -0
  345. data/test/fixtures/testrepo.git/objects/7f/043268ea43ce18e3540acaabf9e090c91965b0 +0 -0
  346. data/test/lib_test.rb +7 -0
  347. data/test/object_test.rb +3 -3
  348. data/test/reference_test.rb +46 -8
  349. data/test/remote_test.rb +8 -2
  350. data/test/repo_pack_test.rb +3 -3
  351. data/test/repo_test.rb +79 -11
  352. data/test/tag_test.rb +9 -2
  353. data/test/test_helper.rb +21 -0
  354. data/test/tree_test.rb +18 -6
  355. metadata +205 -81
  356. data/ext/rugged/vendor/libgit2-dist/include/git2/zlib.h +0 -40
  357. data/ext/rugged/vendor/libgit2-dist/src/hashtable.c +0 -243
  358. data/ext/rugged/vendor/libgit2-dist/src/hashtable.h +0 -80
  359. data/ext/rugged/vendor/libgit2-dist/tests/t00-core.c +0 -628
  360. data/ext/rugged/vendor/libgit2-dist/tests/t01-data.h +0 -322
  361. data/ext/rugged/vendor/libgit2-dist/tests/t01-rawobj.c +0 -638
  362. data/ext/rugged/vendor/libgit2-dist/tests/t03-data.h +0 -344
  363. data/ext/rugged/vendor/libgit2-dist/tests/t03-objwrite.c +0 -255
  364. data/ext/rugged/vendor/libgit2-dist/tests/t04-commit.c +0 -788
  365. data/ext/rugged/vendor/libgit2-dist/tests/t06-index.c +0 -219
  366. data/ext/rugged/vendor/libgit2-dist/tests/t07-hashtable.c +0 -192
  367. data/ext/rugged/vendor/libgit2-dist/tests/t08-tag.c +0 -357
  368. data/ext/rugged/vendor/libgit2-dist/tests/t09-tree.c +0 -221
  369. data/ext/rugged/vendor/libgit2-dist/tests/t10-refs.c +0 -1294
  370. data/ext/rugged/vendor/libgit2-dist/tests/t12-repo.c +0 -174
  371. data/ext/rugged/vendor/libgit2-dist/tests/t13-threads.c +0 -41
  372. data/ext/rugged/vendor/libgit2-dist/tests/t17-bufs.c +0 -61
  373. data/ext/rugged/vendor/libgit2-dist/tests/t18-status.c +0 -448
  374. data/ext/rugged/vendor/libgit2-dist/tests/test_helpers.c +0 -310
  375. data/ext/rugged/vendor/libgit2-dist/tests/test_helpers.h +0 -83
  376. data/ext/rugged/vendor/libgit2-dist/tests/test_lib.c +0 -198
  377. data/ext/rugged/vendor/libgit2-dist/tests/test_lib.h +0 -54
  378. data/ext/rugged/vendor/libgit2-dist/tests/test_main.c +0 -89
  379. data/ext/rugged/vendor/libgit2-dist/tests-clay/clay.h +0 -187
  380. data/ext/rugged/vendor/libgit2-dist/tests-clay/clay_libgit2.h +0 -28
  381. data/ext/rugged/vendor/libgit2-dist/tests-clay/clay_main.c +0 -1073
  382. data/ext/rugged/vendor/libgit2-dist/tests-clay/config/stress.c +0 -39
  383. data/ext/rugged/vendor/libgit2-dist/tests-clay/core/path.c +0 -139
  384. data/ext/rugged/vendor/libgit2-dist/tests-clay/core/rmdir.c +0 -50
  385. data/ext/rugged/vendor/libgit2-dist/tests-clay/core/vector.c +0 -66
  386. data/ext/rugged/vendor/libgit2-dist/tests-clay/network/remotes.c +0 -50
  387. data/ext/rugged/vendor/libgit2-dist/tests-clay/repo/init.c +0 -104
  388. data/ext/rugged/vendor/libgit2-dist/tests-clay/repo/open.c +0 -54
  389. data/ext/rugged/vendor/libgit2-dist/tests-clay/status/status_data.h +0 -48
  390. data/ext/rugged/vendor/libgit2-dist/tests-clay/status/worktree.c +0 -124
  391. data/lib/rugged/objects.rb +0 -45
  392. data/test/fixtures/testrepo.git/refs/heads/new_name +0 -1
@@ -1,1073 +0,0 @@
1
- #include <assert.h>
2
- #include <setjmp.h>
3
- #include <stdlib.h>
4
- #include <stdio.h>
5
- #include <string.h>
6
- #include <math.h>
7
- #include <stdarg.h>
8
-
9
- /* required for sandboxing */
10
- #include <sys/types.h>
11
- #include <sys/stat.h>
12
-
13
- #ifdef _WIN32
14
- # include <windows.h>
15
- # include <io.h>
16
- # include <shellapi.h>
17
- # include <direct.h>
18
-
19
- # define _MAIN_CC __cdecl
20
-
21
- # define stat(path, st) _stat(path, st)
22
- # define mkdir(path, mode) _mkdir(path)
23
- # define chdir(path) _chdir(path)
24
- # define access(path, mode) _access(path, mode)
25
- # define strdup(str) _strdup(str)
26
-
27
- # ifndef __MINGW32__
28
- # pragma comment(lib, "shell32")
29
- # define strncpy(to, from, to_size) strncpy_s(to, to_size, from, _TRUNCATE)
30
- # define W_OK 02
31
- # define S_ISDIR(x) ((x & _S_IFDIR) != 0)
32
- # define mktemp_s(path, len) _mktemp_s(path, len)
33
- # endif
34
- typedef struct _stat STAT_T;
35
- #else
36
- # include <sys/wait.h> /* waitpid(2) */
37
- # include <unistd.h>
38
- # define _MAIN_CC
39
- typedef struct stat STAT_T;
40
- #endif
41
-
42
- #include "clay.h"
43
-
44
- static void fs_rm(const char *_source);
45
- static void fs_copy(const char *_source, const char *dest);
46
-
47
- static const char *
48
- fixture_path(const char *base, const char *fixture_name);
49
-
50
- struct clay_error {
51
- const char *test;
52
- int test_number;
53
- const char *suite;
54
- const char *file;
55
- int line_number;
56
- const char *error_msg;
57
- char *description;
58
-
59
- struct clay_error *next;
60
- };
61
-
62
- static struct {
63
- const char *active_test;
64
- const char *active_suite;
65
-
66
- int suite_errors;
67
- int total_errors;
68
-
69
- int test_count;
70
-
71
- struct clay_error *errors;
72
- struct clay_error *last_error;
73
-
74
- void (*local_cleanup)(void *);
75
- void *local_cleanup_payload;
76
-
77
- jmp_buf trampoline;
78
- int trampoline_enabled;
79
- } _clay;
80
-
81
- struct clay_func {
82
- const char *name;
83
- void (*ptr)(void);
84
- };
85
-
86
- struct clay_suite {
87
- const char *name;
88
- struct clay_func initialize;
89
- struct clay_func cleanup;
90
- const struct clay_func *tests;
91
- size_t test_count;
92
- };
93
-
94
- /* From clay_print_*.c */
95
- static void clay_print_init(int test_count, int suite_count, const char *suite_names);
96
- static void clay_print_shutdown(int test_count, int suite_count, int error_count);
97
- static void clay_print_error(int num, const struct clay_error *error);
98
- static void clay_print_ontest(const char *test_name, int test_number, int failed);
99
- static void clay_print_onsuite(const char *suite_name);
100
- static void clay_print_onabort(const char *msg, ...);
101
-
102
- /* From clay_sandbox.c */
103
- static void clay_unsandbox(void);
104
- static int clay_sandbox(void);
105
-
106
- /* Autogenerated test data by clay */
107
- static const struct clay_func _clay_cb_buf_basic[] = {
108
- {"printf", &test_buf_basic__printf},
109
- {"resize", &test_buf_basic__resize}
110
- };
111
- static const struct clay_func _clay_cb_config_add[] = {
112
- {"to_existing_section", &test_config_add__to_existing_section},
113
- {"to_new_section", &test_config_add__to_new_section}
114
- };
115
- static const struct clay_func _clay_cb_config_new[] = {
116
- {"write_new_config", &test_config_new__write_new_config}
117
- };
118
- static const struct clay_func _clay_cb_config_read[] = {
119
- {"blank_lines", &test_config_read__blank_lines},
120
- {"case_sensitive", &test_config_read__case_sensitive},
121
- {"empty_files", &test_config_read__empty_files},
122
- {"header_in_last_line", &test_config_read__header_in_last_line},
123
- {"invalid_ext_headers", &test_config_read__invalid_ext_headers},
124
- {"lone_variable", &test_config_read__lone_variable},
125
- {"multiline_value", &test_config_read__multiline_value},
126
- {"number_suffixes", &test_config_read__number_suffixes},
127
- {"prefixes", &test_config_read__prefixes},
128
- {"simple_read", &test_config_read__simple_read},
129
- {"subsection_header", &test_config_read__subsection_header}
130
- };
131
- static const struct clay_func _clay_cb_config_stress[] = {
132
- {"dont_break_on_invalid_input", &test_config_stress__dont_break_on_invalid_input}
133
- };
134
- static const struct clay_func _clay_cb_config_write[] = {
135
- {"delete_inexistent", &test_config_write__delete_inexistent},
136
- {"delete_value", &test_config_write__delete_value},
137
- {"replace_value", &test_config_write__replace_value}
138
- };
139
- static const struct clay_func _clay_cb_core_dirent[] = {
140
- {"dont_traverse_dot", &test_core_dirent__dont_traverse_dot},
141
- {"dont_traverse_empty_folders", &test_core_dirent__dont_traverse_empty_folders},
142
- {"traverse_slash_terminated_folder", &test_core_dirent__traverse_slash_terminated_folder},
143
- {"traverse_subfolder", &test_core_dirent__traverse_subfolder},
144
- {"traverse_weird_filenames", &test_core_dirent__traverse_weird_filenames}
145
- };
146
- static const struct clay_func _clay_cb_core_filebuf[] = {
147
- {"0", &test_core_filebuf__0},
148
- {"1", &test_core_filebuf__1},
149
- {"2", &test_core_filebuf__2},
150
- {"3", &test_core_filebuf__3},
151
- {"4", &test_core_filebuf__4},
152
- {"5", &test_core_filebuf__5}
153
- };
154
- static const struct clay_func _clay_cb_core_oid[] = {
155
- {"streq", &test_core_oid__streq}
156
- };
157
- static const struct clay_func _clay_cb_core_path[] = {
158
- {"0", &test_core_path__0},
159
- {"1", &test_core_path__1},
160
- {"2", &test_core_path__2},
161
- {"5", &test_core_path__5},
162
- {"6", &test_core_path__6}
163
- };
164
- static const struct clay_func _clay_cb_core_rmdir[] = {
165
- {"delete_recursive", &test_core_rmdir__delete_recursive},
166
- {"fail_to_delete_non_empty_dir", &test_core_rmdir__fail_to_delete_non_empty_dir}
167
- };
168
- static const struct clay_func _clay_cb_core_string[] = {
169
- {"0", &test_core_string__0},
170
- {"1", &test_core_string__1}
171
- };
172
- static const struct clay_func _clay_cb_core_strtol[] = {
173
- {"int32", &test_core_strtol__int32},
174
- {"int64", &test_core_strtol__int64}
175
- };
176
- static const struct clay_func _clay_cb_core_vector[] = {
177
- {"0", &test_core_vector__0},
178
- {"1", &test_core_vector__1},
179
- {"2", &test_core_vector__2}
180
- };
181
- static const struct clay_func _clay_cb_index_rename[] = {
182
- {"single_file", &test_index_rename__single_file}
183
- };
184
- static const struct clay_func _clay_cb_network_remotes[] = {
185
- {"fnmatch", &test_network_remotes__fnmatch},
186
- {"parsing", &test_network_remotes__parsing},
187
- {"refspec_parsing", &test_network_remotes__refspec_parsing},
188
- {"transform", &test_network_remotes__transform}
189
- };
190
- static const struct clay_func _clay_cb_object_raw_chars[] = {
191
- {"build_valid_oid_from_raw_bytes", &test_object_raw_chars__build_valid_oid_from_raw_bytes},
192
- {"find_invalid_chars_in_oid", &test_object_raw_chars__find_invalid_chars_in_oid}
193
- };
194
- static const struct clay_func _clay_cb_object_raw_compare[] = {
195
- {"compare_allocfmt_oids", &test_object_raw_compare__compare_allocfmt_oids},
196
- {"compare_fmt_oids", &test_object_raw_compare__compare_fmt_oids},
197
- {"compare_pathfmt_oids", &test_object_raw_compare__compare_pathfmt_oids},
198
- {"succeed_on_copy_oid", &test_object_raw_compare__succeed_on_copy_oid},
199
- {"succeed_on_oid_comparison_equal", &test_object_raw_compare__succeed_on_oid_comparison_equal},
200
- {"succeed_on_oid_comparison_greater", &test_object_raw_compare__succeed_on_oid_comparison_greater},
201
- {"succeed_on_oid_comparison_lesser", &test_object_raw_compare__succeed_on_oid_comparison_lesser}
202
- };
203
- static const struct clay_func _clay_cb_object_raw_convert[] = {
204
- {"succeed_on_oid_to_string_conversion", &test_object_raw_convert__succeed_on_oid_to_string_conversion},
205
- {"succeed_on_oid_to_string_conversion_big", &test_object_raw_convert__succeed_on_oid_to_string_conversion_big}
206
- };
207
- static const struct clay_func _clay_cb_object_raw_fromstr[] = {
208
- {"fail_on_invalid_oid_string", &test_object_raw_fromstr__fail_on_invalid_oid_string},
209
- {"succeed_on_valid_oid_string", &test_object_raw_fromstr__succeed_on_valid_oid_string}
210
- };
211
- static const struct clay_func _clay_cb_object_raw_hash[] = {
212
- {"hash_buffer_in_single_call", &test_object_raw_hash__hash_buffer_in_single_call},
213
- {"hash_by_blocks", &test_object_raw_hash__hash_by_blocks},
214
- {"hash_commit_object", &test_object_raw_hash__hash_commit_object},
215
- {"hash_junk_data", &test_object_raw_hash__hash_junk_data},
216
- {"hash_multi_byte_object", &test_object_raw_hash__hash_multi_byte_object},
217
- {"hash_one_byte_object", &test_object_raw_hash__hash_one_byte_object},
218
- {"hash_tag_object", &test_object_raw_hash__hash_tag_object},
219
- {"hash_tree_object", &test_object_raw_hash__hash_tree_object},
220
- {"hash_two_byte_object", &test_object_raw_hash__hash_two_byte_object},
221
- {"hash_vector", &test_object_raw_hash__hash_vector},
222
- {"hash_zero_length_object", &test_object_raw_hash__hash_zero_length_object}
223
- };
224
- static const struct clay_func _clay_cb_object_raw_short[] = {
225
- {"oid_shortener_no_duplicates", &test_object_raw_short__oid_shortener_no_duplicates},
226
- {"oid_shortener_stresstest_git_oid_shorten", &test_object_raw_short__oid_shortener_stresstest_git_oid_shorten}
227
- };
228
- static const struct clay_func _clay_cb_object_raw_size[] = {
229
- {"validate_oid_size", &test_object_raw_size__validate_oid_size}
230
- };
231
- static const struct clay_func _clay_cb_object_raw_type2string[] = {
232
- {"check_type_is_loose", &test_object_raw_type2string__check_type_is_loose},
233
- {"convert_string_to_type", &test_object_raw_type2string__convert_string_to_type},
234
- {"convert_type_to_string", &test_object_raw_type2string__convert_type_to_string}
235
- };
236
- static const struct clay_func _clay_cb_object_tree_frompath[] = {
237
- {"fail_when_processing_an_invalid_path", &test_object_tree_frompath__fail_when_processing_an_invalid_path},
238
- {"fail_when_processing_an_unknown_tree_segment", &test_object_tree_frompath__fail_when_processing_an_unknown_tree_segment},
239
- {"retrieve_tree_from_path_to_treeentry", &test_object_tree_frompath__retrieve_tree_from_path_to_treeentry}
240
- };
241
- static const struct clay_func _clay_cb_odb_loose[] = {
242
- {"exists", &test_odb_loose__exists},
243
- {"simple_reads", &test_odb_loose__simple_reads}
244
- };
245
- static const struct clay_func _clay_cb_odb_packed[] = {
246
- {"mass_read", &test_odb_packed__mass_read},
247
- {"read_header_0", &test_odb_packed__read_header_0},
248
- {"read_header_1", &test_odb_packed__read_header_1}
249
- };
250
- static const struct clay_func _clay_cb_odb_sorting[] = {
251
- {"alternate_backends_sorting", &test_odb_sorting__alternate_backends_sorting},
252
- {"basic_backends_sorting", &test_odb_sorting__basic_backends_sorting}
253
- };
254
- static const struct clay_func _clay_cb_repo_getters[] = {
255
- {"empty", &test_repo_getters__empty},
256
- {"head_detached", &test_repo_getters__head_detached},
257
- {"head_orphan", &test_repo_getters__head_orphan}
258
- };
259
- static const struct clay_func _clay_cb_repo_init[] = {
260
- {"bare_repo", &test_repo_init__bare_repo},
261
- {"bare_repo_noslash", &test_repo_init__bare_repo_noslash},
262
- {"standard_repo", &test_repo_init__standard_repo},
263
- {"standard_repo_noslash", &test_repo_init__standard_repo_noslash}
264
- };
265
- static const struct clay_func _clay_cb_repo_open[] = {
266
- {"bare_empty_repo", &test_repo_open__bare_empty_repo},
267
- {"standard_empty_repo", &test_repo_open__standard_empty_repo}
268
- };
269
- static const struct clay_func _clay_cb_status_single[] = {
270
- {"hash_single_file", &test_status_single__hash_single_file}
271
- };
272
- static const struct clay_func _clay_cb_status_worktree[] = {
273
- {"empty_repository", &test_status_worktree__empty_repository},
274
- {"whole_repository", &test_status_worktree__whole_repository}
275
- };
276
-
277
- static const struct clay_suite _clay_suites[] = {
278
- {
279
- "buf::basic",
280
- {NULL, NULL},
281
- {NULL, NULL},
282
- _clay_cb_buf_basic, 2
283
- },
284
- {
285
- "config::add",
286
- {"initialize", &test_config_add__initialize},
287
- {"cleanup", &test_config_add__cleanup},
288
- _clay_cb_config_add, 2
289
- },
290
- {
291
- "config::new",
292
- {NULL, NULL},
293
- {NULL, NULL},
294
- _clay_cb_config_new, 1
295
- },
296
- {
297
- "config::read",
298
- {NULL, NULL},
299
- {NULL, NULL},
300
- _clay_cb_config_read, 11
301
- },
302
- {
303
- "config::stress",
304
- {"initialize", &test_config_stress__initialize},
305
- {"cleanup", &test_config_stress__cleanup},
306
- _clay_cb_config_stress, 1
307
- },
308
- {
309
- "config::write",
310
- {"initialize", &test_config_write__initialize},
311
- {"cleanup", &test_config_write__cleanup},
312
- _clay_cb_config_write, 3
313
- },
314
- {
315
- "core::dirent",
316
- {NULL, NULL},
317
- {NULL, NULL},
318
- _clay_cb_core_dirent, 5
319
- },
320
- {
321
- "core::filebuf",
322
- {NULL, NULL},
323
- {NULL, NULL},
324
- _clay_cb_core_filebuf, 6
325
- },
326
- {
327
- "core::oid",
328
- {"initialize", &test_core_oid__initialize},
329
- {NULL, NULL},
330
- _clay_cb_core_oid, 1
331
- },
332
- {
333
- "core::path",
334
- {NULL, NULL},
335
- {NULL, NULL},
336
- _clay_cb_core_path, 5
337
- },
338
- {
339
- "core::rmdir",
340
- {"initialize", &test_core_rmdir__initialize},
341
- {NULL, NULL},
342
- _clay_cb_core_rmdir, 2
343
- },
344
- {
345
- "core::string",
346
- {NULL, NULL},
347
- {NULL, NULL},
348
- _clay_cb_core_string, 2
349
- },
350
- {
351
- "core::strtol",
352
- {NULL, NULL},
353
- {NULL, NULL},
354
- _clay_cb_core_strtol, 2
355
- },
356
- {
357
- "core::vector",
358
- {NULL, NULL},
359
- {NULL, NULL},
360
- _clay_cb_core_vector, 3
361
- },
362
- {
363
- "index::rename",
364
- {NULL, NULL},
365
- {NULL, NULL},
366
- _clay_cb_index_rename, 1
367
- },
368
- {
369
- "network::remotes",
370
- {"initialize", &test_network_remotes__initialize},
371
- {"cleanup", &test_network_remotes__cleanup},
372
- _clay_cb_network_remotes, 4
373
- },
374
- {
375
- "object::raw::chars",
376
- {NULL, NULL},
377
- {NULL, NULL},
378
- _clay_cb_object_raw_chars, 2
379
- },
380
- {
381
- "object::raw::compare",
382
- {NULL, NULL},
383
- {NULL, NULL},
384
- _clay_cb_object_raw_compare, 7
385
- },
386
- {
387
- "object::raw::convert",
388
- {NULL, NULL},
389
- {NULL, NULL},
390
- _clay_cb_object_raw_convert, 2
391
- },
392
- {
393
- "object::raw::fromstr",
394
- {NULL, NULL},
395
- {NULL, NULL},
396
- _clay_cb_object_raw_fromstr, 2
397
- },
398
- {
399
- "object::raw::hash",
400
- {NULL, NULL},
401
- {NULL, NULL},
402
- _clay_cb_object_raw_hash, 11
403
- },
404
- {
405
- "object::raw::short",
406
- {NULL, NULL},
407
- {NULL, NULL},
408
- _clay_cb_object_raw_short, 2
409
- },
410
- {
411
- "object::raw::size",
412
- {NULL, NULL},
413
- {NULL, NULL},
414
- _clay_cb_object_raw_size, 1
415
- },
416
- {
417
- "object::raw::type2string",
418
- {NULL, NULL},
419
- {NULL, NULL},
420
- _clay_cb_object_raw_type2string, 3
421
- },
422
- {
423
- "object::tree::frompath",
424
- {"initialize", &test_object_tree_frompath__initialize},
425
- {"cleanup", &test_object_tree_frompath__cleanup},
426
- _clay_cb_object_tree_frompath, 3
427
- },
428
- {
429
- "odb::loose",
430
- {"initialize", &test_odb_loose__initialize},
431
- {"cleanup", &test_odb_loose__cleanup},
432
- _clay_cb_odb_loose, 2
433
- },
434
- {
435
- "odb::packed",
436
- {"initialize", &test_odb_packed__initialize},
437
- {"cleanup", &test_odb_packed__cleanup},
438
- _clay_cb_odb_packed, 3
439
- },
440
- {
441
- "odb::sorting",
442
- {"initialize", &test_odb_sorting__initialize},
443
- {"cleanup", &test_odb_sorting__cleanup},
444
- _clay_cb_odb_sorting, 2
445
- },
446
- {
447
- "repo::getters",
448
- {"initialize", &test_repo_getters__initialize},
449
- {"cleanup", &test_repo_getters__cleanup},
450
- _clay_cb_repo_getters, 3
451
- },
452
- {
453
- "repo::init",
454
- {"initialize", &test_repo_init__initialize},
455
- {NULL, NULL},
456
- _clay_cb_repo_init, 4
457
- },
458
- {
459
- "repo::open",
460
- {NULL, NULL},
461
- {NULL, NULL},
462
- _clay_cb_repo_open, 2
463
- },
464
- {
465
- "status::single",
466
- {NULL, NULL},
467
- {NULL, NULL},
468
- _clay_cb_status_single, 1
469
- },
470
- {
471
- "status::worktree",
472
- {"initialize", &test_status_worktree__initialize},
473
- {"cleanup", &test_status_worktree__cleanup},
474
- _clay_cb_status_worktree, 2
475
- }
476
- };
477
-
478
- static size_t _clay_suite_count = 33;
479
- static size_t _clay_callback_count = 103;
480
-
481
- /* Core test functions */
482
- static void
483
- clay_run_test(
484
- const struct clay_func *test,
485
- const struct clay_func *initialize,
486
- const struct clay_func *cleanup)
487
- {
488
- int error_st = _clay.suite_errors;
489
-
490
- _clay.trampoline_enabled = 1;
491
-
492
- if (setjmp(_clay.trampoline) == 0) {
493
- if (initialize->ptr != NULL)
494
- initialize->ptr();
495
-
496
- test->ptr();
497
- }
498
-
499
- _clay.trampoline_enabled = 0;
500
-
501
- if (_clay.local_cleanup != NULL)
502
- _clay.local_cleanup(_clay.local_cleanup_payload);
503
-
504
- if (cleanup->ptr != NULL)
505
- cleanup->ptr();
506
-
507
- _clay.test_count++;
508
-
509
- /* remove any local-set cleanup methods */
510
- _clay.local_cleanup = NULL;
511
- _clay.local_cleanup_payload = NULL;
512
-
513
- clay_print_ontest(
514
- test->name,
515
- _clay.test_count,
516
- (_clay.suite_errors > error_st)
517
- );
518
- }
519
-
520
- static void
521
- clay_report_errors(void)
522
- {
523
- int i = 1;
524
- struct clay_error *error, *next;
525
-
526
- error = _clay.errors;
527
- while (error != NULL) {
528
- next = error->next;
529
- clay_print_error(i++, error);
530
- free(error->description);
531
- free(error);
532
- error = next;
533
- }
534
-
535
- _clay.errors = _clay.last_error = NULL;
536
- }
537
-
538
- static void
539
- clay_run_suite(const struct clay_suite *suite)
540
- {
541
- const struct clay_func *test = suite->tests;
542
- size_t i;
543
-
544
- clay_print_onsuite(suite->name);
545
-
546
- _clay.active_suite = suite->name;
547
- _clay.suite_errors = 0;
548
-
549
- for (i = 0; i < suite->test_count; ++i) {
550
- _clay.active_test = test[i].name;
551
- clay_run_test(&test[i], &suite->initialize, &suite->cleanup);
552
- }
553
- }
554
-
555
- #if 0 /* temporarily disabled */
556
- static void
557
- clay_run_single(const struct clay_func *test,
558
- const struct clay_suite *suite)
559
- {
560
- _clay.suite_errors = 0;
561
- _clay.active_suite = suite->name;
562
- _clay.active_test = test->name;
563
-
564
- clay_run_test(test, &suite->initialize, &suite->cleanup);
565
- }
566
- #endif
567
-
568
- static void
569
- clay_usage(const char *arg)
570
- {
571
- printf("Usage: %s [options]\n\n", arg);
572
- printf("Options:\n");
573
- // printf(" -tXX\t\tRun only the test number XX\n");
574
- printf(" -sXX\t\tRun only the suite number XX\n");
575
- exit(-1);
576
- }
577
-
578
- static void
579
- clay_parse_args(int argc, char **argv)
580
- {
581
- int i;
582
-
583
- for (i = 1; i < argc; ++i) {
584
- char *argument = argv[i];
585
- char action;
586
- int num;
587
-
588
- if (argument[0] != '-')
589
- clay_usage(argv[0]);
590
-
591
- action = argument[1];
592
- num = strtol(argument + 2, &argument, 10);
593
-
594
- if (*argument != '\0' || num < 0)
595
- clay_usage(argv[0]);
596
-
597
- switch (action) {
598
- case 's':
599
- if ((size_t)num >= _clay_suite_count) {
600
- clay_print_onabort("Suite number %d does not exist.\n", num);
601
- exit(-1);
602
- }
603
-
604
- clay_run_suite(&_clay_suites[num]);
605
- break;
606
-
607
- default:
608
- clay_usage(argv[0]);
609
- }
610
- }
611
- }
612
-
613
- static int
614
- clay_test(int argc, char **argv)
615
- {
616
- clay_print_init(
617
- (int)_clay_callback_count,
618
- (int)_clay_suite_count,
619
- ""
620
- );
621
-
622
- if (clay_sandbox() < 0) {
623
- fprintf(stderr,
624
- "Failed to sandbox the test runner.\n"
625
- "Testing will proceed without sandboxing.\n");
626
- }
627
-
628
- if (argc > 1) {
629
- clay_parse_args(argc, argv);
630
- } else {
631
- size_t i;
632
- for (i = 0; i < _clay_suite_count; ++i)
633
- clay_run_suite(&_clay_suites[i]);
634
- }
635
-
636
- clay_print_shutdown(
637
- (int)_clay_callback_count,
638
- (int)_clay_suite_count,
639
- _clay.total_errors
640
- );
641
-
642
- clay_unsandbox();
643
- return _clay.total_errors;
644
- }
645
-
646
- void
647
- clay__assert(
648
- int condition,
649
- const char *file,
650
- int line,
651
- const char *error_msg,
652
- const char *description,
653
- int should_abort)
654
- {
655
- struct clay_error *error;
656
-
657
- if (condition)
658
- return;
659
-
660
- error = calloc(1, sizeof(struct clay_error));
661
-
662
- if (_clay.errors == NULL)
663
- _clay.errors = error;
664
-
665
- if (_clay.last_error != NULL)
666
- _clay.last_error->next = error;
667
-
668
- _clay.last_error = error;
669
-
670
- error->test = _clay.active_test;
671
- error->test_number = _clay.test_count;
672
- error->suite = _clay.active_suite;
673
- error->file = file;
674
- error->line_number = line;
675
- error->error_msg = error_msg;
676
-
677
- if (description != NULL)
678
- error->description = strdup(description);
679
-
680
- _clay.suite_errors++;
681
- _clay.total_errors++;
682
-
683
- if (should_abort) {
684
- if (!_clay.trampoline_enabled) {
685
- clay_print_onabort(
686
- "Fatal error: a cleanup method raised an exception.");
687
- exit(-1);
688
- }
689
-
690
- longjmp(_clay.trampoline, -1);
691
- }
692
- }
693
-
694
- void cl_set_cleanup(void (*cleanup)(void *), void *opaque)
695
- {
696
- _clay.local_cleanup = cleanup;
697
- _clay.local_cleanup_payload = opaque;
698
- }
699
-
700
- static char _clay_path[4096];
701
-
702
- static int
703
- is_valid_tmp_path(const char *path)
704
- {
705
- STAT_T st;
706
-
707
- if (stat(path, &st) != 0)
708
- return 0;
709
-
710
- if (!S_ISDIR(st.st_mode))
711
- return 0;
712
-
713
- return (access(path, W_OK) == 0);
714
- }
715
-
716
- static int
717
- find_tmp_path(char *buffer, size_t length)
718
- {
719
- #ifndef _WIN32
720
- static const size_t var_count = 4;
721
- static const char *env_vars[] = {
722
- "TMPDIR", "TMP", "TEMP", "USERPROFILE"
723
- };
724
-
725
- size_t i;
726
-
727
- for (i = 0; i < var_count; ++i) {
728
- const char *env = getenv(env_vars[i]);
729
- if (!env)
730
- continue;
731
-
732
- if (is_valid_tmp_path(env)) {
733
- strncpy(buffer, env, length);
734
- return 0;
735
- }
736
- }
737
-
738
- /* If the environment doesn't say anything, try to use /tmp */
739
- if (is_valid_tmp_path("/tmp")) {
740
- strncpy(buffer, "/tmp", length);
741
- return 0;
742
- }
743
-
744
- #else
745
- if (GetTempPath((DWORD)length, buffer))
746
- return 0;
747
- #endif
748
-
749
- /* This system doesn't like us, try to use the current directory */
750
- if (is_valid_tmp_path(".")) {
751
- strncpy(buffer, ".", length);
752
- return 0;
753
- }
754
-
755
- return -1;
756
- }
757
-
758
- static void clay_unsandbox(void)
759
- {
760
- if (_clay_path[0] == '\0')
761
- return;
762
-
763
- #ifdef _WIN32
764
- chdir("..");
765
- #endif
766
-
767
- fs_rm(_clay_path);
768
- }
769
-
770
- static int build_sandbox_path(void)
771
- {
772
- const char path_tail[] = "clay_tmp_XXXXXX";
773
- size_t len;
774
-
775
- if (find_tmp_path(_clay_path, sizeof(_clay_path)) < 0)
776
- return -1;
777
-
778
- len = strlen(_clay_path);
779
-
780
- #ifdef _WIN32
781
- { /* normalize path to POSIX forward slashes */
782
- size_t i;
783
- for (i = 0; i < len; ++i) {
784
- if (_clay_path[i] == '\\')
785
- _clay_path[i] = '/';
786
- }
787
- }
788
- #endif
789
-
790
- if (_clay_path[len - 1] != '/') {
791
- _clay_path[len++] = '/';
792
- }
793
-
794
- strncpy(_clay_path + len, path_tail, sizeof(_clay_path) - len);
795
-
796
- #ifdef _WIN32
797
- if (mktemp_s(_clay_path, sizeof(_clay_path)) != 0)
798
- return -1;
799
-
800
- if (mkdir(_clay_path, 0700) != 0)
801
- return -1;
802
- #else
803
- if (mkdtemp(_clay_path) == NULL)
804
- return -1;
805
- #endif
806
-
807
- return 0;
808
- }
809
-
810
- static int clay_sandbox(void)
811
- {
812
- if (_clay_path[0] == '\0' && build_sandbox_path() < 0)
813
- return -1;
814
-
815
- if (chdir(_clay_path) != 0)
816
- return -1;
817
-
818
- return 0;
819
- }
820
-
821
-
822
- static const char *
823
- fixture_path(const char *base, const char *fixture_name)
824
- {
825
- static char _path[4096];
826
- size_t root_len;
827
-
828
- root_len = strlen(base);
829
- strncpy(_path, base, sizeof(_path));
830
-
831
- if (_path[root_len - 1] != '/')
832
- _path[root_len++] = '/';
833
-
834
- if (fixture_name[0] == '/')
835
- fixture_name++;
836
-
837
- strncpy(_path + root_len,
838
- fixture_name,
839
- sizeof(_path) - root_len);
840
-
841
- return _path;
842
- }
843
-
844
- #ifdef CLAY_FIXTURE_PATH
845
- const char *cl_fixture(const char *fixture_name)
846
- {
847
- return fixture_path(CLAY_FIXTURE_PATH, fixture_name);
848
- }
849
-
850
- void cl_fixture_sandbox(const char *fixture_name)
851
- {
852
- fs_copy(cl_fixture(fixture_name), _clay_path);
853
- }
854
-
855
- void cl_fixture_cleanup(const char *fixture_name)
856
- {
857
- fs_rm(fixture_path(_clay_path, fixture_name));
858
- }
859
- #endif
860
-
861
- #ifdef _WIN32
862
-
863
- #define FOF_FLAGS (FOF_SILENT | FOF_NOCONFIRMATION | FOF_NOERRORUI | FOF_NOCONFIRMMKDIR)
864
-
865
- static char *
866
- fileops_path(const char *_path)
867
- {
868
- char *path = NULL;
869
- size_t length, i;
870
-
871
- if (_path == NULL)
872
- return NULL;
873
-
874
- length = strlen(_path);
875
- path = malloc(length + 2);
876
-
877
- if (path == NULL)
878
- return NULL;
879
-
880
- memcpy(path, _path, length);
881
- path[length] = 0;
882
- path[length + 1] = 0;
883
-
884
- for (i = 0; i < length; ++i) {
885
- if (path[i] == '/')
886
- path[i] = '\\';
887
- }
888
-
889
- return path;
890
- }
891
-
892
- static void
893
- fileops(int mode, const char *_source, const char *_dest)
894
- {
895
- SHFILEOPSTRUCT fops;
896
-
897
- char *source = fileops_path(_source);
898
- char *dest = fileops_path(_dest);
899
-
900
- ZeroMemory(&fops, sizeof(SHFILEOPSTRUCT));
901
-
902
- fops.wFunc = mode;
903
- fops.pFrom = source;
904
- fops.pTo = dest;
905
- fops.fFlags = FOF_FLAGS;
906
-
907
- cl_assert_(
908
- SHFileOperation(&fops) == 0,
909
- "Windows SHFileOperation failed"
910
- );
911
-
912
- free(source);
913
- free(dest);
914
- }
915
-
916
- static void
917
- fs_rm(const char *_source)
918
- {
919
- fileops(FO_DELETE, _source, NULL);
920
- }
921
-
922
- static void
923
- fs_copy(const char *_source, const char *_dest)
924
- {
925
- fileops(FO_COPY, _source, _dest);
926
- }
927
-
928
- void
929
- cl_fs_cleanup(void)
930
- {
931
- fs_rm(fixture_path(_clay_path, "*"));
932
- }
933
-
934
- #else
935
- static int
936
- shell_out(char * const argv[])
937
- {
938
- int status;
939
- pid_t pid;
940
-
941
- pid = fork();
942
-
943
- if (pid < 0) {
944
- fprintf(stderr,
945
- "System error: `fork()` call failed.\n");
946
- exit(-1);
947
- }
948
-
949
- if (pid == 0) {
950
- execv(argv[0], argv);
951
- }
952
-
953
- waitpid(pid, &status, 0);
954
- return WEXITSTATUS(status);
955
- }
956
-
957
- static void
958
- fs_copy(const char *_source, const char *dest)
959
- {
960
- char *argv[5];
961
- char *source;
962
- size_t source_len;
963
-
964
- source = strdup(_source);
965
- source_len = strlen(source);
966
-
967
- if (source[source_len - 1] == '/')
968
- source[source_len - 1] = 0;
969
-
970
- argv[0] = "/bin/cp";
971
- argv[1] = "-R";
972
- argv[2] = source;
973
- argv[3] = (char *)dest;
974
- argv[4] = NULL;
975
-
976
- cl_must_pass_(
977
- shell_out(argv),
978
- "Failed to copy test fixtures to sandbox"
979
- );
980
-
981
- free(source);
982
- }
983
-
984
- static void
985
- fs_rm(const char *source)
986
- {
987
- char *argv[4];
988
-
989
- argv[0] = "/bin/rm";
990
- argv[1] = "-Rf";
991
- argv[2] = (char *)source;
992
- argv[3] = NULL;
993
-
994
- cl_must_pass_(
995
- shell_out(argv),
996
- "Failed to cleanup the sandbox"
997
- );
998
- }
999
-
1000
- void
1001
- cl_fs_cleanup(void)
1002
- {
1003
- clay_unsandbox();
1004
- clay_sandbox();
1005
- }
1006
- #endif
1007
-
1008
-
1009
- static void clay_print_init(int test_count, int suite_count, const char *suite_names)
1010
- {
1011
- (void)suite_names;
1012
- (void)suite_count;
1013
- printf("TAP version 13\n");
1014
- printf("1..%d\n", test_count);
1015
- }
1016
-
1017
- static void clay_print_shutdown(int test_count, int suite_count, int error_count)
1018
- {
1019
- (void)test_count;
1020
- (void)suite_count;
1021
- (void)error_count;
1022
-
1023
- printf("\n");
1024
- }
1025
-
1026
- static void clay_print_error(int num, const struct clay_error *error)
1027
- {
1028
- (void)num;
1029
-
1030
- printf(" ---\n");
1031
- printf(" message : %s\n", error->error_msg);
1032
- printf(" severity: fail\n");
1033
- printf(" suite : %s\n", error->suite);
1034
- printf(" test : %s\n", error->test);
1035
- printf(" file : %s\n", error->file);
1036
- printf(" line : %d\n", error->line_number);
1037
-
1038
- if (error->description != NULL)
1039
- printf(" description: %s\n", error->description);
1040
-
1041
- printf(" ...\n");
1042
- }
1043
-
1044
- static void clay_print_ontest(const char *test_name, int test_number, int failed)
1045
- {
1046
- printf("%s %d - %s\n",
1047
- failed ? "not ok" : "ok",
1048
- test_number,
1049
- test_name
1050
- );
1051
-
1052
- clay_report_errors();
1053
- }
1054
-
1055
- static void clay_print_onsuite(const char *suite_name)
1056
- {
1057
- printf("# *** %s ***\n", suite_name);
1058
- }
1059
-
1060
- static void clay_print_onabort(const char *msg, ...)
1061
- {
1062
- va_list argp;
1063
- va_start(argp, msg);
1064
- fprintf(stdout, "Bail out! ");
1065
- vfprintf(stdout, msg, argp);
1066
- va_end(argp);
1067
- }
1068
-
1069
-
1070
- int _MAIN_CC main(int argc, char *argv[])
1071
- {
1072
- return clay_test(argc, argv);
1073
- }