rugged 0.16.0 → 0.17.0b1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (392) hide show
  1. data/README.md +373 -243
  2. data/Rakefile +22 -0
  3. data/ext/rugged/extconf.rb +9 -6
  4. data/ext/rugged/rugged.c +123 -31
  5. data/ext/rugged/rugged.h +11 -10
  6. data/ext/rugged/rugged_blob.c +181 -18
  7. data/ext/rugged/rugged_commit.c +196 -18
  8. data/ext/rugged/rugged_config.c +94 -5
  9. data/ext/rugged/rugged_object.c +54 -1
  10. data/ext/rugged/rugged_reference.c +203 -15
  11. data/ext/rugged/{remote.c → rugged_remote.c} +35 -10
  12. data/ext/rugged/rugged_repo.c +323 -81
  13. data/ext/rugged/rugged_revwalk.c +57 -4
  14. data/ext/rugged/rugged_signature.c +3 -3
  15. data/ext/rugged/rugged_tag.c +72 -1
  16. data/ext/rugged/rugged_tree.c +70 -2
  17. data/ext/rugged/vendor/libgit2-dist/deps/regex/config.h +7 -0
  18. data/ext/rugged/vendor/libgit2-dist/deps/regex/regcomp.c +3856 -0
  19. data/ext/rugged/vendor/libgit2-dist/deps/regex/regex.c +85 -0
  20. data/ext/rugged/vendor/libgit2-dist/deps/regex/regex.h +582 -0
  21. data/ext/rugged/vendor/libgit2-dist/deps/regex/regex_internal.c +1744 -0
  22. data/ext/rugged/vendor/libgit2-dist/deps/regex/regex_internal.h +810 -0
  23. data/ext/rugged/vendor/libgit2-dist/deps/regex/regexec.c +4369 -0
  24. data/ext/rugged/vendor/libgit2-dist/examples/diff.c +238 -0
  25. data/ext/rugged/vendor/libgit2-dist/examples/general.c +4 -4
  26. data/ext/rugged/vendor/libgit2-dist/examples/network/fetch.c +101 -85
  27. data/ext/rugged/vendor/libgit2-dist/examples/network/git2.c +7 -3
  28. data/ext/rugged/vendor/libgit2-dist/examples/network/index-pack.c +80 -25
  29. data/ext/rugged/vendor/libgit2-dist/examples/network/ls-remote.c +6 -6
  30. data/ext/rugged/vendor/libgit2-dist/include/git2/attr.h +224 -0
  31. data/ext/rugged/vendor/libgit2-dist/include/git2/blob.h +59 -5
  32. data/ext/rugged/vendor/libgit2-dist/include/git2/branch.h +114 -7
  33. data/ext/rugged/vendor/libgit2-dist/include/git2/commit.h +14 -7
  34. data/ext/rugged/vendor/libgit2-dist/include/git2/common.h +4 -3
  35. data/ext/rugged/vendor/libgit2-dist/include/git2/config.h +105 -27
  36. data/ext/rugged/vendor/libgit2-dist/include/git2/diff.h +409 -0
  37. data/ext/rugged/vendor/libgit2-dist/include/git2/errors.h +47 -82
  38. data/ext/rugged/vendor/libgit2-dist/include/git2/index.h +25 -10
  39. data/ext/rugged/vendor/libgit2-dist/include/git2/indexer.h +46 -1
  40. data/ext/rugged/vendor/libgit2-dist/include/git2/merge.h +35 -0
  41. data/ext/rugged/vendor/libgit2-dist/include/git2/net.h +1 -1
  42. data/ext/rugged/vendor/libgit2-dist/include/git2/notes.h +139 -0
  43. data/ext/rugged/vendor/libgit2-dist/include/git2/object.h +5 -5
  44. data/ext/rugged/vendor/libgit2-dist/include/git2/odb.h +13 -13
  45. data/ext/rugged/vendor/libgit2-dist/include/git2/odb_backend.h +8 -8
  46. data/ext/rugged/vendor/libgit2-dist/include/git2/oid.h +14 -9
  47. data/ext/rugged/vendor/libgit2-dist/include/git2/reflog.h +5 -5
  48. data/ext/rugged/vendor/libgit2-dist/include/git2/refs.h +37 -17
  49. data/ext/rugged/vendor/libgit2-dist/include/git2/refspec.h +17 -9
  50. data/ext/rugged/vendor/libgit2-dist/include/git2/remote.h +83 -16
  51. data/ext/rugged/vendor/libgit2-dist/include/git2/repository.h +24 -10
  52. data/ext/rugged/vendor/libgit2-dist/include/git2/reset.h +44 -0
  53. data/ext/rugged/vendor/libgit2-dist/include/git2/revparse.h +36 -0
  54. data/ext/rugged/vendor/libgit2-dist/include/git2/revwalk.h +74 -6
  55. data/ext/rugged/vendor/libgit2-dist/include/git2/signature.h +3 -3
  56. data/ext/rugged/vendor/libgit2-dist/include/git2/status.h +120 -19
  57. data/ext/rugged/vendor/libgit2-dist/include/git2/submodule.h +103 -0
  58. data/ext/rugged/vendor/libgit2-dist/include/git2/tag.h +28 -10
  59. data/ext/rugged/vendor/libgit2-dist/include/git2/threads.h +1 -1
  60. data/ext/rugged/vendor/libgit2-dist/include/git2/tree.h +13 -13
  61. data/ext/rugged/vendor/libgit2-dist/include/git2/types.h +16 -2
  62. data/ext/rugged/vendor/libgit2-dist/include/git2/version.h +3 -3
  63. data/ext/rugged/vendor/libgit2-dist/include/git2/windows.h +1 -1
  64. data/ext/rugged/vendor/libgit2-dist/include/git2.h +7 -2
  65. data/ext/rugged/vendor/libgit2-dist/src/attr.c +677 -0
  66. data/ext/rugged/vendor/libgit2-dist/src/attr.h +56 -0
  67. data/ext/rugged/vendor/libgit2-dist/src/attr_file.c +609 -0
  68. data/ext/rugged/vendor/libgit2-dist/src/attr_file.h +145 -0
  69. data/ext/rugged/vendor/libgit2-dist/src/blob.c +213 -60
  70. data/ext/rugged/vendor/libgit2-dist/src/blob.h +2 -1
  71. data/ext/rugged/vendor/libgit2-dist/src/branch.c +208 -0
  72. data/ext/rugged/vendor/libgit2-dist/src/branch.h +17 -0
  73. data/ext/rugged/vendor/libgit2-dist/src/bswap.h +1 -1
  74. data/ext/rugged/vendor/libgit2-dist/src/buffer.c +395 -46
  75. data/ext/rugged/vendor/libgit2-dist/src/buffer.h +112 -9
  76. data/ext/rugged/vendor/libgit2-dist/src/cache.c +37 -49
  77. data/ext/rugged/vendor/libgit2-dist/src/cache.h +7 -17
  78. data/ext/rugged/vendor/libgit2-dist/src/cc-compat.h +18 -16
  79. data/ext/rugged/vendor/libgit2-dist/src/commit.c +56 -90
  80. data/ext/rugged/vendor/libgit2-dist/src/commit.h +1 -1
  81. data/ext/rugged/vendor/libgit2-dist/src/common.h +12 -5
  82. data/ext/rugged/vendor/libgit2-dist/src/{win32 → compat}/fnmatch.c +1 -1
  83. data/ext/rugged/vendor/libgit2-dist/src/{win32 → compat}/fnmatch.h +3 -3
  84. data/ext/rugged/vendor/libgit2-dist/src/config.c +247 -158
  85. data/ext/rugged/vendor/libgit2-dist/src/config.h +10 -1
  86. data/ext/rugged/vendor/libgit2-dist/src/config_cache.c +94 -0
  87. data/ext/rugged/vendor/libgit2-dist/src/config_file.c +606 -496
  88. data/ext/rugged/vendor/libgit2-dist/src/config_file.h +31 -0
  89. data/ext/rugged/vendor/libgit2-dist/src/crlf.c +228 -0
  90. data/ext/rugged/vendor/libgit2-dist/src/date.c +876 -0
  91. data/ext/rugged/vendor/libgit2-dist/src/delta-apply.c +15 -9
  92. data/ext/rugged/vendor/libgit2-dist/src/delta-apply.h +2 -2
  93. data/ext/rugged/vendor/libgit2-dist/src/diff.c +814 -0
  94. data/ext/rugged/vendor/libgit2-dist/src/diff.h +43 -0
  95. data/ext/rugged/vendor/libgit2-dist/src/diff_output.c +794 -0
  96. data/ext/rugged/vendor/libgit2-dist/src/errors.c +89 -74
  97. data/ext/rugged/vendor/libgit2-dist/src/fetch.c +94 -66
  98. data/ext/rugged/vendor/libgit2-dist/src/fetch.h +5 -4
  99. data/ext/rugged/vendor/libgit2-dist/src/filebuf.c +157 -100
  100. data/ext/rugged/vendor/libgit2-dist/src/filebuf.h +22 -8
  101. data/ext/rugged/vendor/libgit2-dist/src/fileops.c +330 -206
  102. data/ext/rugged/vendor/libgit2-dist/src/fileops.h +82 -51
  103. data/ext/rugged/vendor/libgit2-dist/src/filter.c +165 -0
  104. data/ext/rugged/vendor/libgit2-dist/src/filter.h +119 -0
  105. data/ext/rugged/vendor/libgit2-dist/src/global.c +4 -4
  106. data/ext/rugged/vendor/libgit2-dist/src/global.h +4 -1
  107. data/ext/rugged/vendor/libgit2-dist/src/hash.c +1 -1
  108. data/ext/rugged/vendor/libgit2-dist/src/hash.h +1 -1
  109. data/ext/rugged/vendor/libgit2-dist/src/ignore.c +203 -0
  110. data/ext/rugged/vendor/libgit2-dist/src/ignore.h +38 -0
  111. data/ext/rugged/vendor/libgit2-dist/src/index.c +220 -169
  112. data/ext/rugged/vendor/libgit2-dist/src/index.h +5 -1
  113. data/ext/rugged/vendor/libgit2-dist/src/indexer.c +601 -102
  114. data/ext/rugged/vendor/libgit2-dist/src/iterator.c +748 -0
  115. data/ext/rugged/vendor/libgit2-dist/src/iterator.h +151 -0
  116. data/ext/rugged/vendor/libgit2-dist/src/khash.h +608 -0
  117. data/ext/rugged/vendor/libgit2-dist/src/map.h +6 -1
  118. data/ext/rugged/vendor/libgit2-dist/src/message.c +61 -0
  119. data/ext/rugged/vendor/libgit2-dist/src/message.h +14 -0
  120. data/ext/rugged/vendor/libgit2-dist/src/mwindow.c +27 -29
  121. data/ext/rugged/vendor/libgit2-dist/src/mwindow.h +4 -4
  122. data/ext/rugged/vendor/libgit2-dist/src/netops.c +375 -56
  123. data/ext/rugged/vendor/libgit2-dist/src/netops.h +12 -9
  124. data/ext/rugged/vendor/libgit2-dist/src/notes.c +548 -0
  125. data/ext/rugged/vendor/libgit2-dist/src/notes.h +28 -0
  126. data/ext/rugged/vendor/libgit2-dist/src/object.c +59 -21
  127. data/ext/rugged/vendor/libgit2-dist/src/odb.c +212 -175
  128. data/ext/rugged/vendor/libgit2-dist/src/odb.h +39 -2
  129. data/ext/rugged/vendor/libgit2-dist/src/odb_loose.c +238 -241
  130. data/ext/rugged/vendor/libgit2-dist/src/odb_pack.c +94 -106
  131. data/ext/rugged/vendor/libgit2-dist/src/oid.c +59 -60
  132. data/ext/rugged/vendor/libgit2-dist/src/oidmap.h +42 -0
  133. data/ext/rugged/vendor/libgit2-dist/src/pack.c +198 -170
  134. data/ext/rugged/vendor/libgit2-dist/src/pack.h +16 -9
  135. data/ext/rugged/vendor/libgit2-dist/src/path.c +496 -106
  136. data/ext/rugged/vendor/libgit2-dist/src/path.h +214 -20
  137. data/ext/rugged/vendor/libgit2-dist/src/pkt.c +88 -159
  138. data/ext/rugged/vendor/libgit2-dist/src/pkt.h +9 -5
  139. data/ext/rugged/vendor/libgit2-dist/src/pool.c +294 -0
  140. data/ext/rugged/vendor/libgit2-dist/src/pool.h +125 -0
  141. data/ext/rugged/vendor/libgit2-dist/src/posix.c +38 -16
  142. data/ext/rugged/vendor/libgit2-dist/src/posix.h +20 -2
  143. data/ext/rugged/vendor/libgit2-dist/src/ppc/sha1.c +1 -1
  144. data/ext/rugged/vendor/libgit2-dist/src/ppc/sha1.h +1 -1
  145. data/ext/rugged/vendor/libgit2-dist/src/pqueue.c +7 -7
  146. data/ext/rugged/vendor/libgit2-dist/src/pqueue.h +1 -1
  147. data/ext/rugged/vendor/libgit2-dist/src/protocol.c +21 -13
  148. data/ext/rugged/vendor/libgit2-dist/src/protocol.h +1 -1
  149. data/ext/rugged/vendor/libgit2-dist/src/reflog.c +125 -103
  150. data/ext/rugged/vendor/libgit2-dist/src/reflog.h +1 -1
  151. data/ext/rugged/vendor/libgit2-dist/src/refs.c +713 -640
  152. data/ext/rugged/vendor/libgit2-dist/src/refs.h +27 -3
  153. data/ext/rugged/vendor/libgit2-dist/src/refspec.c +51 -17
  154. data/ext/rugged/vendor/libgit2-dist/src/refspec.h +13 -1
  155. data/ext/rugged/vendor/libgit2-dist/src/remote.c +307 -119
  156. data/ext/rugged/vendor/libgit2-dist/src/remote.h +3 -2
  157. data/ext/rugged/vendor/libgit2-dist/src/repository.c +593 -442
  158. data/ext/rugged/vendor/libgit2-dist/src/repository.h +80 -2
  159. data/ext/rugged/vendor/libgit2-dist/src/reset.c +103 -0
  160. data/ext/rugged/vendor/libgit2-dist/src/revparse.c +753 -0
  161. data/ext/rugged/vendor/libgit2-dist/src/revwalk.c +434 -158
  162. data/ext/rugged/vendor/libgit2-dist/src/sha1.c +3 -3
  163. data/ext/rugged/vendor/libgit2-dist/src/sha1.h +2 -2
  164. data/ext/rugged/vendor/libgit2-dist/src/sha1_lookup.c +3 -2
  165. data/ext/rugged/vendor/libgit2-dist/src/sha1_lookup.h +1 -1
  166. data/ext/rugged/vendor/libgit2-dist/src/signature.c +69 -80
  167. data/ext/rugged/vendor/libgit2-dist/src/signature.h +1 -1
  168. data/ext/rugged/vendor/libgit2-dist/src/status.c +184 -638
  169. data/ext/rugged/vendor/libgit2-dist/src/strmap.h +64 -0
  170. data/ext/rugged/vendor/libgit2-dist/src/submodule.c +387 -0
  171. data/ext/rugged/vendor/libgit2-dist/src/tag.c +162 -137
  172. data/ext/rugged/vendor/libgit2-dist/src/tag.h +2 -1
  173. data/ext/rugged/vendor/libgit2-dist/src/thread-utils.c +1 -1
  174. data/ext/rugged/vendor/libgit2-dist/src/thread-utils.h +8 -8
  175. data/ext/rugged/vendor/libgit2-dist/src/transport.c +31 -19
  176. data/ext/rugged/vendor/libgit2-dist/src/transport.h +31 -11
  177. data/ext/rugged/vendor/libgit2-dist/src/transports/git.c +168 -193
  178. data/ext/rugged/vendor/libgit2-dist/src/transports/http.c +192 -241
  179. data/ext/rugged/vendor/libgit2-dist/src/transports/local.c +92 -86
  180. data/ext/rugged/vendor/libgit2-dist/src/tree-cache.c +32 -49
  181. data/ext/rugged/vendor/libgit2-dist/src/tree-cache.h +1 -1
  182. data/ext/rugged/vendor/libgit2-dist/src/tree.c +172 -145
  183. data/ext/rugged/vendor/libgit2-dist/src/tree.h +16 -2
  184. data/ext/rugged/vendor/libgit2-dist/src/tsort.c +16 -14
  185. data/ext/rugged/vendor/libgit2-dist/src/unix/map.c +8 -24
  186. data/ext/rugged/vendor/libgit2-dist/src/unix/posix.h +9 -3
  187. data/ext/rugged/vendor/libgit2-dist/src/util.c +94 -38
  188. data/ext/rugged/vendor/libgit2-dist/src/util.h +119 -13
  189. data/ext/rugged/vendor/libgit2-dist/src/vector.c +84 -31
  190. data/ext/rugged/vendor/libgit2-dist/src/vector.h +37 -4
  191. data/ext/rugged/vendor/libgit2-dist/src/win32/dir.c +81 -41
  192. data/ext/rugged/vendor/libgit2-dist/src/{dir.h → win32/dir.h} +4 -9
  193. data/ext/rugged/vendor/libgit2-dist/src/win32/map.c +19 -35
  194. data/ext/rugged/vendor/libgit2-dist/src/win32/mingw-compat.h +1 -1
  195. data/ext/rugged/vendor/libgit2-dist/src/win32/msvc-compat.h +5 -1
  196. data/ext/rugged/vendor/libgit2-dist/src/win32/posix.h +10 -8
  197. data/ext/rugged/vendor/libgit2-dist/src/win32/posix_w32.c +262 -118
  198. data/ext/rugged/vendor/libgit2-dist/src/win32/pthread.c +12 -9
  199. data/ext/rugged/vendor/libgit2-dist/src/win32/pthread.h +1 -1
  200. data/ext/rugged/vendor/libgit2-dist/src/win32/utf-conv.c +30 -26
  201. data/ext/rugged/vendor/libgit2-dist/src/win32/utf-conv.h +2 -1
  202. data/ext/rugged/vendor/libgit2-dist/src/xdiff/xdiff.h +135 -0
  203. data/ext/rugged/vendor/libgit2-dist/src/xdiff/xdiffi.c +572 -0
  204. data/ext/rugged/vendor/libgit2-dist/src/xdiff/xdiffi.h +63 -0
  205. data/ext/rugged/vendor/libgit2-dist/src/xdiff/xemit.c +253 -0
  206. data/ext/rugged/vendor/libgit2-dist/src/xdiff/xemit.h +36 -0
  207. data/ext/rugged/vendor/libgit2-dist/src/xdiff/xhistogram.c +371 -0
  208. data/ext/rugged/vendor/libgit2-dist/src/xdiff/xinclude.h +46 -0
  209. data/ext/rugged/vendor/libgit2-dist/src/xdiff/xmacros.h +54 -0
  210. data/ext/rugged/vendor/libgit2-dist/src/xdiff/xmerge.c +619 -0
  211. data/ext/rugged/vendor/libgit2-dist/src/xdiff/xpatience.c +358 -0
  212. data/ext/rugged/vendor/libgit2-dist/src/xdiff/xprepare.c +483 -0
  213. data/ext/rugged/vendor/libgit2-dist/src/xdiff/xprepare.h +34 -0
  214. data/ext/rugged/vendor/libgit2-dist/src/xdiff/xtypes.h +67 -0
  215. data/ext/rugged/vendor/libgit2-dist/src/xdiff/xutils.c +419 -0
  216. data/ext/rugged/vendor/libgit2-dist/src/xdiff/xutils.h +49 -0
  217. data/ext/rugged/vendor/libgit2-dist/tests-clar/attr/attr_expect.h +43 -0
  218. data/ext/rugged/vendor/libgit2-dist/tests-clar/attr/file.c +226 -0
  219. data/ext/rugged/vendor/libgit2-dist/tests-clar/attr/flags.c +108 -0
  220. data/ext/rugged/vendor/libgit2-dist/tests-clar/attr/lookup.c +262 -0
  221. data/ext/rugged/vendor/libgit2-dist/tests-clar/attr/repo.c +273 -0
  222. data/ext/rugged/vendor/libgit2-dist/{tests-clay → tests-clar}/buf/basic.c +5 -5
  223. data/ext/rugged/vendor/libgit2-dist/tests-clar/clar_helpers.c +181 -0
  224. data/ext/rugged/vendor/libgit2-dist/tests-clar/clar_libgit2.h +55 -0
  225. data/ext/rugged/vendor/libgit2-dist/tests-clar/commit/commit.c +44 -0
  226. data/ext/rugged/vendor/libgit2-dist/tests-clar/commit/parse.c +350 -0
  227. data/ext/rugged/vendor/libgit2-dist/tests-clar/commit/signature.c +65 -0
  228. data/ext/rugged/vendor/libgit2-dist/tests-clar/commit/write.c +140 -0
  229. data/ext/rugged/vendor/libgit2-dist/{tests-clay → tests-clar}/config/add.c +3 -3
  230. data/ext/rugged/vendor/libgit2-dist/tests-clar/config/multivar.c +151 -0
  231. data/ext/rugged/vendor/libgit2-dist/{tests-clay → tests-clar}/config/new.c +5 -5
  232. data/ext/rugged/vendor/libgit2-dist/{tests-clay → tests-clar}/config/read.c +44 -32
  233. data/ext/rugged/vendor/libgit2-dist/tests-clar/config/stress.c +61 -0
  234. data/ext/rugged/vendor/libgit2-dist/{tests-clay → tests-clar}/config/write.c +20 -5
  235. data/ext/rugged/vendor/libgit2-dist/tests-clar/core/buffer.c +613 -0
  236. data/ext/rugged/vendor/libgit2-dist/{tests-clay → tests-clar}/core/dirent.c +39 -26
  237. data/ext/rugged/vendor/libgit2-dist/tests-clar/core/env.c +115 -0
  238. data/ext/rugged/vendor/libgit2-dist/tests-clar/core/errors.c +60 -0
  239. data/ext/rugged/vendor/libgit2-dist/{tests-clay → tests-clar}/core/filebuf.c +4 -18
  240. data/ext/rugged/vendor/libgit2-dist/tests-clar/core/hex.c +22 -0
  241. data/ext/rugged/vendor/libgit2-dist/{tests-clay → tests-clar}/core/oid.c +6 -6
  242. data/ext/rugged/vendor/libgit2-dist/tests-clar/core/path.c +420 -0
  243. data/ext/rugged/vendor/libgit2-dist/tests-clar/core/pool.c +85 -0
  244. data/ext/rugged/vendor/libgit2-dist/tests-clar/core/rmdir.c +68 -0
  245. data/ext/rugged/vendor/libgit2-dist/{tests-clay → tests-clar}/core/string.c +1 -1
  246. data/ext/rugged/vendor/libgit2-dist/tests-clar/core/strmap.c +102 -0
  247. data/ext/rugged/vendor/libgit2-dist/{tests-clay → tests-clar}/core/strtol.c +1 -1
  248. data/ext/rugged/vendor/libgit2-dist/tests-clar/core/vector.c +191 -0
  249. data/ext/rugged/vendor/libgit2-dist/tests-clar/date/date.c +15 -0
  250. data/ext/rugged/vendor/libgit2-dist/tests-clar/diff/blob.c +254 -0
  251. data/ext/rugged/vendor/libgit2-dist/tests-clar/diff/diff_helpers.c +104 -0
  252. data/ext/rugged/vendor/libgit2-dist/tests-clar/diff/diff_helpers.h +47 -0
  253. data/ext/rugged/vendor/libgit2-dist/tests-clar/diff/index.c +92 -0
  254. data/ext/rugged/vendor/libgit2-dist/tests-clar/diff/iterator.c +572 -0
  255. data/ext/rugged/vendor/libgit2-dist/tests-clar/diff/patch.c +99 -0
  256. data/ext/rugged/vendor/libgit2-dist/tests-clar/diff/tree.c +210 -0
  257. data/ext/rugged/vendor/libgit2-dist/tests-clar/diff/workdir.c +543 -0
  258. data/ext/rugged/vendor/libgit2-dist/tests-clar/index/read_tree.c +46 -0
  259. data/ext/rugged/vendor/libgit2-dist/{tests-clay → tests-clar}/index/rename.c +2 -12
  260. data/ext/rugged/vendor/libgit2-dist/tests-clar/index/tests.c +246 -0
  261. data/ext/rugged/vendor/libgit2-dist/tests-clar/network/createremotethenload.c +33 -0
  262. data/ext/rugged/vendor/libgit2-dist/tests-clar/network/remotelocal.c +137 -0
  263. data/ext/rugged/vendor/libgit2-dist/tests-clar/network/remotes.c +183 -0
  264. data/ext/rugged/vendor/libgit2-dist/tests-clar/notes/notes.c +133 -0
  265. data/ext/rugged/vendor/libgit2-dist/tests-clar/notes/notesref.c +57 -0
  266. data/ext/rugged/vendor/libgit2-dist/tests-clar/object/blob/filter.c +125 -0
  267. data/ext/rugged/vendor/libgit2-dist/tests-clar/object/blob/fromchunks.c +87 -0
  268. data/ext/rugged/vendor/libgit2-dist/tests-clar/object/blob/write.c +69 -0
  269. data/ext/rugged/vendor/libgit2-dist/tests-clar/object/commit/commitstagedfile.c +126 -0
  270. data/ext/rugged/vendor/libgit2-dist/tests-clar/object/lookup.c +63 -0
  271. data/ext/rugged/vendor/libgit2-dist/tests-clar/object/message.c +171 -0
  272. data/ext/rugged/vendor/libgit2-dist/{tests-clay → tests-clar}/object/raw/chars.c +3 -14
  273. data/ext/rugged/vendor/libgit2-dist/{tests-clay → tests-clar}/object/raw/compare.c +4 -4
  274. data/ext/rugged/vendor/libgit2-dist/{tests-clay → tests-clar}/object/raw/convert.c +10 -10
  275. data/ext/rugged/vendor/libgit2-dist/{tests-clay → tests-clar}/object/raw/data.h +0 -0
  276. data/ext/rugged/vendor/libgit2-dist/{tests-clay → tests-clar}/object/raw/fromstr.c +1 -1
  277. data/ext/rugged/vendor/libgit2-dist/{tests-clay → tests-clar}/object/raw/hash.c +21 -17
  278. data/ext/rugged/vendor/libgit2-dist/{tests-clay → tests-clar}/object/raw/short.c +1 -1
  279. data/ext/rugged/vendor/libgit2-dist/{tests-clay → tests-clar}/object/raw/size.c +1 -1
  280. data/ext/rugged/vendor/libgit2-dist/{tests-clay → tests-clar}/object/raw/type2string.c +14 -14
  281. data/ext/rugged/vendor/libgit2-dist/tests-clar/object/raw/write.c +455 -0
  282. data/ext/rugged/vendor/libgit2-dist/tests-clar/object/tag/peel.c +56 -0
  283. data/ext/rugged/vendor/libgit2-dist/tests-clar/object/tag/read.c +130 -0
  284. data/ext/rugged/vendor/libgit2-dist/tests-clar/object/tag/write.c +192 -0
  285. data/ext/rugged/vendor/libgit2-dist/{tests-clay → tests-clar}/object/tree/frompath.c +22 -16
  286. data/ext/rugged/vendor/libgit2-dist/tests-clar/object/tree/read.c +75 -0
  287. data/ext/rugged/vendor/libgit2-dist/tests-clar/object/tree/write.c +84 -0
  288. data/ext/rugged/vendor/libgit2-dist/{tests-clay → tests-clar}/odb/loose.c +1 -1
  289. data/ext/rugged/vendor/libgit2-dist/{tests-clay → tests-clar}/odb/loose_data.h +0 -0
  290. data/ext/rugged/vendor/libgit2-dist/tests-clar/odb/mixed.c +24 -0
  291. data/ext/rugged/vendor/libgit2-dist/{tests-clay → tests-clar}/odb/pack_data.h +0 -0
  292. data/ext/rugged/vendor/libgit2-dist/{tests-clay → tests-clar}/odb/packed.c +1 -1
  293. data/ext/rugged/vendor/libgit2-dist/{tests-clay → tests-clar}/odb/sorting.c +1 -1
  294. data/ext/rugged/vendor/libgit2-dist/tests-clar/refs/branches/create.c +113 -0
  295. data/ext/rugged/vendor/libgit2-dist/tests-clar/refs/branches/delete.c +91 -0
  296. data/ext/rugged/vendor/libgit2-dist/tests-clar/refs/branches/listall.c +78 -0
  297. data/ext/rugged/vendor/libgit2-dist/tests-clar/refs/branches/move.c +72 -0
  298. data/ext/rugged/vendor/libgit2-dist/tests-clar/refs/crashes.c +17 -0
  299. data/ext/rugged/vendor/libgit2-dist/tests-clar/refs/create.c +149 -0
  300. data/ext/rugged/vendor/libgit2-dist/tests-clar/refs/delete.c +85 -0
  301. data/ext/rugged/vendor/libgit2-dist/tests-clar/refs/list.c +53 -0
  302. data/ext/rugged/vendor/libgit2-dist/tests-clar/refs/listall.c +36 -0
  303. data/ext/rugged/vendor/libgit2-dist/tests-clar/refs/lookup.c +42 -0
  304. data/ext/rugged/vendor/libgit2-dist/tests-clar/refs/normalize.c +200 -0
  305. data/ext/rugged/vendor/libgit2-dist/tests-clar/refs/overwrite.c +136 -0
  306. data/ext/rugged/vendor/libgit2-dist/tests-clar/refs/pack.c +67 -0
  307. data/ext/rugged/vendor/libgit2-dist/tests-clar/refs/read.c +194 -0
  308. data/ext/rugged/vendor/libgit2-dist/tests-clar/refs/reflog.c +123 -0
  309. data/ext/rugged/vendor/libgit2-dist/tests-clar/refs/rename.c +339 -0
  310. data/ext/rugged/vendor/libgit2-dist/tests-clar/refs/revparse.c +174 -0
  311. data/ext/rugged/vendor/libgit2-dist/tests-clar/refs/unicode.c +42 -0
  312. data/ext/rugged/vendor/libgit2-dist/tests-clar/repo/discover.c +142 -0
  313. data/ext/rugged/vendor/libgit2-dist/{tests-clay → tests-clar}/repo/getters.c +19 -1
  314. data/ext/rugged/vendor/libgit2-dist/tests-clar/repo/init.c +235 -0
  315. data/ext/rugged/vendor/libgit2-dist/tests-clar/repo/open.c +282 -0
  316. data/ext/rugged/vendor/libgit2-dist/tests-clar/repo/setters.c +80 -0
  317. data/ext/rugged/vendor/libgit2-dist/tests-clar/reset/mixed.c +47 -0
  318. data/ext/rugged/vendor/libgit2-dist/tests-clar/reset/reset_helpers.c +10 -0
  319. data/ext/rugged/vendor/libgit2-dist/tests-clar/reset/reset_helpers.h +6 -0
  320. data/ext/rugged/vendor/libgit2-dist/tests-clar/reset/soft.c +102 -0
  321. data/ext/rugged/vendor/libgit2-dist/{tests/t05-revwalk.c → tests-clar/revwalk/basic.c} +85 -44
  322. data/ext/rugged/vendor/libgit2-dist/tests-clar/revwalk/mergebase.c +148 -0
  323. data/ext/rugged/vendor/libgit2-dist/tests-clar/status/ignore.c +133 -0
  324. data/ext/rugged/vendor/libgit2-dist/{tests-clay → tests-clar}/status/single.c +2 -11
  325. data/ext/rugged/vendor/libgit2-dist/tests-clar/status/status_data.h +202 -0
  326. data/ext/rugged/vendor/libgit2-dist/tests-clar/status/status_helpers.c +49 -0
  327. data/ext/rugged/vendor/libgit2-dist/tests-clar/status/status_helpers.h +33 -0
  328. data/ext/rugged/vendor/libgit2-dist/tests-clar/status/submodules.c +112 -0
  329. data/ext/rugged/vendor/libgit2-dist/tests-clar/status/worktree.c +649 -0
  330. data/ext/rugged/vendor/libgit2-dist/tests-clar/threads/basic.c +20 -0
  331. data/ext/rugged/vendor/libgit2-dist.tar.gz +0 -0
  332. data/lib/rugged/commit.rb +35 -0
  333. data/lib/rugged/object.rb +7 -0
  334. data/lib/rugged/reference.rb +9 -0
  335. data/lib/rugged/repository.rb +99 -3
  336. data/lib/rugged/tag.rb +22 -0
  337. data/lib/rugged/tree.rb +8 -0
  338. data/lib/rugged/version.rb +1 -1
  339. data/lib/rugged.rb +4 -1
  340. data/test/blob_test.rb +2 -2
  341. data/test/commit_test.rb +27 -13
  342. data/test/config_test.rb +44 -0
  343. data/test/coverage/HEAD.json +1 -1
  344. data/test/fixtures/testrepo.git/config +2 -0
  345. data/test/fixtures/testrepo.git/objects/7f/043268ea43ce18e3540acaabf9e090c91965b0 +0 -0
  346. data/test/lib_test.rb +7 -0
  347. data/test/object_test.rb +3 -3
  348. data/test/reference_test.rb +46 -8
  349. data/test/remote_test.rb +8 -2
  350. data/test/repo_pack_test.rb +3 -3
  351. data/test/repo_test.rb +79 -11
  352. data/test/tag_test.rb +9 -2
  353. data/test/test_helper.rb +21 -0
  354. data/test/tree_test.rb +18 -6
  355. metadata +205 -81
  356. data/ext/rugged/vendor/libgit2-dist/include/git2/zlib.h +0 -40
  357. data/ext/rugged/vendor/libgit2-dist/src/hashtable.c +0 -243
  358. data/ext/rugged/vendor/libgit2-dist/src/hashtable.h +0 -80
  359. data/ext/rugged/vendor/libgit2-dist/tests/t00-core.c +0 -628
  360. data/ext/rugged/vendor/libgit2-dist/tests/t01-data.h +0 -322
  361. data/ext/rugged/vendor/libgit2-dist/tests/t01-rawobj.c +0 -638
  362. data/ext/rugged/vendor/libgit2-dist/tests/t03-data.h +0 -344
  363. data/ext/rugged/vendor/libgit2-dist/tests/t03-objwrite.c +0 -255
  364. data/ext/rugged/vendor/libgit2-dist/tests/t04-commit.c +0 -788
  365. data/ext/rugged/vendor/libgit2-dist/tests/t06-index.c +0 -219
  366. data/ext/rugged/vendor/libgit2-dist/tests/t07-hashtable.c +0 -192
  367. data/ext/rugged/vendor/libgit2-dist/tests/t08-tag.c +0 -357
  368. data/ext/rugged/vendor/libgit2-dist/tests/t09-tree.c +0 -221
  369. data/ext/rugged/vendor/libgit2-dist/tests/t10-refs.c +0 -1294
  370. data/ext/rugged/vendor/libgit2-dist/tests/t12-repo.c +0 -174
  371. data/ext/rugged/vendor/libgit2-dist/tests/t13-threads.c +0 -41
  372. data/ext/rugged/vendor/libgit2-dist/tests/t17-bufs.c +0 -61
  373. data/ext/rugged/vendor/libgit2-dist/tests/t18-status.c +0 -448
  374. data/ext/rugged/vendor/libgit2-dist/tests/test_helpers.c +0 -310
  375. data/ext/rugged/vendor/libgit2-dist/tests/test_helpers.h +0 -83
  376. data/ext/rugged/vendor/libgit2-dist/tests/test_lib.c +0 -198
  377. data/ext/rugged/vendor/libgit2-dist/tests/test_lib.h +0 -54
  378. data/ext/rugged/vendor/libgit2-dist/tests/test_main.c +0 -89
  379. data/ext/rugged/vendor/libgit2-dist/tests-clay/clay.h +0 -187
  380. data/ext/rugged/vendor/libgit2-dist/tests-clay/clay_libgit2.h +0 -28
  381. data/ext/rugged/vendor/libgit2-dist/tests-clay/clay_main.c +0 -1073
  382. data/ext/rugged/vendor/libgit2-dist/tests-clay/config/stress.c +0 -39
  383. data/ext/rugged/vendor/libgit2-dist/tests-clay/core/path.c +0 -139
  384. data/ext/rugged/vendor/libgit2-dist/tests-clay/core/rmdir.c +0 -50
  385. data/ext/rugged/vendor/libgit2-dist/tests-clay/core/vector.c +0 -66
  386. data/ext/rugged/vendor/libgit2-dist/tests-clay/network/remotes.c +0 -50
  387. data/ext/rugged/vendor/libgit2-dist/tests-clay/repo/init.c +0 -104
  388. data/ext/rugged/vendor/libgit2-dist/tests-clay/repo/open.c +0 -54
  389. data/ext/rugged/vendor/libgit2-dist/tests-clay/status/status_data.h +0 -48
  390. data/ext/rugged/vendor/libgit2-dist/tests-clay/status/worktree.c +0 -124
  391. data/lib/rugged/objects.rb +0 -45
  392. data/test/fixtures/testrepo.git/refs/heads/new_name +0 -1
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Copyright (C) 2009-2011 the libgit2 contributors
2
+ * Copyright (C) 2009-2012 the libgit2 contributors
3
3
  *
