rugged 0.17.0.b7 → 0.18.0.b1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (310) hide show
  1. data/LICENSE +1 -1
  2. data/README.md +88 -32
  3. data/ext/rugged/extconf.rb +4 -2
  4. data/ext/rugged/rugged.c +72 -10
  5. data/ext/rugged/rugged.h +14 -10
  6. data/ext/rugged/rugged_blob.c +8 -10
  7. data/ext/rugged/rugged_branch.c +11 -14
  8. data/ext/rugged/rugged_commit.c +31 -24
  9. data/ext/rugged/rugged_config.c +2 -2
  10. data/ext/rugged/rugged_index.c +133 -198
  11. data/ext/rugged/rugged_note.c +372 -0
  12. data/ext/rugged/rugged_object.c +50 -22
  13. data/ext/rugged/rugged_reference.c +122 -130
  14. data/ext/rugged/rugged_remote.c +72 -29
  15. data/ext/rugged/rugged_repo.c +402 -20
  16. data/ext/rugged/rugged_revwalk.c +7 -3
  17. data/ext/rugged/rugged_settings.c +110 -0
  18. data/ext/rugged/rugged_signature.c +23 -7
  19. data/ext/rugged/rugged_tag.c +32 -16
  20. data/ext/rugged/rugged_tree.c +44 -15
  21. data/lib/rugged.rb +1 -0
  22. data/lib/rugged/index.rb +8 -0
  23. data/lib/rugged/remote.rb +13 -0
  24. data/lib/rugged/repository.rb +3 -3
  25. data/lib/rugged/version.rb +1 -1
  26. data/test/blob_test.rb +13 -15
  27. data/test/branch_test.rb +32 -67
  28. data/test/commit_test.rb +50 -12
  29. data/test/config_test.rb +12 -11
  30. data/test/coverage/HEAD.json +1 -1
  31. data/test/coverage/cover.rb +40 -21
  32. data/test/errors_test.rb +34 -0
  33. data/test/fixtures/alternate/objects/14/6ae76773c91e3b1d00cf7a338ec55ae58297e2 +0 -0
  34. data/test/fixtures/alternate/objects/14/9c32d47e99d0a3572ff1e70a2e0051bbf347a9 +0 -0
  35. data/test/fixtures/alternate/objects/14/fb3108588f9421bf764041e5e3ac305eb6277f +0 -0
  36. data/test/fixtures/testrepo.git/logs/refs/notes/commits +1 -0
  37. data/test/fixtures/testrepo.git/objects/44/1034f860c1d5d90e4188d11ae0d325176869a8 +1 -0
  38. data/test/fixtures/testrepo.git/objects/60/d415052a33de2150bf68757f6461df4f563ae4 +0 -0
  39. data/test/fixtures/testrepo.git/objects/68/8a8f4ef7496901d15322972f96e212a9e466cc +1 -0
  40. data/test/fixtures/testrepo.git/objects/94/eca2de348d5f672faf56b0decafa5937e3235e +0 -0
  41. data/test/fixtures/testrepo.git/objects/9b/7384fe1676186192842f5d3e129457b62db9e3 +0 -0
  42. data/test/fixtures/testrepo.git/objects/b7/4713326bc972cc15751ed504dca6f6f3b91f7a +3 -0
  43. data/test/fixtures/testrepo.git/refs/notes/commits +1 -0
  44. data/test/index_test.rb +65 -69
  45. data/test/lib_test.rb +76 -11
  46. data/test/note_test.rb +158 -0
  47. data/test/object_test.rb +8 -11
  48. data/test/reference_test.rb +77 -85
  49. data/test/remote_test.rb +86 -8
  50. data/test/repo_pack_test.rb +9 -7
  51. data/test/repo_reset_test.rb +80 -0
  52. data/test/repo_test.rb +176 -53
  53. data/test/tag_test.rb +44 -7
  54. data/test/test_helper.rb +63 -35
  55. data/test/tree_test.rb +34 -13
  56. data/test/walker_test.rb +14 -14
  57. data/vendor/libgit2/Makefile.embed +1 -1
  58. data/vendor/libgit2/deps/http-parser/http_parser.c +974 -578
  59. data/vendor/libgit2/deps/http-parser/http_parser.h +106 -70
  60. data/vendor/libgit2/deps/regex/regcomp.c +7 -6
  61. data/vendor/libgit2/deps/regex/regex_internal.c +1 -1
  62. data/vendor/libgit2/deps/regex/regex_internal.h +12 -3
  63. data/vendor/libgit2/deps/regex/regexec.c +5 -5
  64. data/vendor/libgit2/include/git2.h +5 -1
  65. data/vendor/libgit2/include/git2/attr.h +4 -2
  66. data/vendor/libgit2/include/git2/blob.h +39 -12
  67. data/vendor/libgit2/include/git2/branch.h +123 -35
  68. data/vendor/libgit2/include/git2/checkout.h +206 -48
  69. data/vendor/libgit2/include/git2/clone.h +72 -27
  70. data/vendor/libgit2/include/git2/commit.h +20 -17
  71. data/vendor/libgit2/include/git2/common.h +67 -1
  72. data/vendor/libgit2/include/git2/config.h +81 -60
  73. data/vendor/libgit2/include/git2/cred_helpers.h +53 -0
  74. data/vendor/libgit2/include/git2/diff.h +459 -150
  75. data/vendor/libgit2/include/git2/errors.h +9 -1
  76. data/vendor/libgit2/include/git2/graph.h +41 -0
  77. data/vendor/libgit2/include/git2/ignore.h +7 -6
  78. data/vendor/libgit2/include/git2/index.h +323 -97
  79. data/vendor/libgit2/include/git2/indexer.h +27 -59
  80. data/vendor/libgit2/include/git2/inttypes.h +4 -0
  81. data/vendor/libgit2/include/git2/merge.h +13 -3
  82. data/vendor/libgit2/include/git2/message.h +14 -8
  83. data/vendor/libgit2/include/git2/net.h +9 -7
  84. data/vendor/libgit2/include/git2/notes.h +88 -29
  85. data/vendor/libgit2/include/git2/object.h +16 -6
  86. data/vendor/libgit2/include/git2/odb.h +80 -17
  87. data/vendor/libgit2/include/git2/odb_backend.h +47 -11
  88. data/vendor/libgit2/include/git2/oid.h +26 -17
  89. data/vendor/libgit2/include/git2/pack.h +62 -8
  90. data/vendor/libgit2/include/git2/push.h +131 -0
  91. data/vendor/libgit2/include/git2/refdb.h +103 -0
  92. data/vendor/libgit2/include/git2/refdb_backend.h +109 -0
  93. data/vendor/libgit2/include/git2/reflog.h +30 -21
  94. data/vendor/libgit2/include/git2/refs.h +215 -193
  95. data/vendor/libgit2/include/git2/refspec.h +22 -2
  96. data/vendor/libgit2/include/git2/remote.h +158 -37
  97. data/vendor/libgit2/include/git2/repository.h +150 -31
  98. data/vendor/libgit2/include/git2/reset.h +43 -9
  99. data/vendor/libgit2/include/git2/revparse.h +48 -4
  100. data/vendor/libgit2/include/git2/revwalk.h +25 -10
  101. data/vendor/libgit2/include/git2/signature.h +20 -12
  102. data/vendor/libgit2/include/git2/stash.h +121 -0
  103. data/vendor/libgit2/include/git2/status.h +122 -53
  104. data/vendor/libgit2/include/git2/strarray.h +17 -11
  105. data/vendor/libgit2/include/git2/submodule.h +42 -7
  106. data/vendor/libgit2/include/git2/tag.h +72 -59
  107. data/vendor/libgit2/include/git2/threads.h +4 -2
  108. data/vendor/libgit2/include/git2/trace.h +68 -0
  109. data/vendor/libgit2/include/git2/transport.h +328 -0
  110. data/vendor/libgit2/include/git2/tree.h +149 -120
  111. data/vendor/libgit2/include/git2/types.h +13 -12
  112. data/vendor/libgit2/include/git2/version.h +3 -3
  113. data/vendor/libgit2/src/amiga/map.c +2 -2
  114. data/vendor/libgit2/src/attr.c +58 -48
  115. data/vendor/libgit2/src/attr.h +4 -18
  116. data/vendor/libgit2/src/attr_file.c +30 -6
  117. data/vendor/libgit2/src/attr_file.h +6 -8
  118. data/vendor/libgit2/src/attrcache.h +24 -0
  119. data/vendor/libgit2/src/blob.c +30 -7
  120. data/vendor/libgit2/src/blob.h +1 -1
  121. data/vendor/libgit2/src/branch.c +361 -68
  122. data/vendor/libgit2/src/branch.h +17 -0
  123. data/vendor/libgit2/src/bswap.h +1 -1
  124. data/vendor/libgit2/src/buf_text.c +291 -0
  125. data/vendor/libgit2/src/buf_text.h +122 -0
  126. data/vendor/libgit2/src/buffer.c +27 -101
  127. data/vendor/libgit2/src/buffer.h +54 -39
  128. data/vendor/libgit2/src/cache.c +15 -6
  129. data/vendor/libgit2/src/cache.h +1 -1
  130. data/vendor/libgit2/src/cc-compat.h +3 -1
  131. data/vendor/libgit2/src/checkout.c +1165 -222
  132. data/vendor/libgit2/src/checkout.h +24 -0
  133. data/vendor/libgit2/src/clone.c +171 -86
  134. data/vendor/libgit2/src/commit.c +44 -45
  135. data/vendor/libgit2/src/commit.h +3 -3
  136. data/vendor/libgit2/src/commit_list.c +194 -0
  137. data/vendor/libgit2/src/commit_list.h +49 -0
  138. data/vendor/libgit2/src/common.h +44 -10
  139. data/vendor/libgit2/src/compress.c +1 -1
  140. data/vendor/libgit2/src/compress.h +1 -1
  141. data/vendor/libgit2/src/config.c +211 -124
  142. data/vendor/libgit2/src/config.h +23 -4
  143. data/vendor/libgit2/src/config_cache.c +2 -2
  144. data/vendor/libgit2/src/config_file.c +129 -53
  145. data/vendor/libgit2/src/config_file.h +10 -8
  146. data/vendor/libgit2/src/crlf.c +66 -67
  147. data/vendor/libgit2/src/date.c +12 -12
  148. data/vendor/libgit2/src/delta-apply.c +14 -1
  149. data/vendor/libgit2/src/delta-apply.h +18 -1
  150. data/vendor/libgit2/src/delta.c +40 -107
  151. data/vendor/libgit2/src/delta.h +19 -17
  152. data/vendor/libgit2/src/diff.c +347 -496
  153. data/vendor/libgit2/src/diff.h +27 -1
  154. data/vendor/libgit2/src/diff_output.c +564 -249
  155. data/vendor/libgit2/src/diff_output.h +15 -8
  156. data/vendor/libgit2/src/diff_tform.c +687 -0
  157. data/vendor/libgit2/src/errors.c +27 -36
  158. data/vendor/libgit2/src/fetch.c +13 -351
  159. data/vendor/libgit2/src/fetch.h +13 -3
  160. data/vendor/libgit2/src/fetchhead.c +295 -0
  161. data/vendor/libgit2/src/fetchhead.h +34 -0
  162. data/vendor/libgit2/src/filebuf.c +42 -15
  163. data/vendor/libgit2/src/filebuf.h +4 -2
  164. data/vendor/libgit2/src/fileops.c +466 -113
  165. data/vendor/libgit2/src/fileops.h +154 -28
  166. data/vendor/libgit2/src/filter.c +3 -75
  167. data/vendor/libgit2/src/filter.h +1 -29
  168. data/vendor/libgit2/src/fnmatch.c +1 -1
  169. data/vendor/libgit2/src/fnmatch.h +1 -1
  170. data/vendor/libgit2/src/global.c +54 -10
  171. data/vendor/libgit2/src/global.h +10 -1
  172. data/vendor/libgit2/src/graph.c +178 -0
  173. data/vendor/libgit2/src/hash.c +25 -52
  174. data/vendor/libgit2/src/hash.h +21 -9
  175. data/vendor/libgit2/src/{sha1/sha1.c → hash/hash_generic.c} +20 -12
  176. data/vendor/libgit2/src/hash/hash_generic.h +24 -0
  177. data/vendor/libgit2/src/hash/hash_openssl.h +45 -0
  178. data/vendor/libgit2/src/hash/hash_win32.c +291 -0
  179. data/vendor/libgit2/src/hash/hash_win32.h +140 -0
  180. data/vendor/libgit2/src/hashsig.c +368 -0
  181. data/vendor/libgit2/src/hashsig.h +72 -0
  182. data/vendor/libgit2/src/ignore.c +22 -15
  183. data/vendor/libgit2/src/ignore.h +6 -1
  184. data/vendor/libgit2/src/index.c +770 -171
  185. data/vendor/libgit2/src/index.h +13 -5
  186. data/vendor/libgit2/src/indexer.c +286 -431
  187. data/vendor/libgit2/src/iterator.c +854 -466
  188. data/vendor/libgit2/src/iterator.h +134 -109
  189. data/vendor/libgit2/src/map.h +1 -1
  190. data/vendor/libgit2/src/merge.c +296 -0
  191. data/vendor/libgit2/src/merge.h +22 -0
  192. data/vendor/libgit2/src/message.c +1 -1
  193. data/vendor/libgit2/src/message.h +1 -1
  194. data/vendor/libgit2/src/mwindow.c +35 -30
  195. data/vendor/libgit2/src/mwindow.h +2 -2
  196. data/vendor/libgit2/src/netops.c +162 -98
  197. data/vendor/libgit2/src/netops.h +50 -15
  198. data/vendor/libgit2/src/notes.c +109 -58
  199. data/vendor/libgit2/src/notes.h +2 -1
  200. data/vendor/libgit2/src/object.c +46 -57
  201. data/vendor/libgit2/src/object.h +1 -8
  202. data/vendor/libgit2/src/odb.c +151 -40
  203. data/vendor/libgit2/src/odb.h +5 -1
  204. data/vendor/libgit2/src/odb_loose.c +4 -5
  205. data/vendor/libgit2/src/odb_pack.c +122 -80
  206. data/vendor/libgit2/src/offmap.h +65 -0
  207. data/vendor/libgit2/src/oid.c +12 -4
  208. data/vendor/libgit2/src/oidmap.h +1 -1
  209. data/vendor/libgit2/src/pack-objects.c +88 -61
  210. data/vendor/libgit2/src/pack-objects.h +8 -8
  211. data/vendor/libgit2/src/pack.c +293 -28
  212. data/vendor/libgit2/src/pack.h +49 -4
  213. data/vendor/libgit2/src/path.c +103 -14
  214. data/vendor/libgit2/src/path.h +23 -7
  215. data/vendor/libgit2/src/pathspec.c +168 -0
  216. data/vendor/libgit2/src/pathspec.h +40 -0
  217. data/vendor/libgit2/src/pool.c +29 -4
  218. data/vendor/libgit2/src/pool.h +8 -1
  219. data/vendor/libgit2/src/posix.c +26 -27
  220. data/vendor/libgit2/src/posix.h +2 -3
  221. data/vendor/libgit2/src/pqueue.c +23 -1
  222. data/vendor/libgit2/src/pqueue.h +23 -1
  223. data/vendor/libgit2/src/push.c +653 -0
  224. data/vendor/libgit2/src/push.h +51 -0
  225. data/vendor/libgit2/src/refdb.c +185 -0
  226. data/vendor/libgit2/src/refdb.h +46 -0
  227. data/vendor/libgit2/src/refdb_fs.c +1024 -0
  228. data/vendor/libgit2/src/refdb_fs.h +15 -0
  229. data/vendor/libgit2/src/reflog.c +77 -45
  230. data/vendor/libgit2/src/reflog.h +1 -3
  231. data/vendor/libgit2/src/refs.c +366 -1326
  232. data/vendor/libgit2/src/refs.h +22 -13
  233. data/vendor/libgit2/src/refspec.c +46 -7
  234. data/vendor/libgit2/src/refspec.h +11 -1
  235. data/vendor/libgit2/src/remote.c +758 -120
  236. data/vendor/libgit2/src/remote.h +10 -5
  237. data/vendor/libgit2/src/repo_template.h +6 -6
  238. data/vendor/libgit2/src/repository.c +315 -96
  239. data/vendor/libgit2/src/repository.h +5 -3
  240. data/vendor/libgit2/src/reset.c +99 -81
  241. data/vendor/libgit2/src/revparse.c +157 -84
  242. data/vendor/libgit2/src/revwalk.c +68 -470
  243. data/vendor/libgit2/src/revwalk.h +44 -0
  244. data/vendor/libgit2/src/sha1_lookup.c +1 -1
  245. data/vendor/libgit2/src/sha1_lookup.h +1 -1
  246. data/vendor/libgit2/src/signature.c +68 -200
  247. data/vendor/libgit2/src/signature.h +1 -1
  248. data/vendor/libgit2/src/stash.c +663 -0
  249. data/vendor/libgit2/src/status.c +101 -79
  250. data/vendor/libgit2/src/strmap.h +1 -1
  251. data/vendor/libgit2/src/submodule.c +67 -51
  252. data/vendor/libgit2/src/submodule.h +1 -1
  253. data/vendor/libgit2/src/tag.c +35 -29
  254. data/vendor/libgit2/src/tag.h +1 -1
  255. data/vendor/libgit2/src/thread-utils.c +1 -1
  256. data/vendor/libgit2/src/thread-utils.h +2 -2
  257. data/vendor/libgit2/src/trace.c +39 -0
  258. data/vendor/libgit2/src/trace.h +56 -0
  259. data/vendor/libgit2/src/transport.c +81 -34
  260. data/vendor/libgit2/src/transports/cred.c +60 -0
  261. data/vendor/libgit2/src/transports/cred_helpers.c +49 -0
  262. data/vendor/libgit2/src/transports/git.c +234 -127
  263. data/vendor/libgit2/src/transports/http.c +761 -433
  264. data/vendor/libgit2/src/transports/local.c +460 -64
  265. data/vendor/libgit2/src/transports/smart.c +345 -0
  266. data/vendor/libgit2/src/transports/smart.h +179 -0
  267. data/vendor/libgit2/src/{pkt.c → transports/smart_pkt.c} +131 -12
  268. data/vendor/libgit2/src/transports/smart_protocol.c +856 -0
  269. data/vendor/libgit2/src/transports/winhttp.c +1136 -0
  270. data/vendor/libgit2/src/tree-cache.c +2 -2
  271. data/vendor/libgit2/src/tree-cache.h +1 -1
  272. data/vendor/libgit2/src/tree.c +239 -166
  273. data/vendor/libgit2/src/tree.h +11 -2
  274. data/vendor/libgit2/src/tsort.c +39 -23
  275. data/vendor/libgit2/src/unix/map.c +1 -1
  276. data/vendor/libgit2/src/unix/posix.h +12 -2
  277. data/vendor/libgit2/src/unix/realpath.c +30 -0
  278. data/vendor/libgit2/src/util.c +250 -13
  279. data/vendor/libgit2/src/util.h +71 -14
  280. data/vendor/libgit2/src/vector.c +123 -60
  281. data/vendor/libgit2/src/vector.h +24 -22
  282. data/vendor/libgit2/src/win32/dir.c +1 -1
  283. data/vendor/libgit2/src/win32/dir.h +1 -1
  284. data/vendor/libgit2/src/win32/error.c +77 -0
  285. data/vendor/libgit2/src/win32/error.h +13 -0
  286. data/vendor/libgit2/src/win32/findfile.c +143 -54
  287. data/vendor/libgit2/src/win32/findfile.h +10 -6
  288. data/vendor/libgit2/src/win32/map.c +1 -1
  289. data/vendor/libgit2/src/win32/mingw-compat.h +1 -1
  290. data/vendor/libgit2/src/win32/msvc-compat.h +10 -1
  291. data/vendor/libgit2/src/win32/posix.h +10 -1
  292. data/vendor/libgit2/src/win32/posix_w32.c +132 -63
  293. data/vendor/libgit2/src/win32/precompiled.c +1 -1
  294. data/vendor/libgit2/src/win32/pthread.c +1 -1
  295. data/vendor/libgit2/src/win32/pthread.h +1 -1
  296. data/vendor/libgit2/src/win32/utf-conv.c +5 -5
  297. data/vendor/libgit2/src/win32/utf-conv.h +3 -3
  298. data/vendor/libgit2/src/win32/version.h +20 -0
  299. metadata +308 -252
  300. data/test/fixtures/testrepo.git/objects/4b/825dc642cb6eb9a060e54bf8d69288fbee4904 +0 -0
  301. data/test/fixtures/testrepo.git/objects/7f/043268ea43ce18e3540acaabf9e090c91965b0 +0 -0
  302. data/test/fixtures/testrepo.git/objects/a3/e05719b428a2d0ed7a55c4ce53dcc5768c6d5e +0 -0
  303. data/test/index_test.rb~ +0 -218
  304. data/vendor/libgit2/src/pkt.h +0 -91
  305. data/vendor/libgit2/src/ppc/sha1.c +0 -70
  306. data/vendor/libgit2/src/ppc/sha1.h +0 -26
  307. data/vendor/libgit2/src/protocol.c +0 -110
  308. data/vendor/libgit2/src/protocol.h +0 -21
  309. data/vendor/libgit2/src/sha1.h +0 -33
  310. data/vendor/libgit2/src/transport.h +0 -148
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Copyright (C) 2012 the libgit2 contributors
2
+ * Copyright (C) the libgit2 contributors. All rights reserved.
3
3
  *
