rugged 0.26.7 → 0.27.0

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 (341) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +2 -2
  3. data/ext/rugged/rugged_blame.c +6 -3
  4. data/ext/rugged/rugged_branch_collection.c +3 -6
  5. data/ext/rugged/rugged_commit.c +56 -0
  6. data/ext/rugged/rugged_config.c +44 -9
  7. data/ext/rugged/rugged_diff.c +3 -14
  8. data/ext/rugged/rugged_diff_hunk.c +1 -3
  9. data/ext/rugged/rugged_index.c +1 -5
  10. data/ext/rugged/rugged_note.c +1 -4
  11. data/ext/rugged/rugged_patch.c +1 -4
  12. data/ext/rugged/rugged_reference_collection.c +1 -7
  13. data/ext/rugged/rugged_remote.c +5 -8
  14. data/ext/rugged/rugged_remote_collection.c +1 -6
  15. data/ext/rugged/rugged_repo.c +16 -48
  16. data/ext/rugged/rugged_revwalk.c +7 -16
  17. data/ext/rugged/rugged_settings.c +28 -0
  18. data/ext/rugged/rugged_submodule_collection.c +3 -4
  19. data/ext/rugged/rugged_tag_collection.c +1 -5
  20. data/ext/rugged/rugged_tree.c +2 -3
  21. data/lib/rugged/repository.rb +43 -0
  22. data/lib/rugged/version.rb +1 -1
  23. data/vendor/libgit2/AUTHORS +1 -0
  24. data/vendor/libgit2/CMakeLists.txt +61 -510
  25. data/vendor/libgit2/cmake/Modules/EnableWarnings.cmake +14 -0
  26. data/vendor/libgit2/cmake/Modules/FindCoreFoundation.cmake +25 -8
  27. data/vendor/libgit2/cmake/Modules/FindSecurity.cmake +27 -8
  28. data/vendor/libgit2/cmake/Modules/FindStatNsec.cmake +20 -0
  29. data/vendor/libgit2/cmake/Modules/IdeSplitSources.cmake +22 -0
  30. data/vendor/libgit2/deps/http-parser/CMakeLists.txt +3 -0
  31. data/vendor/libgit2/deps/regex/CMakeLists.txt +2 -0
  32. data/vendor/libgit2/deps/winhttp/CMakeLists.txt +26 -0
  33. data/vendor/libgit2/deps/zlib/CMakeLists.txt +4 -0
  34. data/vendor/libgit2/include/git2/config.h +29 -2
  35. data/vendor/libgit2/include/git2/describe.h +1 -1
  36. data/vendor/libgit2/include/git2/diff.h +59 -8
  37. data/vendor/libgit2/include/git2/graph.h +3 -0
  38. data/vendor/libgit2/include/git2/merge.h +6 -0
  39. data/vendor/libgit2/include/git2/message.h +43 -3
  40. data/vendor/libgit2/include/git2/notes.h +89 -0
  41. data/vendor/libgit2/include/git2/odb.h +8 -1
  42. data/vendor/libgit2/include/git2/patch.h +2 -2
  43. data/vendor/libgit2/include/git2/pathspec.h +35 -18
  44. data/vendor/libgit2/include/git2/refs.h +3 -0
  45. data/vendor/libgit2/include/git2/remote.h +34 -4
  46. data/vendor/libgit2/include/git2/repository.h +6 -6
  47. data/vendor/libgit2/include/git2/reset.h +4 -4
  48. data/vendor/libgit2/include/git2/status.h +4 -0
  49. data/vendor/libgit2/include/git2/sys/config.h +4 -1
  50. data/vendor/libgit2/include/git2/sys/odb_backend.h +2 -1
  51. data/vendor/libgit2/include/git2/tree.h +4 -3
  52. data/vendor/libgit2/include/git2/types.h +1 -0
  53. data/vendor/libgit2/include/git2/version.h +4 -4
  54. data/vendor/libgit2/include/git2/worktree.h +1 -1
  55. data/vendor/libgit2/src/CMakeLists.txt +463 -0
  56. data/vendor/libgit2/src/annotated_commit.c +1 -1
  57. data/vendor/libgit2/src/annotated_commit.h +2 -0
  58. data/vendor/libgit2/src/apply.c +2 -1
  59. data/vendor/libgit2/src/apply.h +2 -0
  60. data/vendor/libgit2/src/attr.c +24 -4
  61. data/vendor/libgit2/src/attr.h +2 -0
  62. data/vendor/libgit2/src/attr_file.c +9 -2
  63. data/vendor/libgit2/src/attr_file.h +2 -0
  64. data/vendor/libgit2/src/attrcache.c +9 -1
  65. data/vendor/libgit2/src/attrcache.h +2 -0
  66. data/vendor/libgit2/src/blame.c +1 -0
  67. data/vendor/libgit2/src/blame.h +2 -1
  68. data/vendor/libgit2/src/blame_git.c +1 -0
  69. data/vendor/libgit2/src/blame_git.h +2 -0
  70. data/vendor/libgit2/src/blob.c +2 -2
  71. data/vendor/libgit2/src/blob.h +2 -0
  72. data/vendor/libgit2/src/branch.c +8 -1
  73. data/vendor/libgit2/src/branch.h +2 -0
  74. data/vendor/libgit2/src/buf_text.c +7 -7
  75. data/vendor/libgit2/src/buf_text.h +3 -3
  76. data/vendor/libgit2/src/buffer.c +31 -1
  77. data/vendor/libgit2/src/buffer.h +3 -0
  78. data/vendor/libgit2/src/cache.c +2 -2
  79. data/vendor/libgit2/src/cache.h +2 -0
  80. data/vendor/libgit2/src/cc-compat.h +3 -3
  81. data/vendor/libgit2/src/checkout.c +30 -19
  82. data/vendor/libgit2/src/checkout.h +2 -0
  83. data/vendor/libgit2/src/cherrypick.c +1 -0
  84. data/vendor/libgit2/src/clone.c +2 -1
  85. data/vendor/libgit2/src/clone.h +4 -0
  86. data/vendor/libgit2/src/commit.c +2 -1
  87. data/vendor/libgit2/src/commit.h +2 -0
  88. data/vendor/libgit2/src/commit_list.c +1 -1
  89. data/vendor/libgit2/src/commit_list.h +2 -0
  90. data/vendor/libgit2/src/common.h +11 -5
  91. data/vendor/libgit2/src/config.c +12 -10
  92. data/vendor/libgit2/src/config.h +2 -0
  93. data/vendor/libgit2/src/config_cache.c +1 -0
  94. data/vendor/libgit2/src/config_file.c +287 -786
  95. data/vendor/libgit2/src/config_file.h +4 -3
  96. data/vendor/libgit2/src/config_parse.c +525 -0
  97. data/vendor/libgit2/src/config_parse.h +64 -0
  98. data/vendor/libgit2/src/crlf.c +2 -1
  99. data/vendor/libgit2/src/delta.c +28 -30
  100. data/vendor/libgit2/src/delta.h +1 -0
  101. data/vendor/libgit2/src/describe.c +3 -1
  102. data/vendor/libgit2/src/diff.c +148 -2
  103. data/vendor/libgit2/src/diff.h +3 -1
  104. data/vendor/libgit2/src/diff_driver.c +12 -9
  105. data/vendor/libgit2/src/diff_driver.h +4 -1
  106. data/vendor/libgit2/src/diff_file.c +7 -4
  107. data/vendor/libgit2/src/diff_file.h +1 -0
  108. data/vendor/libgit2/src/diff_generate.c +6 -3
  109. data/vendor/libgit2/src/diff_generate.h +6 -1
  110. data/vendor/libgit2/src/diff_parse.c +5 -4
  111. data/vendor/libgit2/src/diff_parse.h +2 -0
  112. data/vendor/libgit2/src/diff_print.c +2 -0
  113. data/vendor/libgit2/src/diff_stats.c +2 -0
  114. data/vendor/libgit2/src/diff_tform.c +2 -1
  115. data/vendor/libgit2/src/diff_tform.h +4 -1
  116. data/vendor/libgit2/src/diff_xdiff.c +5 -2
  117. data/vendor/libgit2/src/diff_xdiff.h +2 -0
  118. data/vendor/libgit2/src/errors.c +2 -0
  119. data/vendor/libgit2/src/features.h.in +36 -0
  120. data/vendor/libgit2/src/fetch.c +2 -2
  121. data/vendor/libgit2/src/fetch.h +4 -0
  122. data/vendor/libgit2/src/fetchhead.c +3 -3
  123. data/vendor/libgit2/src/fetchhead.h +3 -0
  124. data/vendor/libgit2/src/filebuf.c +2 -1
  125. data/vendor/libgit2/src/filebuf.h +2 -0
  126. data/vendor/libgit2/src/fileops.c +12 -1
  127. data/vendor/libgit2/src/fileops.h +7 -1
  128. data/vendor/libgit2/src/filter.c +2 -1
  129. data/vendor/libgit2/src/filter.h +1 -0
  130. data/vendor/libgit2/src/fnmatch.c +2 -2
  131. data/vendor/libgit2/src/fnmatch.h +3 -4
  132. data/vendor/libgit2/src/global.c +4 -3
  133. data/vendor/libgit2/src/global.h +1 -5
  134. data/vendor/libgit2/src/graph.c +2 -0
  135. data/vendor/libgit2/src/hash.c +0 -1
  136. data/vendor/libgit2/src/hash.h +3 -1
  137. data/vendor/libgit2/src/hash/hash_collisiondetect.h +3 -3
  138. data/vendor/libgit2/src/hash/hash_common_crypto.h +18 -5
  139. data/vendor/libgit2/src/hash/hash_generic.c +2 -2
  140. data/vendor/libgit2/src/hash/hash_generic.h +5 -3
  141. data/vendor/libgit2/src/hash/hash_openssl.h +3 -3
  142. data/vendor/libgit2/src/hash/hash_win32.c +57 -14
  143. data/vendor/libgit2/src/hash/hash_win32.h +4 -3
  144. data/vendor/libgit2/src/hashsig.c +3 -0
  145. data/vendor/libgit2/src/ident.c +2 -0
  146. data/vendor/libgit2/src/idxmap.h +2 -1
  147. data/vendor/libgit2/src/ignore.c +14 -2
  148. data/vendor/libgit2/src/ignore.h +2 -0
  149. data/vendor/libgit2/src/index.c +20 -40
  150. data/vendor/libgit2/src/index.h +2 -0
  151. data/vendor/libgit2/src/indexer.c +13 -5
  152. data/vendor/libgit2/src/indexer.h +5 -1
  153. data/vendor/libgit2/src/integer.h +1 -1
  154. data/vendor/libgit2/src/iterator.c +44 -3
  155. data/vendor/libgit2/src/iterator.h +3 -0
  156. data/vendor/libgit2/src/map.h +1 -1
  157. data/vendor/libgit2/src/merge.c +155 -33
  158. data/vendor/libgit2/src/merge.h +2 -0
  159. data/vendor/libgit2/src/merge_driver.c +2 -2
  160. data/vendor/libgit2/src/merge_driver.h +2 -0
  161. data/vendor/libgit2/src/merge_file.c +3 -0
  162. data/vendor/libgit2/src/message.h +3 -1
  163. data/vendor/libgit2/src/mwindow.c +1 -1
  164. data/vendor/libgit2/src/mwindow.h +2 -0
  165. data/vendor/libgit2/src/netops.c +75 -62
  166. data/vendor/libgit2/src/netops.h +2 -1
  167. data/vendor/libgit2/src/notes.c +164 -48
  168. data/vendor/libgit2/src/notes.h +1 -1
  169. data/vendor/libgit2/src/object.c +14 -3
  170. data/vendor/libgit2/src/object.h +4 -0
  171. data/vendor/libgit2/src/object_api.c +3 -2
  172. data/vendor/libgit2/src/odb.c +104 -38
  173. data/vendor/libgit2/src/odb.h +3 -1
  174. data/vendor/libgit2/src/odb_loose.c +414 -267
  175. data/vendor/libgit2/src/odb_mempack.c +1 -0
  176. data/vendor/libgit2/src/odb_pack.c +2 -1
  177. data/vendor/libgit2/src/offmap.h +1 -0
  178. data/vendor/libgit2/src/oid.c +2 -1
  179. data/vendor/libgit2/src/oid.h +3 -8
  180. data/vendor/libgit2/src/oidarray.c +2 -1
  181. data/vendor/libgit2/src/oidarray.h +1 -0
  182. data/vendor/libgit2/src/oidmap.h +1 -0
  183. data/vendor/libgit2/src/pack-objects.c +5 -1
  184. data/vendor/libgit2/src/pack-objects.h +1 -1
  185. data/vendor/libgit2/src/pack.c +2 -6
  186. data/vendor/libgit2/src/pack.h +2 -1
  187. data/vendor/libgit2/src/parse.c +121 -0
  188. data/vendor/libgit2/src/parse.h +61 -0
  189. data/vendor/libgit2/src/patch.c +9 -2
  190. data/vendor/libgit2/src/patch.h +2 -0
  191. data/vendor/libgit2/src/patch_generate.c +6 -5
  192. data/vendor/libgit2/src/patch_generate.h +1 -0
  193. data/vendor/libgit2/src/patch_parse.c +265 -276
  194. data/vendor/libgit2/src/patch_parse.h +6 -11
  195. data/vendor/libgit2/src/path.c +24 -181
  196. data/vendor/libgit2/src/path.h +14 -73
  197. data/vendor/libgit2/src/pathspec.c +2 -1
  198. data/vendor/libgit2/src/pathspec.h +2 -1
  199. data/vendor/libgit2/src/pool.c +8 -0
  200. data/vendor/libgit2/src/pool.h +1 -0
  201. data/vendor/libgit2/src/posix.c +2 -1
  202. data/vendor/libgit2/src/posix.h +1 -0
  203. data/vendor/libgit2/src/pqueue.c +1 -0
  204. data/vendor/libgit2/src/pqueue.h +2 -0
  205. data/vendor/libgit2/src/proxy.c +2 -1
  206. data/vendor/libgit2/src/proxy.h +3 -1
  207. data/vendor/libgit2/src/push.c +4 -171
  208. data/vendor/libgit2/src/push.h +2 -0
  209. data/vendor/libgit2/src/rebase.c +1 -0
  210. data/vendor/libgit2/src/refdb.c +2 -3
  211. data/vendor/libgit2/src/refdb.h +2 -0
  212. data/vendor/libgit2/src/refdb_fs.c +5 -3
  213. data/vendor/libgit2/src/refdb_fs.h +4 -0
  214. data/vendor/libgit2/src/reflog.c +1 -0
  215. data/vendor/libgit2/src/reflog.h +2 -1
  216. data/vendor/libgit2/src/refs.c +1 -0
  217. data/vendor/libgit2/src/refs.h +2 -1
  218. data/vendor/libgit2/src/refspec.c +2 -2
  219. data/vendor/libgit2/src/refspec.h +2 -0
  220. data/vendor/libgit2/src/remote.c +56 -10
  221. data/vendor/libgit2/src/remote.h +2 -0
  222. data/vendor/libgit2/src/repository.c +16 -14
  223. data/vendor/libgit2/src/repository.h +2 -0
  224. data/vendor/libgit2/src/reset.c +6 -5
  225. data/vendor/libgit2/src/revert.c +1 -0
  226. data/vendor/libgit2/src/revparse.c +3 -5
  227. data/vendor/libgit2/src/revwalk.c +2 -2
  228. data/vendor/libgit2/src/revwalk.h +2 -0
  229. data/vendor/libgit2/src/settings.c +6 -8
  230. data/vendor/libgit2/src/sha1_lookup.c +2 -216
  231. data/vendor/libgit2/src/sha1_lookup.h +2 -6
  232. data/vendor/libgit2/src/signature.c +8 -3
  233. data/vendor/libgit2/src/signature.h +2 -0
  234. data/vendor/libgit2/src/sortedcache.c +7 -0
  235. data/vendor/libgit2/src/sortedcache.h +2 -0
  236. data/vendor/libgit2/src/stash.c +1 -0
  237. data/vendor/libgit2/src/status.c +14 -9
  238. data/vendor/libgit2/src/status.h +2 -0
  239. data/vendor/libgit2/src/{curl_stream.c → streams/curl.c} +2 -0
  240. data/vendor/libgit2/src/{curl_stream.h → streams/curl.h} +4 -2
  241. data/vendor/libgit2/src/{openssl_stream.c → streams/openssl.c} +47 -18
  242. data/vendor/libgit2/src/{openssl_stream.h → streams/openssl.h} +6 -2
  243. data/vendor/libgit2/src/{socket_stream.c → streams/socket.c} +2 -2
  244. data/vendor/libgit2/src/{socket_stream.h → streams/socket.h} +4 -2
  245. data/vendor/libgit2/src/{stransport_stream.c → streams/stransport.c} +4 -2
  246. data/vendor/libgit2/src/{stransport_stream.h → streams/stransport.h} +4 -2
  247. data/vendor/libgit2/src/{tls_stream.c → streams/tls.c} +4 -3
  248. data/vendor/libgit2/src/{tls_stream.h → streams/tls.h} +4 -2
  249. data/vendor/libgit2/src/submodule.c +28 -80
  250. data/vendor/libgit2/src/submodule.h +2 -13
  251. data/vendor/libgit2/src/sysdir.c +75 -8
  252. data/vendor/libgit2/src/sysdir.h +2 -1
  253. data/vendor/libgit2/src/tag.c +2 -2
  254. data/vendor/libgit2/src/tag.h +2 -0
  255. data/vendor/libgit2/src/thread-utils.c +1 -0
  256. data/vendor/libgit2/src/thread-utils.h +1 -1
  257. data/vendor/libgit2/src/trace.c +2 -2
  258. data/vendor/libgit2/src/trace.h +2 -0
  259. data/vendor/libgit2/src/trailer.c +416 -0
  260. data/vendor/libgit2/src/transaction.c +2 -1
  261. data/vendor/libgit2/src/transport.c +2 -0
  262. data/vendor/libgit2/src/transports/auth.c +2 -1
  263. data/vendor/libgit2/src/transports/auth.h +4 -3
  264. data/vendor/libgit2/src/transports/auth_negotiate.c +2 -1
  265. data/vendor/libgit2/src/transports/auth_negotiate.h +3 -3
  266. data/vendor/libgit2/src/transports/cred.c +2 -0
  267. data/vendor/libgit2/src/transports/cred.h +4 -2
  268. data/vendor/libgit2/src/transports/cred_helpers.c +1 -0
  269. data/vendor/libgit2/src/transports/git.c +3 -1
  270. data/vendor/libgit2/src/transports/http.c +10 -14
  271. data/vendor/libgit2/src/transports/http.h +23 -0
  272. data/vendor/libgit2/src/transports/local.c +23 -5
  273. data/vendor/libgit2/src/transports/smart.c +3 -1
  274. data/vendor/libgit2/src/transports/smart.h +23 -16
  275. data/vendor/libgit2/src/transports/smart_pkt.c +114 -130
  276. data/vendor/libgit2/src/transports/smart_protocol.c +26 -22
  277. data/vendor/libgit2/src/transports/ssh.c +12 -7
  278. data/vendor/libgit2/src/transports/ssh.h +4 -2
  279. data/vendor/libgit2/src/transports/winhttp.c +19 -21
  280. data/vendor/libgit2/src/tree-cache.c +1 -0
  281. data/vendor/libgit2/src/tree-cache.h +1 -0
  282. data/vendor/libgit2/src/tree.c +20 -14
  283. data/vendor/libgit2/src/tree.h +2 -0
  284. data/vendor/libgit2/src/tsort.c +0 -1
  285. data/vendor/libgit2/src/unix/map.c +4 -1
  286. data/vendor/libgit2/src/unix/posix.h +8 -4
  287. data/vendor/libgit2/src/unix/pthread.h +1 -1
  288. data/vendor/libgit2/src/unix/realpath.c +4 -1
  289. data/vendor/libgit2/src/util.c +6 -5
  290. data/vendor/libgit2/src/util.h +39 -111
  291. data/vendor/libgit2/src/varint.c +0 -1
  292. data/vendor/libgit2/src/varint.h +2 -0
  293. data/vendor/libgit2/src/vector.c +1 -1
  294. data/vendor/libgit2/src/win32/dir.c +3 -0
  295. data/vendor/libgit2/src/win32/dir.h +4 -3
  296. data/vendor/libgit2/src/win32/error.c +1 -1
  297. data/vendor/libgit2/src/win32/error.h +4 -2
  298. data/vendor/libgit2/src/win32/findfile.c +2 -1
  299. data/vendor/libgit2/src/win32/findfile.h +4 -2
  300. data/vendor/libgit2/src/win32/map.c +2 -0
  301. data/vendor/libgit2/src/win32/mingw-compat.h +3 -3
  302. data/vendor/libgit2/src/win32/msvc-compat.h +3 -3
  303. data/vendor/libgit2/src/win32/path_w32.c +7 -12
  304. data/vendor/libgit2/src/win32/path_w32.h +3 -2
  305. data/vendor/libgit2/src/win32/posix.h +2 -2
  306. data/vendor/libgit2/src/win32/posix_w32.c +11 -5
  307. data/vendor/libgit2/src/win32/precompiled.h +2 -1
  308. data/vendor/libgit2/src/win32/reparse.h +2 -2
  309. data/vendor/libgit2/src/win32/thread.c +1 -0
  310. data/vendor/libgit2/src/win32/thread.h +2 -2
  311. data/vendor/libgit2/src/win32/utf-conv.c +0 -1
  312. data/vendor/libgit2/src/win32/utf-conv.h +4 -3
  313. data/vendor/libgit2/src/win32/w32_buffer.c +1 -1
  314. data/vendor/libgit2/src/win32/w32_buffer.h +4 -2
  315. data/vendor/libgit2/src/win32/w32_crtdbg_stacktrace.c +2 -1
  316. data/vendor/libgit2/src/win32/w32_crtdbg_stacktrace.h +85 -2
  317. data/vendor/libgit2/src/win32/w32_stack.c +2 -1
  318. data/vendor/libgit2/src/win32/w32_stack.h +5 -3
  319. data/vendor/libgit2/src/win32/w32_util.h +4 -2
  320. data/vendor/libgit2/src/win32/win32-compat.h +3 -3
  321. data/vendor/libgit2/src/worktree.c +4 -5
  322. data/vendor/libgit2/src/worktree.h +2 -0
  323. data/vendor/libgit2/src/xdiff/xdiff.h +22 -13
  324. data/vendor/libgit2/src/xdiff/xdiffi.c +523 -81
  325. data/vendor/libgit2/src/xdiff/xdiffi.h +2 -2
  326. data/vendor/libgit2/src/xdiff/xemit.c +63 -39
  327. data/vendor/libgit2/src/xdiff/xemit.h +2 -2
  328. data/vendor/libgit2/src/xdiff/xhistogram.c +0 -1
  329. data/vendor/libgit2/src/xdiff/xinclude.h +3 -2
  330. data/vendor/libgit2/src/xdiff/xmacros.h +2 -2
  331. data/vendor/libgit2/src/xdiff/xmerge.c +80 -20
  332. data/vendor/libgit2/src/xdiff/xpatience.c +41 -9
  333. data/vendor/libgit2/src/xdiff/xprepare.c +2 -2
  334. data/vendor/libgit2/src/xdiff/xprepare.h +2 -2
  335. data/vendor/libgit2/src/xdiff/xtypes.h +2 -2
  336. data/vendor/libgit2/src/xdiff/xutils.c +47 -27
  337. data/vendor/libgit2/src/xdiff/xutils.h +2 -5
  338. data/vendor/libgit2/src/zstream.c +65 -45
  339. data/vendor/libgit2/src/zstream.h +9 -2
  340. metadata +27 -13
  341. data/vendor/libgit2/include/git2/sys/remote.h +0 -16