4
4
  * This file is part of libgit2, distributed under the GNU GPL v2 with
5
5
  * a Linking Exception. For full terms see the included COPYING file.
@@ -13,684 +13,230 @@
13
13
  #include "tree.h"
14
14
  #include "git2/status.h"
15
15
  #include "repository.h"
16
-
17
- struct status_entry {
18
- git_index_time mtime;
19
-
20
- git_oid head_oid;
21
- git_oid index_oid;
22
- git_oid wt_oid;
23
-
24
- unsigned int status_flags:6;
25
-
26
- char path[GIT_FLEX_ARRAY]; /* more */
27
- };
28
-
29
- static struct status_entry *status_entry_new(git_vector *entries, const char *path)
30
- {
31
- struct status_entry *e = git__malloc(sizeof(*e) + strlen(path) + 1);
32
- if (e == NULL)
33
- return NULL;
34
-
35
- memset(e, 0x0, sizeof(*e));
36
-
37
- if (entries != NULL)
38
- git_vector_insert(entries, e);
39
-
40
- strcpy(e->path, path);
41
-
42
- return e;
43
- }
44
-
45
- GIT_INLINE(void) status_entry_update_from_tree_entry(struct status_entry *e, const git_tree_entry *tree_entry)
46
- {
47
- assert(e && tree_entry);
48
-
49
- git_oid_cpy(&e->head_oid, &tree_entry->oid);
50
- }
51
-
52
- GIT_INLINE(void) status_entry_update_from_index_entry(struct status_entry *e, const git_index_entry *index_entry)
53
- {
54
- assert(e && index_entry);
55
-
56
- git_oid_cpy(&e->index_oid, &index_entry->oid);
57
- e->mtime = index_entry->mtime;
58
- }
59
-
60
- static void status_entry_update_from_index(struct status_entry *e, git_index *index)
61
- {
62
- int idx;
63
- git_index_entry *index_entry;
64
-
65
- assert(e && index);
66
-
67
- idx = git_index_find(index, e->path);
68
- if (idx < 0)
69
- return;
70
-
71
- index_entry = git_index_get(index, idx);
72
-
73
- status_entry_update_from_index_entry(e, index_entry);
74
- }
75
-
76
- static int status_entry_update_from_workdir(struct status_entry *e, char* full_path)
77
- {
78
- struct stat filest;
79
-
80
- if (p_stat(full_path, &filest) < GIT_SUCCESS)
81
- return git__throw(GIT_EOSERR, "Failed to determine status of file '%s'. Can't read file", full_path);
82
-
83
- if (e->mtime.seconds == (git_time_t)filest.st_mtime)
84
- git_oid_cpy(&e->wt_oid, &e->index_oid);
85
- else
86
- git_odb_hashfile(&e->wt_oid, full_path, GIT_OBJ_BLOB);
87
-
88
- return GIT_SUCCESS;
89
- }
90
-
91
- static int status_entry_update_flags(struct status_entry *e)
92
- {
93
- git_oid zero;
94
- int head_zero, index_zero, wt_zero;
95
-
96
- memset(&zero, 0x0, sizeof(git_oid));
97
-
98
- head_zero = git_oid_cmp(&zero, &e->head_oid);
99
- index_zero = git_oid_cmp(&zero, &e->index_oid);
100
- wt_zero = git_oid_cmp(&zero, &e->wt_oid);
101
-
102
- if (head_zero == 0 && index_zero == 0 && wt_zero == 0)
103
- return GIT_ENOTFOUND;
104
-
105
- if (head_zero == 0 && index_zero != 0)
106
- e->status_flags |= GIT_STATUS_INDEX_NEW;
107
- else if (index_zero == 0 && head_zero != 0)
108
- e->status_flags |= GIT_STATUS_INDEX_DELETED;
109
- else if (git_oid_cmp(&e->head_oid, &e->index_oid) != 0)
110
- e->status_flags |= GIT_STATUS_INDEX_MODIFIED;
111
-
112
- if (index_zero == 0 && wt_zero != 0)
113
- e->status_flags |= GIT_STATUS_WT_NEW;
114
- else if (wt_zero == 0 && index_zero != 0)
115
- e->status_flags |= GIT_STATUS_WT_DELETED;
116
- else if (git_oid_cmp(&e->index_oid, &e->wt_oid) != 0)
117
- e->status_flags |= GIT_STATUS_WT_MODIFIED;
118
-
119
- return GIT_SUCCESS;
120
- }
121
-
122
- struct status_st {
123
- git_vector *vector;
124
- git_index *index;
125
- git_tree *tree;
126
-
127
- int workdir_path_len;
128
- char* head_tree_relative_path;
129
- int head_tree_relative_path_len;
130
- unsigned int tree_position;
131
- unsigned int index_position;
132
- int is_dir:1;
133
- };
134
-
135
- static int retrieve_head_tree(git_tree **tree_out, git_repository *repo)
136
- {
137
- git_reference *resolved_head_ref;
138
- git_commit *head_commit = NULL;
139
- git_tree *tree;
140
- int error = GIT_SUCCESS;
141
-
142
- *tree_out = NULL;
143
-
144
- error = git_repository_head(&resolved_head_ref, repo);
145
- /*
146
- * We assume that a situation where HEAD exists but can not be resolved is valid.
147
- * A new repository fits this description for instance.
148
- */
149
- if (error == GIT_ENOTFOUND)
150
- return GIT_SUCCESS;
151
- if (error < GIT_SUCCESS)
152
- return git__rethrow(error, "HEAD can't be resolved");
153
-
154
- if ((error = git_commit_lookup(&head_commit, repo, git_reference_oid(resolved_head_ref))) < GIT_SUCCESS)
155
- return git__rethrow(error, "The tip of HEAD can't be retrieved");
156
-
157
- if ((error = git_commit_tree(&tree, head_commit)) < GIT_SUCCESS) {
158
- error = git__rethrow(error, "The tree of HEAD can't be retrieved");
159
- goto exit;
160
- }
161
-
162
- *tree_out = tree;
163
-
164
- exit:
165
- git_commit_free(head_commit);
166
- return error;
167
- }
168
-
169
- enum path_type {
170
- GIT_STATUS_PATH_NULL,
171
- GIT_STATUS_PATH_IGNORE,
172
- GIT_STATUS_PATH_FILE,
173
- GIT_STATUS_PATH_FOLDER,
174
- };
175
-
176
- static int dirent_cb(void *state, char *full_path);
177
- static int alphasorted_futils_direach(
178
- char *path, size_t path_sz,
179
- int (*fn)(void *, char *), void *arg);
180
-
181
- static int process_folder(struct status_st *st, const git_tree_entry *tree_entry, char *full_path, enum path_type path_type)
182
- {
183
- git_object *subtree = NULL;
184
- git_tree *pushed_tree = NULL;
185
- int error, pushed_tree_position = 0;
186
- git_otype tree_entry_type = GIT_OBJ_BAD;
187
-
188
- if (tree_entry != NULL) {
189
- tree_entry_type = git_tree_entry_type(tree_entry);
190
-
191
- switch (tree_entry_type) {
192
- case GIT_OBJ_TREE:
193
- error = git_tree_entry_2object(&subtree, ((git_object *)(st->tree))->repo, tree_entry);
194
- pushed_tree = st->tree;
195
- pushed_tree_position = st->tree_position;
196
- st->tree = (git_tree *)subtree;
197
- st->tree_position = 0;
198
- st->head_tree_relative_path_len += 1 + tree_entry->filename_len; /* path + '/' + name */
199
- break;
200
-
201
- case GIT_OBJ_BLOB:
202
- /* No op */
203
- break;
204
-
205
- default:
206
- error = git__throw(GIT_EINVALIDTYPE, "Unexpected tree entry type"); /* TODO: How should we deal with submodules? */
16
+ #include "ignore.h"
17
+
18
+ #include "git2/diff.h"
19
+ #include "diff.h"
20
+
21
+ static unsigned int index_delta2status(git_delta_t index_status)
22
+ {
23
+ unsigned int st = GIT_STATUS_CURRENT;
24
+
25
+ switch (index_status) {
26
+ case GIT_DELTA_ADDED:
27
+ case GIT_DELTA_COPIED:
28
+ case GIT_DELTA_RENAMED:
29
+ st = GIT_STATUS_INDEX_NEW;
30
+ break;
31
+ case GIT_DELTA_DELETED:
32
+ st = GIT_STATUS_INDEX_DELETED;
33
+ break;
34
+ case GIT_DELTA_MODIFIED:
35
+ st = GIT_STATUS_INDEX_MODIFIED;
36
+ break;
37
+ default:
38
+ break;
39
+ }
40
+
41
+ return st;
42
+ }
43
+
44
+ static unsigned int workdir_delta2status(git_delta_t workdir_status)
45
+ {
46
+ unsigned int st = GIT_STATUS_CURRENT;
47
+
48
+ switch (workdir_status) {
49
+ case GIT_DELTA_ADDED:
50
+ case GIT_DELTA_COPIED:
51
+ case GIT_DELTA_RENAMED:
52
+ case GIT_DELTA_UNTRACKED:
53
+ st = GIT_STATUS_WT_NEW;
54
+ break;
55
+ case GIT_DELTA_DELETED:
56
+ st = GIT_STATUS_WT_DELETED;
57
+ break;
58
+ case GIT_DELTA_MODIFIED:
59
+ st = GIT_STATUS_WT_MODIFIED;
60
+ break;
61
+ case GIT_DELTA_IGNORED:
62
+ st = GIT_STATUS_IGNORED;
63
+ break;
64
+ default:
65
+ break;
66
+ }
67
+
68
+ return st;
69
+ }
70
+
71
+ int git_status_foreach_ext(
72
+ git_repository *repo,
73
+ const git_status_options *opts,
74
+ int (*cb)(const char *, unsigned int, void *),
75
+ void *cbdata)
76
+ {
77
+ int err = 0, cmp;
78
+ git_diff_options diffopt;
79
+ git_diff_list *idx2head = NULL, *wd2idx = NULL;
80
+ git_tree *head = NULL;
81
+ git_status_show_t show =
82
+ opts ? opts->show : GIT_STATUS_SHOW_INDEX_AND_WORKDIR;
83
+ git_diff_delta *i2h, *w2i;
84
+ unsigned int i, j, i_max, j_max;
85
+
86
+ assert(show <= GIT_STATUS_SHOW_INDEX_THEN_WORKDIR);
87
+
88
+ if ((err = git_repository_head_tree(&head, repo)) < 0)
89
+ return err;
90
+
91
+ memset(&diffopt, 0, sizeof(diffopt));
92
+ memcpy(&diffopt.pathspec, &opts->pathspec, sizeof(diffopt.pathspec));
93
+
94
+ if ((opts->flags & GIT_STATUS_OPT_INCLUDE_UNTRACKED) != 0)
95
+ diffopt.flags = diffopt.flags | GIT_DIFF_INCLUDE_UNTRACKED;
96
+ if ((opts->flags & GIT_STATUS_OPT_INCLUDE_IGNORED) != 0)
97
+ diffopt.flags = diffopt.flags | GIT_DIFF_INCLUDE_IGNORED;
98
+ if ((opts->flags & GIT_STATUS_OPT_INCLUDE_UNMODIFIED) != 0)
99
+ diffopt.flags = diffopt.flags | GIT_DIFF_INCLUDE_UNMODIFIED;
100
+ if ((opts->flags & GIT_STATUS_OPT_RECURSE_UNTRACKED_DIRS) != 0)
101
+ diffopt.flags = diffopt.flags | GIT_DIFF_RECURSE_UNTRACKED_DIRS;
102
+ /* TODO: support EXCLUDE_SUBMODULES flag */
103
+
104
+ if (show != GIT_STATUS_SHOW_WORKDIR_ONLY &&
105
+ (err = git_diff_index_to_tree(repo, &diffopt, head, &idx2head)) < 0)
106
+ goto cleanup;
107
+
108
+ if (show != GIT_STATUS_SHOW_INDEX_ONLY &&
109
+ (err = git_diff_workdir_to_index(repo, &diffopt, &wd2idx)) < 0)
110
+ goto cleanup;
111
+
112
+ if (show == GIT_STATUS_SHOW_INDEX_THEN_WORKDIR) {
113
+ for (i = 0; !err && i < idx2head->deltas.length; i++) {
114
+ i2h = GIT_VECTOR_GET(&idx2head->deltas, i);
115
+ err = cb(i2h->old_file.path, index_delta2status(i2h->status), cbdata);
207
116
  }
117
+ git_diff_list_free(idx2head);
118
+ idx2head = NULL;
208
119
  }
209
120
 
210
- if (full_path != NULL && path_type == GIT_STATUS_PATH_FOLDER)
211
- error = alphasorted_futils_direach(full_path, GIT_PATH_MAX, dirent_cb, st);
212
- else {
213
- error = dirent_cb(st, NULL);
214
- }
121
+ i_max = idx2head ? idx2head->deltas.length : 0;
122
+ j_max = wd2idx ? wd2idx->deltas.length : 0;
215
123
 
216
- if (tree_entry_type == GIT_OBJ_TREE) {
217
- git_object_free(subtree);
218
- st->head_tree_relative_path_len -= 1 + tree_entry->filename_len;
219
- st->tree = pushed_tree;
220
- st->tree_position = pushed_tree_position;
221
- st->tree_position++;
222
- }
124
+ for (i = 0, j = 0; !err && (i < i_max || j < j_max); ) {
125
+ i2h = idx2head ? GIT_VECTOR_GET(&idx2head->deltas,i) : NULL;
126
+ w2i = wd2idx ? GIT_VECTOR_GET(&wd2idx->deltas,j) : NULL;
223
127
 
224
- return error;
225
- }
226
-
227
- static int store_if_changed(struct status_st *st, struct status_entry *e)
228
- {
229
- int error;
230
- if ((error = status_entry_update_flags(e)) < GIT_SUCCESS)
231
- return git__throw(error, "Failed to process the file '%s'. It doesn't exist in the workdir, in the HEAD nor in the index", e->path);
232
-
233
- if (e->status_flags == GIT_STATUS_CURRENT) {
234
- git__free(e);
235
- return GIT_SUCCESS;
236
- }
237
-
238
- return git_vector_insert(st->vector, e);
239
- }
240
-
241
- static int determine_status(struct status_st *st,
242
- int in_head, int in_index, int in_workdir,
243
- const git_tree_entry *tree_entry,
244
- const git_index_entry *index_entry,
245
- char *full_path,
246
- const char *status_path,
247
- enum path_type path_type)
248
- {
249
- struct status_entry *e;
250
- int error = GIT_SUCCESS;
251
- git_otype tree_entry_type = GIT_OBJ_BAD;
128
+ cmp = !w2i ? -1 : !i2h ? 1 : strcmp(i2h->old_file.path, w2i->old_file.path);
252
129
 
253
- if (tree_entry != NULL)
254
- tree_entry_type = git_tree_entry_type(tree_entry);
255
-
256
- /* If we're dealing with a directory in the workdir, let's recursively tackle it first */
257
- if (path_type == GIT_STATUS_PATH_FOLDER)
258
- return process_folder(st, tree_entry, full_path, path_type);
259
-
260
- /* Are we dealing with a file somewhere? */
261
- if (in_workdir || in_index || (in_head && tree_entry_type == GIT_OBJ_BLOB)) {
262
- e = status_entry_new(NULL, status_path);
263
-
264
- if (in_head && tree_entry_type == GIT_OBJ_BLOB) {
265
- status_entry_update_from_tree_entry(e, tree_entry);
266
- st->tree_position++;
130
+ if (cmp < 0) {
131
+ err = cb(i2h->old_file.path, index_delta2status(i2h->status), cbdata);
132
+ i++;
133
+ } else if (cmp > 0) {
134
+ err = cb(w2i->old_file.path, workdir_delta2status(w2i->status), cbdata);
135
+ j++;
136
+ } else {
137
+ err = cb(i2h->old_file.path, index_delta2status(i2h->status) |
138
+ workdir_delta2status(w2i->status), cbdata);
139
+ i++; j++;
267
140
  }
268
-
269
- if (in_index) {
270
- status_entry_update_from_index_entry(e, index_entry);
271
- st->index_position++;
272
- }
273
-
274
- if (in_workdir)
275
- if ((error = status_entry_update_from_workdir(e, full_path)) < GIT_SUCCESS)
276
- return error; /* The callee has already set the error message */
277
-
278
- return store_if_changed(st, e);
279
141
  }
280
142
 
281
- /* Last option, we're dealing with a leftover folder tree entry */
282
- assert(in_head && !in_index && !in_workdir && (tree_entry_type == GIT_OBJ_TREE));
283
- return process_folder(st, tree_entry, full_path, path_type);
143
+ cleanup:
144
+ git_tree_free(head);
145
+ git_diff_list_free(idx2head);
146
+ git_diff_list_free(wd2idx);
147
+ return err;
284
148
  }
285
149
 
286
- static int path_type_from(char *full_path, int is_dir)
150
+ int git_status_foreach(
151
+ git_repository *repo,
152
+ int (*callback)(const char *, unsigned int, void *),
153
+ void *payload)
287
154
  {
288
- if (full_path == NULL)
289
- return GIT_STATUS_PATH_NULL;
290
-
291
- if (!is_dir)
292
- return GIT_STATUS_PATH_FILE;
155
+ git_status_options opts;
293
156
 
294
- if (!git__suffixcmp(full_path, "/" DOT_GIT "/"))
295
- return GIT_STATUS_PATH_IGNORE;
157
+ memset(&opts, 0, sizeof(opts));
158
+ opts.show = GIT_STATUS_SHOW_INDEX_AND_WORKDIR;
159
+ opts.flags = GIT_STATUS_OPT_INCLUDE_IGNORED |
160
+ GIT_STATUS_OPT_INCLUDE_UNTRACKED |
161
+ GIT_STATUS_OPT_RECURSE_UNTRACKED_DIRS;
296
162
 
297
- return GIT_STATUS_PATH_FOLDER;
163
+ return git_status_foreach_ext(repo, &opts, callback, payload);
298
164
  }
299
165
 
300
- static const char *status_path(const char *first, const char *second, const char *third)
301
- {
302
- /* At least one of them can not be NULL */
303
- assert(first != NULL || second != NULL || third != NULL);
304
-
305
- /* TODO: Fixme. Ensure that when non null, they're all equal */
306
- if (first != NULL)
307
- return first;
308
-
309
- if (second != NULL)
310
- return second;
311
-
312
- return third;
313
- }
166
+ struct status_file_info {
167
+ unsigned int count;
168
+ unsigned int status;
169
+ char *expected;
170
+ };
314
171
 
315
- static int compare(const char *left, const char *right)
172
+ static int get_one_status(const char *path, unsigned int status, void *data)
316
173
  {
317
- if (left == NULL && right == NULL)
318
- return 0;
174
+ struct status_file_info *sfi = data;
319
175
 
320
- if (left == NULL)
321
- return 1;
176
+ sfi->count++;
177
+ sfi->status = status;
322
178
 
323
- if (right == NULL)
179
+ if (sfi->count > 1 || strcmp(sfi->expected, path) != 0) {
180
+ giterr_set(GITERR_INVALID,
181
+ "Ambiguous path '%s' given to git_status_file", sfi->expected);
324
182
  return -1;
325
-
326
- return strcmp(left, right);
327
- }
328
-
329
- /* Greatly inspired from JGit IndexTreeWalker */
330
- /* https://github.com/spearce/jgit/blob/ed47e29c777accfa78c6f50685a5df2b8f5b8ff5/org.spearce.jgit/src/org/spearce/jgit/lib/IndexTreeWalker.java#L88 */
331
-
332
- static int dirent_cb(void *state, char *a)
333
- {
334
- const git_tree_entry *m;
335
- const git_index_entry *entry;
336
- enum path_type path_type;
337
- int cmpma, cmpmi, cmpai, error;
338
- const char *pm, *pa, *pi;
339
- const char *m_name, *i_name, *a_name;
340
-
341
- struct status_st *st = (struct status_st *)state;
342
-
343
- path_type = path_type_from(a, st->is_dir);
344
-
345
- if (path_type == GIT_STATUS_PATH_IGNORE)
346
- return GIT_SUCCESS; /* Let's skip the ".git" directory */
347
-
348
- a_name = (path_type != GIT_STATUS_PATH_NULL) ? a + st->workdir_path_len : NULL;
349
-
350
- while (1) {
351
- if (st->tree == NULL)
352
- m = NULL;
353
- else
354
- m = git_tree_entry_byindex(st->tree, st->tree_position);
355
-
356
- entry = git_index_get(st->index, st->index_position);
357
-
358
- if ((m == NULL) && (a == NULL) && (entry == NULL))
359
- return GIT_SUCCESS;
360
-
361
- if (m != NULL) {
362
- st->head_tree_relative_path[st->head_tree_relative_path_len] = '\0';
363
-
364
- /* When the tree entry is a folder, append a forward slash to its name */
365
- if (git_tree_entry_type(m) == GIT_OBJ_TREE)
366
- git_path_join_n(st->head_tree_relative_path, 3, st->head_tree_relative_path, m->filename, "");
367
- else
368
- git_path_join(st->head_tree_relative_path, st->head_tree_relative_path, m->filename);
369
-
370
- m_name = st->head_tree_relative_path;
371
- } else
372
- m_name = NULL;
373
-
374
- i_name = (entry != NULL) ? entry->path : NULL;
375
-
376
- cmpma = compare(m_name, a_name);
377
- cmpmi = compare(m_name, i_name);
378
- cmpai = compare(a_name, i_name);
379
-
380
- pm = ((cmpma <= 0) && (cmpmi <= 0)) ? m_name : NULL;
381
- pa = ((cmpma >= 0) && (cmpai <= 0)) ? a_name : NULL;
382
- pi = ((cmpmi >= 0) && (cmpai >= 0)) ? i_name : NULL;
383
-
384
- if((error = determine_status(st, pm != NULL, pi != NULL, pa != NULL, m, entry, a, status_path(pm, pi, pa), path_type)) < GIT_SUCCESS)
385
- return git__rethrow(error, "An error occured while determining the status of '%s'", a);
386
-
387
- if ((pa != NULL) || (path_type == GIT_STATUS_PATH_FOLDER))
388
- return GIT_SUCCESS;
389
- }
390
- }
391
-
392
- static int status_cmp(const void *a, const void *b)
393
- {
394
- const struct status_entry *entry_a = (const struct status_entry *)(a);
395
- const struct status_entry *entry_b = (const struct status_entry *)(b);
396
-
397
- return strcmp(entry_a->path, entry_b->path);
398
- }
399
-
400
- #define DEFAULT_SIZE 16
401
-
402
- int git_status_foreach(git_repository *repo, int (*callback)(const char *, unsigned int, void *), void *payload)
403
- {
404
- git_vector entries;
405
- git_index *index = NULL;
406
- char temp_path[GIT_PATH_MAX];
407
- char tree_path[GIT_PATH_MAX] = "";
408
- struct status_st dirent_st;
409
- int error = GIT_SUCCESS;
410
- unsigned int i;
411
- git_tree *tree;
412
- struct status_entry *e;
413
- const char *workdir;
414
-
415
- if ((workdir = git_repository_workdir(repo)) == NULL)
416
- return git__throw(GIT_ERROR,
417
- "Cannot retrieve status on a bare repository");
418
-
419
- if ((error = git_repository_index__weakptr(&index, repo)) < GIT_SUCCESS) {
420
- return git__rethrow(error,
421
- "Failed to determine statuses. Index can't be opened");
422
- }
423
-
424
- if ((error = retrieve_head_tree(&tree, repo)) < GIT_SUCCESS) {
425
- error = git__rethrow(error, "Failed to determine statuses");
426
- goto exit;
427
- }
428
-
429
- git_vector_init(&entries, DEFAULT_SIZE, status_cmp);
430
-
431
- dirent_st.workdir_path_len = strlen(workdir);
432
- dirent_st.tree_position = 0;
433
- dirent_st.index_position = 0;
434
- dirent_st.tree = tree;
435
- dirent_st.index = index;
436
- dirent_st.vector = &entries;
437
- dirent_st.head_tree_relative_path = tree_path;
438
- dirent_st.head_tree_relative_path_len = 0;
439
- dirent_st.is_dir = 1;
440
-
441
- strcpy(temp_path, workdir);
442
-
443
- if (git_futils_isdir(temp_path)) {
444
- error = git__throw(GIT_EINVALIDPATH,
445
- "Failed to determine status of file '%s'. "
446
- "The given path doesn't lead to a folder", temp_path);
447
- goto exit;
448
- }
449
-
450
- error = alphasorted_futils_direach(
451
- temp_path, sizeof(temp_path),
452
- dirent_cb, &dirent_st
453
- );
454
-
455
- if (error < GIT_SUCCESS)
456
- error = git__rethrow(error,
457
- "Failed to determine statuses. "
458
- "An error occured while processing the working directory");
459
-
460
- if ((error == GIT_SUCCESS) && ((error = dirent_cb(&dirent_st, NULL)) < GIT_SUCCESS))
461
- error = git__rethrow(error,
462
- "Failed to determine statuses. "
463
- "An error occured while post-processing the HEAD tree and the index");
464
-
465
- for (i = 0; i < entries.length; ++i) {
466
- e = (struct status_entry *)git_vector_get(&entries, i);
467
-
468
- if (error == GIT_SUCCESS) {
469
- error = callback(e->path, e->status_flags, payload);
470
- if (error < GIT_SUCCESS)
471
- error = git__rethrow(error,
472
- "Failed to determine statuses. User callback failed");
473
- }
474
-
475
- git__free(e);
476
183
  }
477
184
 
478
- exit:
479
- git_vector_free(&entries);
480
- git_tree_free(tree);
481
- return error;
185
+ return 0;
482
186
  }
483
187
 
484
- static int recurse_tree_entry(git_tree *tree, struct status_entry *e, const char *path)
188
+ int git_status_file(
189
+ unsigned int *status_flags,
190
+ git_repository *repo,
191
+ const char *path)
485
192
  {
486
- char *dir_sep;
487
- const git_tree_entry *tree_entry;
488
- git_tree *subtree;
489
- int error = GIT_SUCCESS;
490
-
491
- dir_sep = strchr(path, '/');
492
- if (!dir_sep) {
493
- tree_entry = git_tree_entry_byname(tree, path);
494
- if (tree_entry == NULL)
495
- return GIT_SUCCESS; /* The leaf doesn't exist in the tree*/
496
-
497
- status_entry_update_from_tree_entry(e, tree_entry);
498
- return GIT_SUCCESS;
499
- }
500
-
501
- /* Retrieve subtree name */
502
- *dir_sep = '\0';
503
-
504
- tree_entry = git_tree_entry_byname(tree, path);
505
- if (tree_entry == NULL)
506
- return GIT_SUCCESS; /* The subtree doesn't exist in the tree*/
507
-
508
- *dir_sep = '/';
509
-
510
- /* Retreive subtree */
511
- if ((error = git_tree_lookup(&subtree, tree->object.repo, &tree_entry->oid)) < GIT_SUCCESS)
512
- return git__throw(GIT_EOBJCORRUPTED, "Can't find tree object '%s'", tree_entry->filename);
513
-
514
- error = recurse_tree_entry(subtree, e, dir_sep+1);
515
- git_tree_free(subtree);
516
- return error;
517
- }
518
-
519
- int git_status_file(unsigned int *status_flags, git_repository *repo, const char *path)
520
- {
521
- struct status_entry *e;
522
- git_index *index = NULL;
523
- char temp_path[GIT_PATH_MAX];
524
- int error = GIT_SUCCESS;
525
- git_tree *tree = NULL;
526
- const char *workdir;
193
+ int error;
194
+ git_status_options opts;
195
+ struct status_file_info sfi;
527
196
 
528
197
  assert(status_flags && repo && path);
529
198
 
530
- if ((workdir = git_repository_workdir(repo)) == NULL)
531
- return git__throw(GIT_ERROR,
532
- "Cannot retrieve status on a bare repository");
533
-
534
- git_path_join(temp_path, workdir, path);
535
- if (git_futils_isdir(temp_path) == GIT_SUCCESS)
536
- return git__throw(GIT_EINVALIDPATH,
537
- "Failed to determine status of file '%s'. "
538
- "Given path leads to a folder, not a file", path);
539
-
540
- e = status_entry_new(NULL, path);
541
- if (e == NULL)
542
- return GIT_ENOMEM;
543
-
544
- /* Find file in Workdir */
545
- if (git_futils_exists(temp_path) == GIT_SUCCESS) {
546
- if ((error = status_entry_update_from_workdir(e, temp_path)) < GIT_SUCCESS)
547
- goto exit; /* The callee has already set the error message */
548
- }
549
-
550
- /* Find file in Index */
551
- if ((error = git_repository_index__weakptr(&index, repo)) < GIT_SUCCESS) {
552
- error = git__rethrow(error,
553
- "Failed to determine status of file '%s'."
554
- "Index can't be opened", path);
555
- goto exit;
556
- }
557
-
558
- status_entry_update_from_index(e, index);
199
+ memset(&sfi, 0, sizeof(sfi));
200
+ if ((sfi.expected = git__strdup(path)) == NULL)
201
+ return -1;
559
202
 
560
- if ((error = retrieve_head_tree(&tree, repo)) < GIT_SUCCESS) {
561
- error = git__rethrow(error,
562
- "Failed to determine status of file '%s'", path);
563
- goto exit;
564
- }
203
+ memset(&opts, 0, sizeof(opts));
204
+ opts.show = GIT_STATUS_SHOW_INDEX_AND_WORKDIR;
205
+ opts.flags = GIT_STATUS_OPT_INCLUDE_IGNORED |
206
+ GIT_STATUS_OPT_INCLUDE_UNTRACKED |
207
+ GIT_STATUS_OPT_RECURSE_UNTRACKED_DIRS |
208
+ GIT_STATUS_OPT_INCLUDE_UNMODIFIED;
209
+ opts.pathspec.count = 1;
210
+ opts.pathspec.strings = &sfi.expected;
565
211
 
566
- /* If the repository is not empty, try and locate the file in HEAD */
567
- if (tree != NULL) {
568
- strcpy(temp_path, path);
212
+ error = git_status_foreach_ext(repo, &opts, get_one_status, &sfi);
569
213
 
570
- error = recurse_tree_entry(tree, e, temp_path);
571
- if (error < GIT_SUCCESS) {
572
- error = git__rethrow(error,
573
- "Failed to determine status of file '%s'. "
574
- "An error occured while processing the tree", path);
575
- goto exit;
576
- }
214
+ if (!error && !sfi.count) {
215
+ giterr_set(GITERR_INVALID,
216
+ "Attempt to get status of nonexistent file '%s'", path);
217
+ error = GIT_ENOTFOUND;
577
218
  }
578
219
 
579
- /* Determine status */
580
- if ((error = status_entry_update_flags(e)) < GIT_SUCCESS) {
581
- error = git__throw(error, "Nonexistent file");
582
- goto exit;
583
- }
220
+ *status_flags = sfi.status;
584
221
 
585
- *status_flags = e->status_flags;
222
+ git__free(sfi.expected);
586
223
 
587
- exit:
588
- git_tree_free(tree);
589
- git__free(e);
590
224
  return error;
591
225
  }
592
226
 
593
- /*
594
- * git_futils_direach is not supposed to return entries in an ordered manner.
595
- * alphasorted_futils_direach wraps git_futils_direach and invokes the callback
596
- * function by passing it alphabeticcally sorted paths parameters.
597
- *
598
- */
599
-
600
- struct alphasorted_dirent_info {
601
- int is_dir;
602
-
603
- char path[GIT_FLEX_ARRAY]; /* more */
604
- };
605
-
606
- static struct alphasorted_dirent_info *alphasorted_dirent_info_new(const char *path)
607
- {
608
- int is_dir, size;
609
- struct alphasorted_dirent_info *di;
610
-
611
- is_dir = git_futils_isdir(path) == GIT_SUCCESS ? 1 : 0;
612
- size = sizeof(*di) + (is_dir ? GIT_PATH_MAX : strlen(path)) + 2;
613
-
614
- di = git__malloc(size);
615
- if (di == NULL)
616
- return NULL;
617
-
618
- memset(di, 0x0, size);
619
-
620
- strcpy(di->path, path);
621
-
622
- if (is_dir) {
623
- di->is_dir = 1;
624
-
625
- /*
626
- * Append a forward slash to the name to force folders
627
- * to be ordered in a similar way than in a tree
628
- *
629
- * The file "subdir" should appear before the file "subdir.txt"
630
- * The folder "subdir" should appear after the file "subdir.txt"
631
- */
632
- di->path[strlen(path)] = '/';
633
- }
634
-
635
- return di;
636
- }
637
-
638
- static int alphasorted_dirent_info_cmp(const void *a, const void *b)
227
+ int git_status_should_ignore(
228
+ int *ignored,
229
+ git_repository *repo,
230
+ const char *path)
639
231
  {
640
- struct alphasorted_dirent_info *stra = (struct alphasorted_dirent_info *)a;
641
- struct alphasorted_dirent_info *strb = (struct alphasorted_dirent_info *)b;
642
-
643
- return strcmp(stra->path, strb->path);
644
- }
645
-
646
- static int alphasorted_dirent_cb(void *state, char *full_path)
647
- {
648
- struct alphasorted_dirent_info *entry;
649
- git_vector *entry_names;
650
-
651
- entry_names = (git_vector *)state;
652
- entry = alphasorted_dirent_info_new(full_path);
653
-
654
- if (entry == NULL)
655
- return GIT_ENOMEM;
656
-
657
- if (git_vector_insert(entry_names, entry) < GIT_SUCCESS) {
658
- git__free(entry);
659
- return GIT_ENOMEM;
660
- }
661
-
662
- return GIT_SUCCESS;
663
- }
664
-
665
- static int alphasorted_futils_direach(
666
- char *path,
667
- size_t path_sz,
668
- int (*fn)(void *, char *),
669
- void *arg)
670
- {
671
- struct alphasorted_dirent_info *entry;
672
- git_vector entry_names;
673
- unsigned int idx;
674
- int error = GIT_SUCCESS;
675
-
676
- if (git_vector_init(&entry_names, 16, alphasorted_dirent_info_cmp) < GIT_SUCCESS)
677
- return GIT_ENOMEM;
678
-
679
- error = git_futils_direach(path, path_sz, alphasorted_dirent_cb, &entry_names);
680
-
681
- git_vector_sort(&entry_names);
682
-
683
- for (idx = 0; idx < entry_names.length; ++idx) {
684
- entry = (struct alphasorted_dirent_info *)git_vector_get(&entry_names, idx);
685
-
686
- if (error == GIT_SUCCESS) {
687
- ((struct status_st *)arg)->is_dir = entry->is_dir;
688
- error = fn(arg, entry->path);
689
- }
232
+ int error;
233
+ git_ignores ignores;
690
234
 
691
- git__free(entry);
692
- }
235
+ if (git_ignore__for_path(repo, path, &ignores) < 0)
236
+ return -1;
693
237
 
694
- git_vector_free(&entry_names);
238
+ error = git_ignore__lookup(&ignores, path, ignored);
239
+ git_ignore__free(&ignores);
695
240
  return error;
696
241
  }
242
+