4
4
  * This file is part of libgit2, distributed under the GNU GPL v2 with
5
5
  * a Linking Exception. For full terms see the included COPYING file.
@@ -9,36 +9,36 @@
9
9
 
10
10
  #include "git2/config.h"
11
11
 
12
- GIT_INLINE(int) git_config_file_open(git_config_file *cfg, unsigned int level)
12
+ GIT_INLINE(int) git_config_file_open(git_config_backend *cfg, unsigned int level)
13
13
  {
14
14
  return cfg->open(cfg, level);
15
15
  }
16
16
 
17
- GIT_INLINE(void) git_config_file_free(git_config_file *cfg)
17
+ GIT_INLINE(void) git_config_file_free(git_config_backend *cfg)
18
18
  {
19
19
  cfg->free(cfg);
20
20
  }
21
21
 
22
22
  GIT_INLINE(int) git_config_file_get_string(
23
- const git_config_entry **out, git_config_file *cfg, const char *name)
23
+ const git_config_entry **out, git_config_backend *cfg, const char *name)
24
24
  {
25
25
  return cfg->get(cfg, name, out);
26
26
  }
27
27
 
28
28
  GIT_INLINE(int) git_config_file_set_string(
29
- git_config_file *cfg, const char *name, const char *value)
29
+ git_config_backend *cfg, const char *name, const char *value)
30
30
  {
31
31
  return cfg->set(cfg, name, value);
32
32
  }