@@ -13,8 +13,8 @@
13
13
  * Lesser General Public License for more details.
14
14
  *
15
15
  * You should have received a copy of the GNU Lesser General Public
16
- * License along with this library; if not, write to the Free Software
17
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16
+ * License along with this library; if not, see
17
+ * <http://www.gnu.org/licenses/>.
18
18
  *
19
19
  * Davide Libenzi <davidel@xmailserver.org>
20
20
  *
@@ -13,8 +13,8 @@
13
13
  * Lesser General Public License for more details.
14
14
  *
15
15
  * You should have received a copy of the GNU Lesser General Public
16
- * License along with this library; if not, write to the Free Software
17
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16
+ * License along with this library; if not, see
17
+ * <http://www.gnu.org/licenses/>.
18
18
  *
19
19
  * Davide Libenzi <davidel@xmailserver.org>
20
20
  *
@@ -22,15 +22,6 @@
22
22
 
23
23
  #include "xinclude.h"
24
24
 
25
-
26
-
27
-
28
- static long xdl_get_rec(xdfile_t *xdf, long ri, char const **rec);
29
- static int xdl_emit_record(xdfile_t *xdf, long ri, char const *pre, xdemitcb_t *ecb);
30
-
31
-
32
-
33
-
34
25
  static long xdl_get_rec(xdfile_t *xdf, long ri, char const **rec) {
35
26
 
36
27
  *rec = xdf->recs[ri]->ptr;
@@ -110,7 +101,7 @@ static long def_ff(const char *rec, long len, char *buf, long sz, void *priv)
110
101
 
111
102
  if (len > 0 &&
112
103
  (isalpha((unsigned char)*rec) || /* identifier? */
113
- *rec == '_' || /* also identifier? */
104
+ *rec == '_' || /* also identifier? */
114
105
  *rec == '$')) { /* identifiers from VMS and other esoterico */
115
106
  if (len > sz)
116
107
  len = sz;
@@ -122,22 +113,20 @@ static long def_ff(const char *rec, long len, char *buf, long sz, void *priv)
122
113
  return -1;
123
114
  }
124
115
 
125
- static int xdl_emit_common(xdfenv_t *xe, xdchange_t *xscr, xdemitcb_t *ecb,
126
- xdemitconf_t const *xecfg) {
127
- xdfile_t *xdf = &xe->xdf2;
128
- const char *rchg = xdf->rchg;
129
- long ix;
130
-
131
- (void)xscr;
132
- (void)xecfg;
116
+ static long match_func_rec(xdfile_t *xdf, xdemitconf_t const *xecfg, long ri,
117
+ char *buf, long sz)
118
+ {
119
+ const char *rec;
120
+ long len = xdl_get_rec(xdf, ri, &rec);
121
+ if (!xecfg->find_func)
122
+ return def_ff(rec, len, buf, sz, xecfg->find_func_priv);
123
+ return xecfg->find_func(rec, len, buf, sz, xecfg->find_func_priv);
124
+ }
133
125
 
134
- for (ix = 0; ix < xdf->nrec; ix++) {
135
- if (rchg[ix])
136
- continue;
137
- if (xdl_emit_record(xdf, ix, "", ecb))
138
- return -1;
139
- }
140
- return 0;
126
+ static int is_func_rec(xdfile_t *xdf, xdemitconf_t const *xecfg, long ri)
127
+ {
128
+ char dummy[1];
129
+ return match_func_rec(xdf, xecfg, ri, dummy, sizeof(dummy)) >= 0;
141
130
  }
142
131
 
143
132
  struct func_line {
@@ -148,7 +137,6 @@ struct func_line {
148
137
  static long get_func_line(xdfenv_t *xe, xdemitconf_t const *xecfg,
149
138
  struct func_line *func_line, long start, long limit)
150
139
  {
151
- find_func_t ff = xecfg->find_func ? xecfg->find_func : def_ff;
152
140
  long l, size, step = (start > limit) ? -1 : 1;
153
141
  char *buf, dummy[1];
154
142
 
@@ -156,9 +144,7 @@ static long get_func_line(xdfenv_t *xe, xdemitconf_t const *xecfg,
156
144
  size = func_line ? sizeof(func_line->buf) : sizeof(dummy);
157
145
 
158
146
  for (l = start; l != limit && 0 <= l && l < xe->xdf1.nrec; l += step) {
159
- const char *rec;
160
- long reclen = xdl_get_rec(&xe->xdf1, l, &rec);
161
- long len = ff(rec, reclen, buf, size, xecfg->find_func_priv);
147
+ long len = match_func_rec(&xe->xdf1, xecfg, l, buf, size);
162
148
  if (len >= 0) {
163
149
  if (func_line)
164
150
  func_line->len = len;
@@ -168,6 +154,18 @@ static long get_func_line(xdfenv_t *xe, xdemitconf_t const *xecfg,
168
154
  return -1;
169
155
  }
170
156
 
157
+ static int is_empty_rec(xdfile_t *xdf, long ri)
158
+ {
159
+ const char *rec;
160
+ long len = xdl_get_rec(xdf, ri, &rec);
161
+
162
+ while (len > 0 && XDL_ISSPACE(*rec)) {
163
+ rec++;
164
+ len--;
165
+ }
166
+ return !len;
167
+ }
168
+
171
169
  int xdl_emit_diff(xdfenv_t *xe, xdchange_t *xscr, xdemitcb_t *ecb,
172
170
  xdemitconf_t const *xecfg) {
173
171
  long s1, s2, e1, e2, lctx;
@@ -175,9 +173,6 @@ int xdl_emit_diff(xdfenv_t *xe, xdchange_t *xscr, xdemitcb_t *ecb,
175
173
  long funclineprev = -1;
176
174
  struct func_line func_line = { 0 };
177
175
 
178
- if (xecfg->flags & XDL_EMIT_COMMON)
179
- return xdl_emit_common(xe, xscr, ecb, xecfg);
180
-
181
176
  for (xch = xscr; xch; xch = xche->next) {
182
177
  xche = xdl_get_hunk(&xch, xecfg);
183
178
  if (!xch)
@@ -187,7 +182,33 @@ int xdl_emit_diff(xdfenv_t *xe, xdchange_t *xscr, xdemitcb_t *ecb,
187
182
  s2 = XDL_MAX(xch->i2 - xecfg->ctxlen, 0);
188
183
 
189
184
  if (xecfg->flags & XDL_EMIT_FUNCCONTEXT) {
190
- long fs1 = get_func_line(xe, xecfg, NULL, xch->i1, -1);
185
+ long fs1, i1 = xch->i1;
186
+
187
+ /* Appended chunk? */
188
+ if (i1 >= xe->xdf1.nrec) {
189
+ long i2 = xch->i2;
190
+
191
+ /*
192
+ * We don't need additional context if
193
+ * a whole function was added.
194
+ */
195
+ while (i2 < xe->xdf2.nrec) {
196
+ if (is_func_rec(&xe->xdf2, xecfg, i2))
197
+ goto post_context_calculation;
198
+ i2++;
199
+ }
200
+
201
+ /*
202
+ * Otherwise get more context from the
203
+ * pre-image.
204
+ */
205
+ i1 = xe->xdf1.nrec - 1;
206
+ }
207
+
208
+ fs1 = get_func_line(xe, xecfg, NULL, i1, -1);
209
+ while (fs1 > 0 && !is_empty_rec(&xe->xdf1, fs1 - 1) &&
210
+ !is_func_rec(&xe->xdf1, xecfg, fs1 - 1))
211
+ fs1--;
191
212
  if (fs1 < 0)
192
213
  fs1 = 0;
193
214
  if (fs1 < s1) {
@@ -196,7 +217,7 @@ int xdl_emit_diff(xdfenv_t *xe, xdchange_t *xscr, xdemitcb_t *ecb,
196
217
  }
197
218
  }
198
219
 
199
- again:
220
+ post_context_calculation:
200
221
  lctx = xecfg->ctxlen;
201
222
  lctx = XDL_MIN(lctx, xe->xdf1.nrec - (xche->i1 + xche->chg1));
202
223
  lctx = XDL_MIN(lctx, xe->xdf2.nrec - (xche->i2 + xche->chg2));
@@ -208,6 +229,8 @@ int xdl_emit_diff(xdfenv_t *xe, xdchange_t *xscr, xdemitcb_t *ecb,
208
229
  long fe1 = get_func_line(xe, xecfg, NULL,
209
230
  xche->i1 + xche->chg1,
210
231
  xe->xdf1.nrec);
232
+ while (fe1 > 0 && is_empty_rec(&xe->xdf1, fe1 - 1))
233
+ fe1--;
211
234
  if (fe1 < 0)
212
235
  fe1 = xe->xdf1.nrec;
213
236
  if (fe1 > e1) {
@@ -221,11 +244,12 @@ int xdl_emit_diff(xdfenv_t *xe, xdchange_t *xscr, xdemitcb_t *ecb,
221
244
  * its new end.
222
245
  */
223
246
  if (xche->next) {
224
- long l = xche->next->i1;
225
- if (l <= e1 ||
247
+ long l = XDL_MIN(xche->next->i1,
248
+ xe->xdf1.nrec - 1);
249
+ if (l - xecfg->ctxlen <= e1 ||
226
250
  get_func_line(xe, xecfg, NULL, l, e1) < 0) {
227
251
  xche = xche->next;
228
- goto again;
252
+ goto post_context_calculation;
229
253
  }
230
254
  }
231
255
  }
@@ -13,8 +13,8 @@
13
13
  * Lesser General Public License for more details.
14
14
  *
15
15
  * You should have received a copy of the GNU Lesser General Public
16
- * License along with this library; if not, write to the Free Software
17
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16
+ * License along with this library; if not, see
17
+ * <http://www.gnu.org/licenses/>.
18
18
  *
19
19
  * Davide Libenzi <davidel@xmailserver.org>
20
20
  *
@@ -44,7 +44,6 @@
44
44
  #include "xinclude.h"
45
45
  #include "xtypes.h"
46
46
  #include "xdiff.h"
47
- #include "common.h"
48
47
 
49
48
  #define MAX_PTR UINT_MAX
50
49
  #define MAX_CNT UINT_MAX
@@ -13,8 +13,8 @@
13
13
  * Lesser General Public License for more details.
14
14
  *
15
15
  * You should have received a copy of the GNU Lesser General Public
16
- * License along with this library; if not, write to the Free Software
17
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16
+ * License along with this library; if not, see
17
+ * <http://www.gnu.org/licenses/>.
18
18
  *
19
19
  * Davide Libenzi <davidel@xmailserver.org>
20
20
  *
@@ -42,5 +42,6 @@
42
42
  #include "xdiffi.h"
43
43
  #include "xemit.h"
44
44
 
45
+ #include "common.h"
45
46
 
46
47
  #endif /* #if !defined(XINCLUDE_H) */
@@ -13,8 +13,8 @@
13
13
  * Lesser General Public License for more details.
14
14
  *
15
15
  * You should have received a copy of the GNU Lesser General Public
16
- * License along with this library; if not, write to the Free Software
17
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16
+ * License along with this library; if not, see
17
+ * <http://www.gnu.org/licenses/>.
18
18
  *
19
19
  * Davide Libenzi <davidel@xmailserver.org>
20
20
  *
@@ -13,15 +13,14 @@
13
13
  * Lesser General Public License for more details.
14
14
  *
15
15
  * You should have received a copy of the GNU Lesser General Public
16
- * License along with this library; if not, write to the Free Software
17
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16
+ * License along with this library; if not, see
17
+ * <http://www.gnu.org/licenses/>.
18
18
  *
19
19
  * Davide Libenzi <davidel@xmailserver.org>
20
20
  *
21
21
  */
22
22
 
23
23
  #include "xinclude.h"
24
- #include "common.h"
25
24
 
26
25
  typedef struct s_xdmerge {
27
26
  struct s_xdmerge *next;
@@ -110,7 +109,7 @@ static int xdl_merge_cmp_lines(xdfenv_t *xe1, int i1, xdfenv_t *xe2, int i2,
110
109
  return 0;
111
110
  }
112
111
 
113
- static int xdl_recs_copy_0(size_t *out, int use_orig, xdfenv_t *xe, int i, int count, int add_nl, char *dest)
112
+ static int xdl_recs_copy_0(size_t *out, int use_orig, xdfenv_t *xe, int i, int count, int needs_cr, int add_nl, char *dest)
114
113
  {
115
114
  xrecord_t **recs;
116
115
  size_t size = 0;
@@ -132,6 +131,12 @@ static int xdl_recs_copy_0(size_t *out, int use_orig, xdfenv_t *xe, int i, int c
132
131
  if (add_nl) {
133
132
  i = recs[count - 1]->size;
134
133
  if (i == 0 || recs[count - 1]->ptr[i - 1] != '\n') {
134
+ if (needs_cr) {
135
+ if (dest)
136
+ dest[size] = '\r';
137
+ GITERR_CHECK_ALLOC_ADD(&size, size, 1);
138
+ }
139
+
135
140
  if (dest)
136
141
  dest[size] = '\n';
137
142
 
@@ -143,14 +148,58 @@ static int xdl_recs_copy_0(size_t *out, int use_orig, xdfenv_t *xe, int i, int c
143
148
  return 0;
144
149
  }
145
150
 
146
- static int xdl_recs_copy(size_t *out, xdfenv_t *xe, int i, int count, int add_nl, char *dest)
151
+ static int xdl_recs_copy(size_t *out, xdfenv_t *xe, int i, int count, int needs_cr, int add_nl, char *dest)
147
152
  {
148
- return xdl_recs_copy_0(out, 0, xe, i, count, add_nl, dest);
153
+ return xdl_recs_copy_0(out, 0, xe, i, count, needs_cr, add_nl, dest);
149
154
  }
150
155
 
151
- static int xdl_orig_copy(size_t *out, xdfenv_t *xe, int i, int count, int add_nl, char *dest)
156
+ static int xdl_orig_copy(size_t *out, xdfenv_t *xe, int i, int count, int needs_cr, int add_nl, char *dest)
152
157
  {
153
- return xdl_recs_copy_0(out, 1, xe, i, count, add_nl, dest);
158
+ return xdl_recs_copy_0(out, 1, xe, i, count, needs_cr, add_nl, dest);
159
+ }
160
+
161
+ /*
162
+ * Returns 1 if the i'th line ends in CR/LF (if it is the last line and
163
+ * has no eol, the preceding line, if any), 0 if it ends in LF-only, and
164
+ * -1 if the line ending cannot be determined.
165
+ */
166
+ static int is_eol_crlf(xdfile_t *file, int i)
167
+ {
168
+ long size;
169
+
170
+ if (i < file->nrec - 1)
171
+ /* All lines before the last *must* end in LF */
172
+ return (size = file->recs[i]->size) > 1 &&
173
+ file->recs[i]->ptr[size - 2] == '\r';
174
+ if (!file->nrec)
175
+ /* Cannot determine eol style from empty file */
176
+ return -1;
177
+ if ((size = file->recs[i]->size) &&
178
+ file->recs[i]->ptr[size - 1] == '\n')
179
+ /* Last line; ends in LF; Is it CR/LF? */
180
+ return size > 1 &&
181
+ file->recs[i]->ptr[size - 2] == '\r';
182
+ if (!i)
183
+ /* The only line has no eol */
184
+ return -1;
185
+ /* Determine eol from second-to-last line */
186
+ return (size = file->recs[i - 1]->size) > 1 &&
187
+ file->recs[i - 1]->ptr[size - 2] == '\r';
188
+ }
189
+
190
+ static int is_cr_needed(xdfenv_t *xe1, xdfenv_t *xe2, xdmerge_t *m)
191
+ {
192
+ int needs_cr;
193
+
194
+ /* Match post-images' preceding, or first, lines' end-of-line style */
195
+ needs_cr = is_eol_crlf(&xe1->xdf2, m->i1 ? m->i1 - 1 : 0);
196
+ if (needs_cr)
197
+ needs_cr = is_eol_crlf(&xe2->xdf2, m->i2 ? m->i2 - 1 : 0);
198
+ /* Look at pre-image's first line, unless we already settled on LF */
199
+ if (needs_cr)
200
+ needs_cr = is_eol_crlf(&xe1->xdf1, 0);
201
+ /* If still undecided, use LF-only */
202
+ return needs_cr < 0 ? 0 : needs_cr;
154
203
  }
155
204
 
156
205
  static int fill_conflict_hunk(size_t *out, xdfenv_t *xe1, const char *name1,
@@ -162,6 +211,7 @@ static int fill_conflict_hunk(size_t *out, xdfenv_t *xe1, const char *name1,
162
211
  int marker1_size = (name1 ? (int)strlen(name1) + 1 : 0);
163
212
  int marker2_size = (name2 ? (int)strlen(name2) + 1 : 0);
164
213
  int marker3_size = (name3 ? (int)strlen(name3) + 1 : 0);
214
+ int needs_cr = is_cr_needed(xe1, xe2, m);
165
215
  size_t copied;
166
216
 
167
217
  *out = 0;
@@ -170,14 +220,14 @@ static int fill_conflict_hunk(size_t *out, xdfenv_t *xe1, const char *name1,
170
220
  marker_size = DEFAULT_CONFLICT_MARKER_SIZE;
171
221
 
172
222
  /* Before conflicting part */
173
- if (xdl_recs_copy(&copied, xe1, i, m->i1 - i, 0,
223
+ if (xdl_recs_copy(&copied, xe1, i, m->i1 - i, 0, 0,
174
224
  dest ? dest + size : NULL) < 0)
175
225
  return -1;
176
226
 
177
227
  GITERR_CHECK_ALLOC_ADD(&size, size, copied);
178
228
 
179
229
  if (!dest) {
180
- GITERR_CHECK_ALLOC_ADD4(&size, size, marker_size, 1, marker1_size);
230
+ GITERR_CHECK_ALLOC_ADD5(&size, size, marker_size, 1, needs_cr, marker1_size);
181
231
  } else {
182
232
  memset(dest + size, '<', marker_size);
183
233
  size += marker_size;
@@ -186,11 +236,13 @@ static int fill_conflict_hunk(size_t *out, xdfenv_t *xe1, const char *name1,
186
236
  memcpy(dest + size + 1, name1, marker1_size - 1);
187
237
  size += marker1_size;
188
238
  }
239
+ if (needs_cr)
240
+ dest[size++] = '\r';
189
241
  dest[size++] = '\n';
190
242
  }
191
243
 
192
244
  /* Postimage from side #1 */
193
- if (xdl_recs_copy(&copied, xe1, m->i1, m->chg1, 1,
245
+ if (xdl_recs_copy(&copied, xe1, m->i1, m->chg1, needs_cr, 1,
194
246
  dest ? dest + size : NULL) < 0)
195
247
  return -1;
196
248
 
@@ -199,7 +251,7 @@ static int fill_conflict_hunk(size_t *out, xdfenv_t *xe1, const char *name1,
199
251
  if (style == XDL_MERGE_DIFF3) {
200
252
  /* Shared preimage */
201
253
  if (!dest) {
202
- GITERR_CHECK_ALLOC_ADD4(&size, size, marker_size, 1, marker3_size);
254
+ GITERR_CHECK_ALLOC_ADD5(&size, size, marker_size, 1, needs_cr, marker3_size);
203
255
  } else {
204
256
  memset(dest + size, '|', marker_size);
205
257
  size += marker_size;
@@ -208,32 +260,36 @@ static int fill_conflict_hunk(size_t *out, xdfenv_t *xe1, const char *name1,
208
260
  memcpy(dest + size + 1, name3, marker3_size - 1);
209
261
  size += marker3_size;
210
262
  }
263
+ if (needs_cr)
264
+ dest[size++] = '\r';
211
265
  dest[size++] = '\n';
212
266
  }
213
267
 
214
- if (xdl_orig_copy(&copied, xe1, m->i0, m->chg0, 1,
268
+ if (xdl_orig_copy(&copied, xe1, m->i0, m->chg0, needs_cr, 1,
215
269
  dest ? dest + size : NULL) < 0)
216
270
  return -1;
217
271
  GITERR_CHECK_ALLOC_ADD(&size, size, copied);
218
272
  }
219
273
 
220
274
  if (!dest) {
221
- GITERR_CHECK_ALLOC_ADD3(&size, size, marker_size, 1);
275
+ GITERR_CHECK_ALLOC_ADD4(&size, size, marker_size, 1, needs_cr);
222
276
  } else {
223
277
  memset(dest + size, '=', marker_size);
224
278
  size += marker_size;
279
+ if (needs_cr)
280
+ dest[size++] = '\r';
225
281
  dest[size++] = '\n';
226
282
  }
227
283
 
228
284
  /* Postimage from side #2 */
229
285
 
230
- if (xdl_recs_copy(&copied, xe2, m->i2, m->chg2, 1,
286
+ if (xdl_recs_copy(&copied, xe2, m->i2, m->chg2, needs_cr, 1,
231
287
  dest ? dest + size : NULL) < 0)
232
288
  return -1;
233
289
  GITERR_CHECK_ALLOC_ADD(&size, size, copied);
234
290
 
235
291
  if (!dest) {
236
- GITERR_CHECK_ALLOC_ADD4(&size, size, marker_size, 1, marker2_size);
292
+ GITERR_CHECK_ALLOC_ADD5(&size, size, marker_size, 1, needs_cr, marker2_size);
237
293
  } else {
238
294
  memset(dest + size, '>', marker_size);
239
295
  size += marker_size;
@@ -242,6 +298,8 @@ static int fill_conflict_hunk(size_t *out, xdfenv_t *xe1, const char *name1,
242
298
  memcpy(dest + size + 1, name2, marker2_size - 1);
243
299
  size += marker2_size;
244
300
  }
301
+ if (needs_cr)
302
+ dest[size++] = '\r';
245
303
  dest[size++] = '\n';
246
304
  }
247
305
 
@@ -275,14 +333,16 @@ static int xdl_fill_merge_buffer(size_t *out,
275
333
  }
276
334
  else if (m->mode & 3) {
277
335
  /* Before conflicting part */
278
- if (xdl_recs_copy(&copied, xe1, i, m->i1 - i, 0,
336
+ if (xdl_recs_copy(&copied, xe1, i, m->i1 - i, 0, 0,
279
337
  dest ? dest + size : NULL) < 0)
280
338
  return -1;
281
339
  GITERR_CHECK_ALLOC_ADD(&size, size, copied);
282
340
 
283
341
  /* Postimage from side #1 */
284
342
  if (m->mode & 1) {
285
- if (xdl_recs_copy(&copied, xe1, m->i1, m->chg1, (m->mode & 2),
343
+ int needs_cr = is_cr_needed(xe1, xe2, m);
344
+
345
+ if (xdl_recs_copy(&copied, xe1, m->i1, m->chg1, needs_cr, (m->mode & 2),
286
346
  dest ? dest + size : NULL) < 0)
287
347
  return -1;
288
348
  GITERR_CHECK_ALLOC_ADD(&size, size, copied);
@@ -290,7 +350,7 @@ static int xdl_fill_merge_buffer(size_t *out,
290
350
 
291
351
  /* Postimage from side #2 */
292
352
  if (m->mode & 2) {
293
- if (xdl_recs_copy(&copied, xe2, m->i2, m->chg2, 0,
353
+ if (xdl_recs_copy(&copied, xe2, m->i2, m->chg2, 0, 0,
294
354
  dest ? dest + size : NULL) < 0)
295
355
  return -1;
296
356
  GITERR_CHECK_ALLOC_ADD(&size, size, copied);
@@ -300,7 +360,7 @@ static int xdl_fill_merge_buffer(size_t *out,
300
360
  i = m->i1 + m->chg1;
301
361
  }
302
362
 
303
- if (xdl_recs_copy(&copied, xe1, i, xe1->xdf2.nrec - i, 0,
363
+ if (xdl_recs_copy(&copied, xe1, i, xe1->xdf2.nrec - i, 0, 0,
304
364
  dest ? dest + size : NULL) < 0)
305
365
  return -1;
306
366
  GITERR_CHECK_ALLOC_ADD(&size, size, copied);