33
33
 
34
34
  GIT_INLINE(int) git_config_file_delete(
35
- git_config_file *cfg, const char *name)
35
+ git_config_backend *cfg, const char *name)
36
36
  {
37
37
  return cfg->del(cfg, name);
38
38
  }
39
39
 
40
40
  GIT_INLINE(int) git_config_file_foreach(
41
- git_config_file *cfg,
41
+ git_config_backend *cfg,
42
42
  int (*fn)(const git_config_entry *entry, void *data),
43
43
  void *data)
44
44
  {
@@ -46,7 +46,7 @@ GIT_INLINE(int) git_config_file_foreach(
46
46
  }
47
47
 
48
48
  GIT_INLINE(int) git_config_file_foreach_match(
49
- git_config_file *cfg,
49
+ git_config_backend *cfg,
50
50
  const char *regexp,
51
51
  int (*fn)(const git_config_entry *entry, void *data),
52
52
  void *data)
@@ -54,5 +54,7 @@ GIT_INLINE(int) git_config_file_foreach_match(
54
54
  return cfg->foreach(cfg, regexp, fn, data);
55
55
  }
56
56
 
57
+ extern int git_config_file_normalize_section(char *start, char *end);
58
+
57
59
  #endif
58
60
 
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Copyright (C) 2009-2012 the libgit2 contributors
2
+ * Copyright (C) the libgit2 contributors. All rights reserved.
3
3
  *
4
4
  * This file is part of libgit2, distributed under the GNU GPL v2 with
5
5
  * a Linking Exception. For full terms see the included COPYING file.
@@ -9,9 +9,10 @@
9
9
  #include "fileops.h"
10
10
  #include "hash.h"
11
11
  #include "filter.h"
12
+ #include "buf_text.h"
12
13
  #include "repository.h"
13
-
14
14
  #include "git2/attr.h"
15
+ #include "git2/blob.h"
15
16
 
16
17
  struct crlf_attrs {
17
18
  int crlf_action;
@@ -21,6 +22,8 @@ struct crlf_attrs {
21
22
  struct crlf_filter {
22
23
  git_filter f;
23
24
  struct crlf_attrs attrs;
25
+ git_repository *repo;
26
+ char path[GIT_FLEX_ARRAY];
24
27
  };
25
28
 
26
29
  static int check_crlf(const char *value)
@@ -103,36 +106,46 @@ static int crlf_load_attributes(struct crlf_attrs *ca, git_repository *repo, con
103
106
  return -1;
104
107
  }
105
108
 
106
- static int drop_crlf(git_buf *dest, const git_buf *source)
109
+ static int has_cr_in_index(git_filter *self)
107
110
  {
108
- const char *scan = source->ptr, *next;
109
- const char *scan_end = git_buf_cstr(source) + git_buf_len(source);
111
+ struct crlf_filter *filter = (struct crlf_filter *)self;
112
+ git_index *index;
113
+ const git_index_entry *entry;
114
+ git_blob *blob;
115
+ const void *blobcontent;
116
+ git_off_t blobsize;
117
+ bool found_cr;
118
+
119
+ if (git_repository_index__weakptr(&index, filter->repo) < 0) {
120
+ giterr_clear();
121
+ return false;
122
+ }
110
123
 
111
- /* Main scan loop. Find the next carriage return and copy the
112
- * whole chunk up to that point to the destination buffer.
113
- */
114
- while ((next = memchr(scan, '\r', scan_end - scan)) != NULL) {
115
- /* copy input up to \r */
116
- if (next > scan)
117
- git_buf_put(dest, scan, next - scan);
124
+ if (!(entry = git_index_get_bypath(index, filter->path, 0)) &&
125
+ !(entry = git_index_get_bypath(index, filter->path, 1)))
126
+ return false;
118
127
 
119
- /* Do not drop \r unless it is followed by \n */
120
- if (*(next + 1) != '\n')
121
- git_buf_putc(dest, '\r');
128
+ if (!S_ISREG(entry->mode)) /* don't crlf filter non-blobs */
129
+ return true;
122
130
 
123
- scan = next + 1;
124
- }
131
+ if (git_blob_lookup(&blob, filter->repo, &entry->oid) < 0)
132
+ return false;
125
133
 
126
- /* If there was no \r, then tell the library to skip this filter */
127
- if (scan == source->ptr)
128
- return -1;
134
+ blobcontent = git_blob_rawcontent(blob);
135
+ blobsize = git_blob_rawsize(blob);
136
+ if (!git__is_sizet(blobsize))
137
+ blobsize = (size_t)-1;
129
138
 
130
- /* Copy remaining input into dest */
131
- git_buf_put(dest, scan, scan_end - scan);
132
- return 0;
139
+ found_cr = (blobcontent != NULL &&
140
+ blobsize > 0 &&
141
+ memchr(blobcontent, '\r', (size_t)blobsize) != NULL);
142
+
143
+ git_blob_free(blob);
144
+ return found_cr;
133
145
  }
134
146
 
135
- static int crlf_apply_to_odb(git_filter *self, git_buf *dest, const git_buf *source)
147
+ static int crlf_apply_to_odb(
148
+ git_filter *self, git_buf *dest, const git_buf *source)
136
149
  {
137
150
  struct crlf_filter *filter = (struct crlf_filter *)self;
138
151
 
@@ -148,8 +161,11 @@ static int crlf_apply_to_odb(git_filter *self, git_buf *dest, const git_buf *sou
148
161
  if (filter->attrs.crlf_action == GIT_CRLF_AUTO ||
149
162
  filter->attrs.crlf_action == GIT_CRLF_GUESS) {
150
163
 
151
- git_text_stats stats;
152
- git_text_gather_stats(&stats, source);
164
+ git_buf_text_stats stats;
165
+
166
+ /* Check heuristics for binary vs text... */
167
+ if (git_buf_text_gather_stats(&stats, source, false))
168
+ return -1;
153
169
 
154
170
  /*
155
171
  * We're currently not going to even try to convert stuff
@@ -159,46 +175,21 @@ static int crlf_apply_to_odb(git_filter *self, git_buf *dest, const git_buf *sou
159
175
  if (stats.cr != stats.crlf)
160
176
  return -1;
161
177
 
162
- /*
163
- * And add some heuristics for binary vs text, of course...
164
- */
165
- if (git_text_is_binary(&stats))
166
- return -1;
167
-
168
- #if 0
169
- if (crlf_action == CRLF_GUESS) {
178
+ if (filter->attrs.crlf_action == GIT_CRLF_GUESS) {
170
179
  /*
171
180
  * If the file in the index has any CR in it, do not convert.
172
181
  * This is the new safer autocrlf handling.
173
182
  */
174
- if (has_cr_in_index(path))
175
- return 0;
183
+ if (has_cr_in_index(self))
184
+ return -1;
176
185
  }
177
- #endif
178
186
 
179
187
  if (!stats.cr)
180
188
  return -1;
181
189
  }
182
190
 
183
191
  /* Actually drop the carriage returns */
184
- return drop_crlf(dest, source);
185
- }
186
-
187
- static int convert_line_endings(git_buf *dest, const git_buf *source, const char *ending)
188
- {
189
- const char *scan = git_buf_cstr(source),
190
- *next,
191
- *scan_end = git_buf_cstr(source) + git_buf_len(source);
192
-
193
- while ((next = memchr(scan, '\n', scan_end - scan)) != NULL) {
194
- if (next > scan)
195
- git_buf_put(dest, scan, next-scan);
196
- git_buf_puts(dest, ending);
197
- scan = next + 1;
198
- }
199
-
200
- git_buf_put(dest, scan, scan_end - scan);
201
- return 0;
192
+ return git_buf_text_crlf_to_lf(dest, source);
202
193
  }
203
194
 
204
195
  static const char *line_ending(struct crlf_filter *filter)
@@ -241,26 +232,28 @@ line_ending_error:
241
232
  return NULL;
242
233
  }
243
234
 
244
- static int crlf_apply_to_workdir(git_filter *self, git_buf *dest, const git_buf *source)
235
+ static int crlf_apply_to_workdir(
236
+ git_filter *self, git_buf *dest, const git_buf *source)
245
237
  {
246
238
  struct crlf_filter *filter = (struct crlf_filter *)self;
247
239
  const char *workdir_ending = NULL;
248
240
 
249
- assert (self && dest && source);
241
+ assert(self && dest && source);
250
242
 
251
243
  /* Empty file? Nothing to do. */
252
244
  if (git_buf_len(source) == 0)
253
- return 0;
245
+ return -1;
254
246
 
255
247
  /* Determine proper line ending */
256
248
  workdir_ending = line_ending(filter);
257
- if (!workdir_ending) return -1;
258
-
259
- /* If the line ending is '\n', just copy the input */
260
- if (!strcmp(workdir_ending, "\n"))
261
- return git_buf_puts(dest, git_buf_cstr(source));
249
+ if (!workdir_ending)
250
+ return -1;
251
+ if (!strcmp("\n", workdir_ending)) /* do nothing for \n ending */
252
+ return -1;
262
253
 
263
- return convert_line_endings(dest, source, workdir_ending);
254
+ /* for now, only lf->crlf conversion is supported here */
255
+ assert(!strcmp("\r\n", workdir_ending));
256
+ return git_buf_text_lf_to_crlf(dest, source);
264
257
  }
265
258
 
266
259
  static int find_and_add_filter(
@@ -269,6 +262,7 @@ static int find_and_add_filter(
269
262
  {
270
263
  struct crlf_attrs ca;
271
264
  struct crlf_filter *filter;
265
+ size_t pathlen;
272
266
  int error;
273
267
 
274
268
  /* Load gitattributes for the path */
@@ -296,22 +290,27 @@ static int find_and_add_filter(
296
290
 
297
291
  /* If we're good, we create a new filter object and push it
298
292
  * into the filters array */
299
- filter = git__malloc(sizeof(struct crlf_filter));
293
+ pathlen = strlen(path);
294
+ filter = git__malloc(sizeof(struct crlf_filter) + pathlen + 1);
300
295
  GITERR_CHECK_ALLOC(filter);
301
296
 
302
297
  filter->f.apply = apply;
303
298
  filter->f.do_free = NULL;
304
299
  memcpy(&filter->attrs, &ca, sizeof(struct crlf_attrs));
300
+ filter->repo = repo;
301
+ memcpy(filter->path, path, pathlen + 1);
305
302
 
306
303
  return git_vector_insert(filters, filter);
307
304
  }
308
305
 
309
- int git_filter_add__crlf_to_odb(git_vector *filters, git_repository *repo, const char *path)
306
+ int git_filter_add__crlf_to_odb(
307
+ git_vector *filters, git_repository *repo, const char *path)
310
308
  {
311
309
  return find_and_add_filter(filters, repo, path, &crlf_apply_to_odb);
312
310
  }
313
311
 
314
- int git_filter_add__crlf_to_workdir(git_vector *filters, git_repository *repo, const char *path)
312
+ int git_filter_add__crlf_to_workdir(
313
+ git_vector *filters, git_repository *repo, const char *path)
315
314
  {
316
315
  return find_and_add_filter(filters, repo, path, &crlf_apply_to_workdir);
317
316
  }
@@ -106,15 +106,15 @@ static const struct {
106
106
  { "MESZ", +1, 1, }, /* Middle European Summer */
107
107
  { "FWT", +1, 0, }, /* French Winter */
108
108
  { "FST", +1, 1, }, /* French Summer */
109
- { "EET", +2, 0, }, /* Eastern Europe, USSR Zone 1 */
109
+ { "EET", +2, 0, }, /* Eastern Europe */
110
110
  { "EEST", +2, 1, }, /* Eastern European Daylight */
111
111
  { "WAST", +7, 0, }, /* West Australian Standard */
112
112
  { "WADT", +7, 1, }, /* West Australian Daylight */
113
- { "CCT", +8, 0, }, /* China Coast, USSR Zone 7 */
114
- { "JST", +9, 0, }, /* Japan Standard, USSR Zone 8 */
113
+ { "CCT", +8, 0, }, /* China Coast */
114
+ { "JST", +9, 0, }, /* Japan Standard */
115
115
  { "EAST", +10, 0, }, /* Eastern Australian Standard */
116
116
  { "EADT", +10, 1, }, /* Eastern Australian Daylight */
117
- { "GST", +10, 0, }, /* Guam Standard, USSR Zone 9 */
117
+ { "GST", +10, 0, }, /* Guam Standard */
118
118
  { "NZT", +12, 0, }, /* New Zealand */
119
119
  { "NZST", +12, 0, }, /* New Zealand Standard */
120
120
  { "NZDT", +12, 1, }, /* New Zealand Daylight */
@@ -195,7 +195,7 @@ static size_t match_alpha(const char *date, struct tm *tm, int *offset)
195
195
  return 2;
196
196
  }
197
197
 
198
- /* BAD CRAP */
198
+ /* BAD */
199
199
  return skip_alpha(date);
200
200
  }
201
201
 
@@ -425,16 +425,16 @@ static size_t match_tz(const char *date, int *offp)
425
425
  min = hour % 100;
426
426
  hour = hour / 100;
427
427
  } else if (n != 2) {
428
- min = 99; /* random crap */
428
+ min = 99; /* random stuff */
429
429
  } else if (*end == ':') {
430
430
  /* hh:mm? */
431
431
  min = strtoul(end + 1, &end, 10);
432
432
  if (end - (date + 1) != 5)
433
- min = 99; /* random crap */
433
+ min = 99; /* random stuff */
434
434
  } /* otherwise we parsed "hh" */
435
435
 
436
436
  /*
437
- * Don't accept any random crap. Even though some places have
437
+ * Don't accept any random stuff. Even though some places have
438
438
  * offset larger than 12 hours (e.g. Pacific/Kiritimati is at
439
439
  * UTC+14), there is something wrong if hour part is much
440
440
  * larger than that. We might also want to check that the
@@ -521,7 +521,7 @@ static int parse_date_basic(const char *date, git_time_t *timestamp, int *offset
521
521
  match = match_tz(date, offset);
522
522
 
523
523
  if (!match) {
524
- /* BAD CRAP */
524
+ /* BAD */
525
525
  match = 1;
526
526
  }
527
527
 
@@ -681,8 +681,8 @@ static const char *approxidate_alpha(const char *date, struct tm *tm, struct tm
681
681
  const char *end = date;
682
682
  int i;
683
683
 
684
- while (isalpha(*++end));
685
- ;
684
+ while (isalpha(*++end))
685
+ /* scan to non-alpha */;
686
686
 
687
687
  for (i = 0; i < 12; i++) {
688
688
  size_t match = match_string(date, month_names[i]);
@@ -817,7 +817,7 @@ static void pending_number(struct tm *tm, int *num)
817
817
  tm->tm_year = number;
818
818
  else if (number < 38)
819
819
  tm->tm_year = 100 + number;
820
- /* We screw up for number = 00 ? */
820
+ /* We mess up for number = 00 ? */
821
821
  }
822
822
  }
823
823
  }
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Copyright (C) 2009-2012 the libgit2 contributors
2
+ * Copyright (C) the libgit2 contributors. All rights reserved.
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.
@@ -36,6 +36,19 @@ static int hdr_sz(
36
36
  return 0;
37
37
  }
38
38
 
39
+ int git__delta_read_header(
40
+ const unsigned char *delta,
41
+ size_t delta_len,
42
+ size_t *base_sz,
43
+ size_t *res_sz)
44
+ {
45
+ const unsigned char *delta_end = delta + delta_len;
46
+ if ((hdr_sz(base_sz, &delta, delta_end) < 0) ||
47
+ (hdr_sz(res_sz, &delta, delta_end) < 0))
48
+ return -1;
49
+ return 0;
50
+ }
51
+
39
52
  int git__delta_apply(
40
53
  git_rawobj *out,
41
54
  const unsigned char *base,
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Copyright (C) 2009-2012 the libgit2 contributors
2
+ * Copyright (C) the libgit2 contributors. All rights reserved.
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.
@@ -30,4 +30,21 @@ extern int git__delta_apply(
30
30
  const unsigned char *delta,
31
31
  size_t delta_len);
32
32
 
33
+ /**
34
+ * Read the header of a git binary delta.
35
+ *
36
+ * @param delta the delta to execute copy/insert instructions from.
37
+ * @param delta_len total number of bytes in the delta.
38
+ * @param base_sz pointer to store the base size field.
39
+ * @param res_sz pointer to store the result size field.
40
+ * @return
41
+ * - 0 on a successful decoding the header.
42
+ * - GIT_ERROR if the delta is corrupt.
43
+ */
44
+ extern int git__delta_read_header(
45
+ const unsigned char *delta,
46
+ size_t delta_len,
47
+ size_t *base_sz,
48
+ size_t *res_sz);
49
+
33
50
  #endif
@@ -1,16 +1,8 @@
1
1
  /*
2
- * diff-delta.c: generate a delta between two buffers
2
+ * Copyright (C) the libgit2 contributors. All rights reserved.
3
3
  *
4
- * This code was greatly inspired by parts of LibXDiff from Davide Libenzi
5
- * http://www.xmailserver.org/xdiff-lib.html
6
- *
7
- * Rewritten for GIT by Nicolas Pitre <nico@fluxnic.net>, (C) 2005-2007
8
- *
9
- * Modified for libgit2 by Michael Schubert <schu@schu.io>, (C) 2012
10
- *
11
- * This code is free software; you can redistribute it and/or modify
12
- * it under the terms of the GNU General Public License version 2 as
13
- * published by the Free Software Foundation.
4
+ * This file is part of libgit2, distributed under the GNU GPL v2 with
5
+ * a Linking Exception. For full terms see the included COPYING file.
14
6
  */
15
7
 
16
8
  #include "delta.h"
@@ -116,11 +108,7 @@ static const unsigned int U[256] = {
116
108
  struct index_entry {
117
109
  const unsigned char *ptr;
118
110
  unsigned int val;
119
- };
120
-
121
- struct unpacked_index_entry {
122
- struct index_entry entry;
123
- struct unpacked_index_entry *next;
111
+ struct index_entry *next;
124
112
  };
125
113
 
126
114
  struct git_delta_index {
@@ -137,8 +125,7 @@ git_delta_create_index(const void *buf, unsigned long bufsize)
137
125
  unsigned int i, hsize, hmask, entries, prev_val, *hash_count;
138
126
  const unsigned char *data, *buffer = buf;
139
127
  struct git_delta_index *index;
140
- struct unpacked_index_entry *entry, **hash;
141
- struct index_entry *packed_entry, **packed_hash;
128
+ struct index_entry *entry, **hash;
142
129
  void *mem;
143
130
  unsigned long memsize;
144
131
 
@@ -146,9 +133,9 @@ git_delta_create_index(const void *buf, unsigned long bufsize)
146
133
  return NULL;
147
134
 
148
135
  /* Determine index hash size. Note that indexing skips the
149
- first byte to allow for optimizing the Rabin's polynomial
136
+ first byte to allow for optimizing the rabin polynomial
150
137
  initialization in create_delta(). */
151
- entries = (bufsize - 1) / RABIN_WINDOW;
138
+ entries = (unsigned int)(bufsize - 1) / RABIN_WINDOW;
152
139
  if (bufsize >= 0xffffffffUL) {
153
140
  /*
154
141
  * Current delta format can't encode offsets into
@@ -162,21 +149,28 @@ git_delta_create_index(const void *buf, unsigned long bufsize)
162
149
  hmask = hsize - 1;
163
150
 
164
151
  /* allocate lookup index */
165
- memsize = sizeof(*hash) * hsize +
152
+ memsize = sizeof(*index) +
153
+ sizeof(*hash) * hsize +
166
154
  sizeof(*entry) * entries;
167
155
  mem = git__malloc(memsize);
168
156
  if (!mem)
169
157
  return NULL;
158
+ index = mem;
159
+ mem = index->hash;
170
160
  hash = mem;
171
161
  mem = hash + hsize;
172
162
  entry = mem;
173
163
 
164
+ index->memsize = memsize;
165
+ index->src_buf = buf;
166
+ index->src_size = bufsize;
167
+ index->hash_mask = hmask;
174
168
  memset(hash, 0, hsize * sizeof(*hash));
175
169
 
176
170
  /* allocate an array to count hash entries */
177
171
  hash_count = calloc(hsize, sizeof(*hash_count));
178
172
  if (!hash_count) {
179
- git__free(hash);
173
+ git__free(index);
180
174
  return NULL;
181
175
  }
182
176
 
@@ -190,13 +184,12 @@ git_delta_create_index(const void *buf, unsigned long bufsize)
190
184
  val = ((val << 8) | data[i]) ^ T[val >> RABIN_SHIFT];
191
185
  if (val == prev_val) {
192
186
  /* keep the lowest of consecutive identical blocks */
193
- entry[-1].entry.ptr = data + RABIN_WINDOW;
194
- --entries;
187
+ entry[-1].ptr = data + RABIN_WINDOW;
195
188
  } else {
196
189
  prev_val = val;
197
190
  i = val & hmask;
198
- entry->entry.ptr = data + RABIN_WINDOW;
199
- entry->entry.val = val;
191
+ entry->ptr = data + RABIN_WINDOW;
192
+ entry->val = val;
200
193
  entry->next = hash[i];
201
194
  hash[i] = entry++;
202
195
  hash_count[i]++;
@@ -205,7 +198,7 @@ git_delta_create_index(const void *buf, unsigned long bufsize)
205
198
 
206
199
  /*
207
200
  * Determine a limit on the number of entries in the same hash
208
- * bucket. This guards us against pathological data sets causing
201
+ * bucket. This guard us against patological data sets causing
209
202
  * really bad hash distribution with most entries in the same hash
210
203
  * bucket that would bring us to O(m*n) computing costs (m and n
211
204
  * corresponding to reference and target buffer sizes).
@@ -216,84 +209,21 @@ git_delta_create_index(const void *buf, unsigned long bufsize)
216
209
  * the reference buffer.
217
210
  */
218
211
  for (i = 0; i < hsize; i++) {
219
- int acc;
220
-
221
- if (hash_count[i] <= HASH_LIMIT)
212
+ if (hash_count[i] < HASH_LIMIT)
222
213
  continue;
223
214
 
224
- /* We leave exactly HASH_LIMIT entries in the bucket */
225
- entries -= hash_count[i] - HASH_LIMIT;
226
-
227
215
  entry = hash[i];
228
- acc = 0;
229
-
230
- /*
231
- * Assume that this loop is gone through exactly
232
- * HASH_LIMIT times and is entered and left with
233
- * acc==0. So the first statement in the loop
234
- * contributes (hash_count[i]-HASH_LIMIT)*HASH_LIMIT
235
- * to the accumulator, and the inner loop consequently
236
- * is run (hash_count[i]-HASH_LIMIT) times, removing
237
- * one element from the list each time. Since acc
238
- * balances out to 0 at the final run, the inner loop
239
- * body can't be left with entry==NULL. So we indeed
240
- * encounter entry==NULL in the outer loop only.
241
- */
242
216
  do {
243
- acc += hash_count[i] - HASH_LIMIT;
244
- if (acc > 0) {
245
- struct unpacked_index_entry *keep = entry;
246
- do {
247
- entry = entry->next;
248
- acc -= HASH_LIMIT;
249
- } while (acc > 0);
250
- keep->next = entry->next;
251
- }
252
- entry = entry->next;
217
+ struct index_entry *keep = entry;
218
+ int skip = hash_count[i] / HASH_LIMIT / 2;
219
+ do {
220
+ entry = entry->next;
221
+ } while(--skip && entry);
222
+ keep->next = entry;
253
223
  } while (entry);
254
224
  }
255
225
  git__free(hash_count);
256
226
 
257
- /*
258
- * Now create the packed index in array form
259
- * rather than linked lists.
260
- */
261
- memsize = sizeof(*index)
262
- + sizeof(*packed_hash) * (hsize+1)
263
- + sizeof(*packed_entry) * entries;
264
- mem = git__malloc(memsize);
265
- if (!mem) {
266
- git__free(hash);
267
- return NULL;
268
- }
269
-
270
- index = mem;
271
- index->memsize = memsize;
272
- index->src_buf = buf;
273
- index->src_size = bufsize;
274
- index->hash_mask = hmask;
275
-
276
- mem = index->hash;
277
- packed_hash = mem;
278
- mem = packed_hash + (hsize+1);
279
- packed_entry = mem;
280
-
281
- for (i = 0; i < hsize; i++) {
282
- /*
283
- * Coalesce all entries belonging to one linked list
284
- * into consecutive array entries.
285
- */
286
- packed_hash[i] = packed_entry;
287
- for (entry = hash[i]; entry; entry = entry->next)
288
- *packed_entry++ = entry->entry;
289
- }
290
-
291
- /* Sentinel value to indicate the length of the last hash bucket */
292
- packed_hash[hsize] = packed_entry;
293
-
294
- assert(packed_entry - (struct index_entry *)mem == entries);
295
- git__free(hash);
296
-
297
227
  return index;
298
228
  }
299
229
 
@@ -312,14 +242,17 @@ unsigned long git_delta_sizeof_index(struct git_delta_index *index)
312
242
 
313
243
  /*
314
244
  * The maximum size for any opcode sequence, including the initial header
315
- * plus Rabin window plus biggest copy.
245
+ * plus rabin window plus biggest copy.
316
246
  */
317
247
  #define MAX_OP_SIZE (5 + 5 + 1 + RABIN_WINDOW + 7)
318
248
 
319
249
  void *
320
- git_delta_create(const struct git_delta_index *index,
321
- const void *trg_buf, unsigned long trg_size,
322
- unsigned long *delta_size, unsigned long max_size)
250
+ git_delta_create(
251
+ const struct git_delta_index *index,
252
+ const void *trg_buf,
253
+ unsigned long trg_size,
254
+ unsigned long *delta_size,
255
+ unsigned long max_size)
323
256
  {
324
257
  unsigned int i, outpos, outsize, moff, msize, val;
325
258
  int inscnt;
@@ -332,7 +265,7 @@ git_delta_create(const struct git_delta_index *index,
332
265
  outpos = 0;
333
266
  outsize = 8192;
334
267
  if (max_size && outsize >= max_size)
335
- outsize = max_size + MAX_OP_SIZE + 1;
268
+ outsize = (unsigned int)(max_size + MAX_OP_SIZE + 1);
336
269
  out = git__malloc(outsize);
337
270
  if (!out)
338
271
  return NULL;
@@ -374,22 +307,22 @@ git_delta_create(const struct git_delta_index *index,
374
307
  val ^= U[data[-RABIN_WINDOW]];
375
308
  val = ((val << 8) | *data) ^ T[val >> RABIN_SHIFT];
376
309
  i = val & index->hash_mask;
377
- for (entry = index->hash[i]; entry < index->hash[i+1]; entry++) {
310
+ for (entry = index->hash[i]; entry; entry = entry->next) {
378
311
  const unsigned char *ref = entry->ptr;
379
312
  const unsigned char *src = data;
380
- unsigned int ref_size = ref_top - ref;
313
+ unsigned int ref_size = (unsigned int)(ref_top - ref);
381
314
  if (entry->val != val)
382
315
  continue;
383
316
  if (ref_size > (unsigned int)(top - src))
384
- ref_size = top - src;
317
+ ref_size = (unsigned int)(top - src);
385
318
  if (ref_size <= msize)
386
319
  break;
387
320
  while (ref_size-- && *src++ == *ref)
388
321
  ref++;
389
322
  if (msize < (unsigned int)(ref - entry->ptr)) {
390
323
  /* this is our best match so far */
391
- msize = ref - entry->ptr;
392
- moff = entry->ptr - ref_data;
324
+ msize = (unsigned int)(ref - entry->ptr);
325
+ moff = (unsigned int)(entry->ptr - ref_data);
393
326
  if (msize >= 4096) /* good enough */
394
327
  break;
395
328
  }