rugged 0.18.0.gh.de28323 → 0.19.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (283) hide show
  1. data/README.md +9 -4
  2. data/Rakefile +1 -1
  3. data/ext/rugged/extconf.rb +10 -0
  4. data/ext/rugged/rugged.c +153 -86
  5. data/ext/rugged/rugged.h +44 -33
  6. data/ext/rugged/rugged_blob.c +288 -60
  7. data/ext/rugged/rugged_branch.c +82 -57
  8. data/ext/rugged/rugged_commit.c +83 -86
  9. data/ext/rugged/rugged_config.c +68 -68
  10. data/ext/rugged/rugged_diff.c +509 -0
  11. data/ext/rugged/rugged_diff_delta.c +94 -0
  12. data/ext/rugged/rugged_diff_hunk.c +100 -0
  13. data/ext/rugged/rugged_diff_line.c +79 -0
  14. data/ext/rugged/rugged_diff_patch.c +169 -0
  15. data/ext/rugged/rugged_index.c +539 -8
  16. data/ext/rugged/rugged_note.c +74 -80
  17. data/ext/rugged/rugged_object.c +63 -8
  18. data/ext/rugged/rugged_reference.c +231 -145
  19. data/ext/rugged/rugged_remote.c +509 -53
  20. data/ext/rugged/rugged_repo.c +572 -236
  21. data/ext/rugged/rugged_revwalk.c +59 -36
  22. data/ext/rugged/rugged_settings.c +7 -9
  23. data/ext/rugged/rugged_signature.c +7 -11
  24. data/ext/rugged/rugged_tag.c +93 -39
  25. data/ext/rugged/rugged_tree.c +321 -58
  26. data/lib/rugged.rb +1 -0
  27. data/lib/rugged/commit.rb +16 -1
  28. data/lib/rugged/console.rb +9 -0
  29. data/lib/rugged/diff.rb +19 -0
  30. data/lib/rugged/diff/delta.rb +54 -0
  31. data/lib/rugged/diff/hunk.rb +23 -0
  32. data/lib/rugged/diff/line.rb +29 -0
  33. data/lib/rugged/diff/patch.rb +28 -0
  34. data/lib/rugged/repository.rb +36 -39
  35. data/lib/rugged/version.rb +1 -1
  36. data/test/blob_test.rb +308 -1
  37. data/test/branch_test.rb +7 -0
  38. data/test/commit_test.rb +7 -10
  39. data/test/coverage/cover.rb +9 -1
  40. data/test/diff_test.rb +777 -0
  41. data/test/fixtures/archive.tar.gz +0 -0
  42. data/test/fixtures/attr/attr0 +1 -0
  43. data/test/fixtures/attr/attr1 +29 -0
  44. data/test/fixtures/attr/attr2 +21 -0
  45. data/test/fixtures/attr/attr3 +4 -0
  46. data/test/fixtures/attr/binfile +1 -0
  47. data/test/fixtures/attr/dir/file +0 -0
  48. data/test/fixtures/attr/file +1 -0
  49. data/test/fixtures/attr/gitattributes +29 -0
  50. data/test/fixtures/attr/gitignore +2 -0
  51. data/test/fixtures/attr/ign +1 -0
  52. data/test/fixtures/attr/macro_bad +1 -0
  53. data/test/fixtures/attr/macro_test +1 -0
  54. data/test/fixtures/attr/root_test1 +1 -0
  55. data/test/fixtures/attr/root_test2 +6 -0
  56. data/test/fixtures/attr/root_test3 +19 -0
  57. data/test/fixtures/attr/root_test4.txt +14 -0
  58. data/test/fixtures/attr/sub/abc +37 -0
  59. data/test/fixtures/attr/sub/dir/file +0 -0
  60. data/test/fixtures/attr/sub/file +1 -0
  61. data/test/fixtures/attr/sub/ign/file +1 -0
  62. data/test/fixtures/attr/sub/ign/sub/file +1 -0
  63. data/test/fixtures/attr/sub/sub/dir +0 -0
  64. data/test/fixtures/attr/sub/sub/file +1 -0
  65. data/test/fixtures/attr/sub/sub/subsub.txt +1 -0
  66. data/test/fixtures/attr/sub/subdir_test1 +2 -0
  67. data/test/fixtures/attr/sub/subdir_test2.txt +1 -0
  68. data/test/fixtures/diff/another.txt +38 -0
  69. data/test/fixtures/diff/readme.txt +36 -0
  70. data/test/fixtures/mergedrepo/conflicts-one.txt +5 -0
  71. data/test/fixtures/mergedrepo/conflicts-two.txt +5 -0
  72. data/test/fixtures/mergedrepo/one.txt +10 -0
  73. data/test/fixtures/mergedrepo/two.txt +12 -0
  74. data/test/fixtures/status/current_file +1 -0
  75. data/test/fixtures/status/ignored_file +1 -0
  76. data/test/fixtures/status/modified_file +2 -0
  77. data/test/fixtures/status/new_file +1 -0
  78. data/test/fixtures/status/staged_changes +2 -0
  79. data/test/fixtures/status/staged_changes_modified_file +3 -0
  80. data/test/fixtures/status/staged_delete_modified_file +1 -0
  81. data/test/fixtures/status/staged_new_file +1 -0
  82. data/test/fixtures/status/staged_new_file_modified_file +2 -0
  83. data/test/fixtures/status/subdir.txt +2 -0
  84. data/test/fixtures/status/subdir/current_file +1 -0
  85. data/test/fixtures/status/subdir/modified_file +2 -0
  86. data/test/fixtures/status/subdir/new_file +1 -0
  87. data/test/fixtures/status//350/277/231 +1 -0
  88. data/test/fixtures/testrepo.git/config +5 -0
  89. data/test/fixtures/testrepo.git/objects/77/71329dfa3002caf8c61a0ceb62a31d09023f37 +0 -0
  90. data/test/fixtures/text_file.md +464 -0
  91. data/test/fixtures/unsymlinked.git/HEAD +1 -0
  92. data/test/fixtures/unsymlinked.git/config +6 -0
  93. data/test/fixtures/unsymlinked.git/description +1 -0
  94. data/test/fixtures/unsymlinked.git/info/exclude +2 -0
  95. data/test/fixtures/unsymlinked.git/objects/08/8b64704e0d6b8bd061dea879418cb5442a3fbf +0 -0
  96. data/test/fixtures/unsymlinked.git/objects/13/a5e939bca25940c069fd2169d993dba328e30b +0 -0
  97. data/test/fixtures/unsymlinked.git/objects/19/bf568e59e3a0b363cafb4106226e62d4a4c41c +0 -0
  98. data/test/fixtures/unsymlinked.git/objects/58/1fadd35b4cf320d102a152f918729011604773 +0 -0
  99. data/test/fixtures/unsymlinked.git/objects/5c/87b6791e8b13da658a14d1ef7e09b5dc3bac8c +0 -0
  100. data/test/fixtures/unsymlinked.git/objects/6f/e5f5398af85fb3de8a6aba0339b6d3bfa26a27 +0 -0
  101. data/test/fixtures/unsymlinked.git/objects/7f/ccd75616ec188b8f1b23d67506a334cc34a49d +0 -0
  102. data/test/fixtures/unsymlinked.git/objects/80/6999882bf91d24241e4077906b9017605eb1f3 +0 -0
  103. data/test/fixtures/unsymlinked.git/objects/83/7d176303c5005505ec1e4a30231c40930c0230 +0 -0
  104. data/test/fixtures/unsymlinked.git/objects/a8/595ccca04f40818ae0155c8f9c77a230e597b6 +2 -0
  105. data/test/fixtures/unsymlinked.git/objects/cf/8f1cf5cce859c438d6cc067284cb5e161206e7 +0 -0
  106. data/test/fixtures/unsymlinked.git/objects/d5/278d05c8607ec420bfee4cf219fbc0eeebfd6a +0 -0
  107. data/test/fixtures/unsymlinked.git/objects/f4/e16fb76536591a41454194058d048d8e4dd2e9 +0 -0
  108. data/test/fixtures/unsymlinked.git/objects/f9/e65619d93fdf2673882e0a261c5e93b1a84006 +0 -0
  109. data/test/fixtures/unsymlinked.git/refs/heads/exe-file +1 -0
  110. data/test/fixtures/unsymlinked.git/refs/heads/master +1 -0
  111. data/test/fixtures/unsymlinked.git/refs/heads/reg-file +1 -0
  112. data/test/index_test.rb +120 -0
  113. data/test/reference_test.rb +38 -3
  114. data/test/remote_test.rb +224 -3
  115. data/test/repo_reset_test.rb +2 -0
  116. data/test/repo_test.rb +147 -10
  117. data/test/test_helper.rb +5 -2
  118. data/vendor/libgit2/include/git2/attr.h +3 -3
  119. data/vendor/libgit2/include/git2/blob.h +11 -17
  120. data/vendor/libgit2/include/git2/branch.h +3 -2
  121. data/vendor/libgit2/include/git2/checkout.h +7 -0
  122. data/vendor/libgit2/include/git2/clone.h +3 -0
  123. data/vendor/libgit2/include/git2/commit.h +61 -66
  124. data/vendor/libgit2/include/git2/common.h +73 -42
  125. data/vendor/libgit2/include/git2/config.h +57 -71
  126. data/vendor/libgit2/include/git2/cred_helpers.h +2 -2
  127. data/vendor/libgit2/include/git2/diff.h +179 -30
  128. data/vendor/libgit2/include/git2/errors.h +3 -3
  129. data/vendor/libgit2/include/git2/index.h +225 -146
  130. data/vendor/libgit2/include/git2/indexer.h +2 -22
  131. data/vendor/libgit2/include/git2/inttypes.h +9 -9
  132. data/vendor/libgit2/include/git2/merge.h +123 -5
  133. data/vendor/libgit2/include/git2/odb.h +59 -38
  134. data/vendor/libgit2/include/git2/odb_backend.h +45 -104
  135. data/vendor/libgit2/include/git2/oid.h +30 -19
  136. data/vendor/libgit2/include/git2/pack.h +21 -3
  137. data/vendor/libgit2/include/git2/refdb.h +0 -35
  138. data/vendor/libgit2/include/git2/refs.h +93 -31
  139. data/vendor/libgit2/include/git2/refspec.h +17 -0
  140. data/vendor/libgit2/include/git2/remote.h +60 -20
  141. data/vendor/libgit2/include/git2/repository.h +48 -70
  142. data/vendor/libgit2/include/git2/reset.h +3 -3
  143. data/vendor/libgit2/include/git2/revparse.h +22 -0
  144. data/vendor/libgit2/include/git2/stash.h +1 -1
  145. data/vendor/libgit2/include/git2/status.h +131 -56
  146. data/vendor/libgit2/include/git2/strarray.h +2 -2
  147. data/vendor/libgit2/include/git2/submodule.h +16 -16
  148. data/vendor/libgit2/include/git2/sys/commit.h +46 -0
  149. data/vendor/libgit2/include/git2/sys/config.h +71 -0
  150. data/vendor/libgit2/include/git2/sys/index.h +179 -0
  151. data/vendor/libgit2/include/git2/sys/odb_backend.h +86 -0
  152. data/vendor/libgit2/include/git2/sys/refdb_backend.h +158 -0
  153. data/vendor/libgit2/include/git2/sys/refs.h +38 -0
  154. data/vendor/libgit2/include/git2/sys/repository.h +106 -0
  155. data/vendor/libgit2/include/git2/tag.h +44 -18
  156. data/vendor/libgit2/include/git2/trace.h +1 -2
  157. data/vendor/libgit2/include/git2/transport.h +74 -0
  158. data/vendor/libgit2/include/git2/tree.h +12 -22
  159. data/vendor/libgit2/include/git2/types.h +33 -0
  160. data/vendor/libgit2/include/git2/version.h +2 -2
  161. data/vendor/libgit2/src/array.h +66 -0
  162. data/vendor/libgit2/src/attr.c +26 -13
  163. data/vendor/libgit2/src/attr_file.c +3 -2
  164. data/vendor/libgit2/src/attr_file.h +3 -3
  165. data/vendor/libgit2/src/attrcache.h +4 -4
  166. data/vendor/libgit2/src/blob.c +13 -9
  167. data/vendor/libgit2/src/blob.h +2 -2
  168. data/vendor/libgit2/src/branch.c +67 -49
  169. data/vendor/libgit2/src/cache.c +224 -54
  170. data/vendor/libgit2/src/cache.h +33 -20
  171. data/vendor/libgit2/src/checkout.c +145 -85
  172. data/vendor/libgit2/src/clone.c +62 -50
  173. data/vendor/libgit2/src/commit.c +74 -40
  174. data/vendor/libgit2/src/commit.h +2 -3
  175. data/vendor/libgit2/src/commit_list.c +14 -8
  176. data/vendor/libgit2/src/config.c +119 -36
  177. data/vendor/libgit2/src/config.h +3 -0
  178. data/vendor/libgit2/src/config_cache.c +24 -7
  179. data/vendor/libgit2/src/config_file.c +9 -6
  180. data/vendor/libgit2/src/crlf.c +4 -2
  181. data/vendor/libgit2/src/date.c +3 -3
  182. data/vendor/libgit2/src/delta.c +1 -1
  183. data/vendor/libgit2/src/diff.c +681 -303
  184. data/vendor/libgit2/src/diff.h +34 -2
  185. data/vendor/libgit2/src/diff_driver.c +405 -0
  186. data/vendor/libgit2/src/diff_driver.h +49 -0
  187. data/vendor/libgit2/src/diff_file.c +447 -0
  188. data/vendor/libgit2/src/diff_file.h +58 -0
  189. data/vendor/libgit2/src/diff_patch.c +995 -0
  190. data/vendor/libgit2/src/diff_patch.h +46 -0
  191. data/vendor/libgit2/src/diff_print.c +430 -0
  192. data/vendor/libgit2/src/diff_tform.c +464 -203
  193. data/vendor/libgit2/src/diff_xdiff.c +166 -0
  194. data/vendor/libgit2/src/diff_xdiff.h +28 -0
  195. data/vendor/libgit2/src/fetch.c +11 -4
  196. data/vendor/libgit2/src/fileops.c +85 -61
  197. data/vendor/libgit2/src/fileops.h +4 -0
  198. data/vendor/libgit2/src/global.c +10 -2
  199. data/vendor/libgit2/src/global.h +0 -8
  200. data/vendor/libgit2/src/hash/hash_generic.h +3 -3
  201. data/vendor/libgit2/src/hash/hash_win32.h +4 -4
  202. data/vendor/libgit2/src/hashsig.c +0 -1
  203. data/vendor/libgit2/src/ignore.c +68 -28
  204. data/vendor/libgit2/src/ignore.h +10 -1
  205. data/vendor/libgit2/src/index.c +666 -84
  206. data/vendor/libgit2/src/index.h +6 -0
  207. data/vendor/libgit2/src/indexer.c +10 -28
  208. data/vendor/libgit2/src/iterator.c +427 -283
  209. data/vendor/libgit2/src/iterator.h +58 -4
  210. data/vendor/libgit2/src/merge.c +1892 -32
  211. data/vendor/libgit2/src/merge.h +132 -5
  212. data/vendor/libgit2/src/merge_file.c +174 -0
  213. data/vendor/libgit2/src/merge_file.h +71 -0
  214. data/vendor/libgit2/src/mwindow.c +1 -1
  215. data/vendor/libgit2/src/notes.c +45 -48
  216. data/vendor/libgit2/src/object.c +89 -127
  217. data/vendor/libgit2/src/object.h +0 -1
  218. data/vendor/libgit2/src/object_api.c +129 -0
  219. data/vendor/libgit2/src/odb.c +156 -59
  220. data/vendor/libgit2/src/odb.h +5 -2
  221. data/vendor/libgit2/src/odb_loose.c +31 -17
  222. data/vendor/libgit2/src/odb_pack.c +39 -43
  223. data/vendor/libgit2/src/oid.c +62 -27
  224. data/vendor/libgit2/src/oid.h +33 -0
  225. data/vendor/libgit2/src/oidmap.h +4 -6
  226. data/vendor/libgit2/src/pack-objects.c +54 -22
  227. data/vendor/libgit2/src/pack.c +98 -56
  228. data/vendor/libgit2/src/pack.h +3 -1
  229. data/vendor/libgit2/src/pathspec.c +26 -1
  230. data/vendor/libgit2/src/pathspec.h +14 -0
  231. data/vendor/libgit2/src/pool.c +5 -0
  232. data/vendor/libgit2/src/posix.c +2 -2
  233. data/vendor/libgit2/src/posix.h +3 -0
  234. data/vendor/libgit2/src/push.c +13 -10
  235. data/vendor/libgit2/src/refdb.c +82 -62
  236. data/vendor/libgit2/src/refdb.h +16 -16
  237. data/vendor/libgit2/src/refdb_fs.c +386 -133
  238. data/vendor/libgit2/src/reflog.c +3 -1
  239. data/vendor/libgit2/src/refs.c +247 -221
  240. data/vendor/libgit2/src/refs.h +2 -1
  241. data/vendor/libgit2/src/refspec.c +18 -1
  242. data/vendor/libgit2/src/refspec.h +3 -1
  243. data/vendor/libgit2/src/remote.c +434 -253
  244. data/vendor/libgit2/src/remote.h +5 -3
  245. data/vendor/libgit2/src/repository.c +197 -111
  246. data/vendor/libgit2/src/repository.h +26 -5
  247. data/vendor/libgit2/src/reset.c +1 -1
  248. data/vendor/libgit2/src/revparse.c +84 -79
  249. data/vendor/libgit2/src/revwalk.c +1 -1
  250. data/vendor/libgit2/src/signature.c +22 -10
  251. data/vendor/libgit2/src/stash.c +5 -2
  252. data/vendor/libgit2/src/status.c +311 -107
  253. data/vendor/libgit2/src/status.h +23 -0
  254. data/vendor/libgit2/src/submodule.c +21 -13
  255. data/vendor/libgit2/src/tag.c +42 -31
  256. data/vendor/libgit2/src/tag.h +2 -3
  257. data/vendor/libgit2/src/thread-utils.h +105 -3
  258. data/vendor/libgit2/src/trace.c +1 -2
  259. data/vendor/libgit2/src/trace.h +3 -3
  260. data/vendor/libgit2/src/transport.c +18 -6
  261. data/vendor/libgit2/src/transports/cred.c +103 -1
  262. data/vendor/libgit2/src/transports/local.c +19 -9
  263. data/vendor/libgit2/src/transports/smart_protocol.c +32 -12
  264. data/vendor/libgit2/src/transports/ssh.c +519 -0
  265. data/vendor/libgit2/src/transports/winhttp.c +3 -1
  266. data/vendor/libgit2/src/tree.c +26 -28
  267. data/vendor/libgit2/src/tree.h +3 -3
  268. data/vendor/libgit2/src/unix/posix.h +2 -0
  269. data/vendor/libgit2/src/util.c +43 -6
  270. data/vendor/libgit2/src/util.h +40 -12
  271. data/vendor/libgit2/src/vector.c +3 -5
  272. data/vendor/libgit2/src/vector.h +9 -0
  273. data/vendor/libgit2/src/win32/dir.c +1 -1
  274. data/vendor/libgit2/src/win32/error.c +2 -0
  275. data/vendor/libgit2/src/win32/findfile.c +3 -6
  276. data/vendor/libgit2/src/win32/posix_w32.c +85 -59
  277. data/vendor/libgit2/src/win32/pthread.c +16 -8
  278. data/vendor/libgit2/src/win32/pthread.h +7 -4
  279. metadata +407 -306
  280. data/test/coverage/HEAD.json +0 -1
  281. data/vendor/libgit2/include/git2/refdb_backend.h +0 -109
  282. data/vendor/libgit2/src/diff_output.c +0 -1819
  283. data/vendor/libgit2/src/diff_output.h +0 -93
@@ -103,10 +103,10 @@ GIT_EXTERN(void) git_libgit2_version(int *major, int *minor, int *rev);
103
103
  /**
104
104
  * Combinations of these values describe the capabilities of libgit2.
105
105
  */
106
- enum {
106
+ typedef enum {
107
107
  GIT_CAP_THREADS = ( 1 << 0 ),
108
108
  GIT_CAP_HTTPS = ( 1 << 1 )
109
- };
109
+ } git_cap_t;
110
110
 
111
111
  /**
112
112
  * Query compile time options for libgit2.
@@ -114,69 +114,100 @@ enum {
114
114
  * @return A combination of GIT_CAP_* values.
115
115
  *
116
116
  * - GIT_CAP_THREADS
117
- * Libgit2 was compiled with thread support. Note that thread support is still to be seen as a
118
- * 'work in progress'.
117
+ * Libgit2 was compiled with thread support. Note that thread support is
118
+ * still to be seen as a 'work in progress' - basic object lookups are
119
+ * believed to be threadsafe, but other operations may not be.
119
120
  *
120
121
  * - GIT_CAP_HTTPS
121
- * Libgit2 supports the https:// protocol. This requires the open ssl library to be
122
- * found when compiling libgit2.
122
+ * Libgit2 supports the https:// protocol. This requires the openssl
123
+ * library to be found when compiling libgit2.
123
124
  */
124
125
  GIT_EXTERN(int) git_libgit2_capabilities(void);
125
126
 
126
127
 
127
- enum {
128
+ typedef enum {
128
129
  GIT_OPT_GET_MWINDOW_SIZE,
129
130
  GIT_OPT_SET_MWINDOW_SIZE,
130
131
  GIT_OPT_GET_MWINDOW_MAPPED_LIMIT,
131
132
  GIT_OPT_SET_MWINDOW_MAPPED_LIMIT,
132
133
  GIT_OPT_GET_SEARCH_PATH,
133
134
  GIT_OPT_SET_SEARCH_PATH,
134
- GIT_OPT_GET_ODB_CACHE_SIZE,
135
- GIT_OPT_SET_ODB_CACHE_SIZE,
136
- };
135
+ GIT_OPT_SET_CACHE_OBJECT_LIMIT,
136
+ GIT_OPT_SET_CACHE_MAX_SIZE,
137
+ GIT_OPT_ENABLE_CACHING,
138
+ GIT_OPT_GET_CACHED_MEMORY
139
+ } git_libgit2_opt_t;
137
140
 
138
141
  /**
139
142
  * Set or query a library global option
140
143
  *
141
144
  * Available options:
142
145
  *
143
- * opts(GIT_OPT_GET_MWINDOW_SIZE, size_t *):
144
- * Get the maximum mmap window size
146
+ * * opts(GIT_OPT_GET_MWINDOW_SIZE, size_t *):
145
147
  *
146
- * opts(GIT_OPT_SET_MWINDOW_SIZE, size_t):
147
- * Set the maximum mmap window size
148
+ * > Get the maximum mmap window size
148
149
  *
149
- * opts(GIT_OPT_GET_MWINDOW_MAPPED_LIMIT, size_t *):
150
- * Get the maximum memory that will be mapped in total by the library
150
+ * * opts(GIT_OPT_SET_MWINDOW_SIZE, size_t):
151
151
  *
152
- * opts(GIT_OPT_SET_MWINDOW_MAPPED_LIMIT, size_t):
153
- * Set the maximum amount of memory that can be mapped at any time
152
+ * > Set the maximum mmap window size
153
+ *
154
+ * * opts(GIT_OPT_GET_MWINDOW_MAPPED_LIMIT, size_t *):
155
+ *
156
+ * > Get the maximum memory that will be mapped in total by the library
157
+ *
158
+ * * opts(GIT_OPT_SET_MWINDOW_MAPPED_LIMIT, size_t):
159
+ *
160
+ * >Set the maximum amount of memory that can be mapped at any time
154
161
  * by the library
155
162
  *
156
- * opts(GIT_OPT_GET_SEARCH_PATH, int level, char *out, size_t len)
157
- * Get the search path for a given level of config data. "level" must
158
- * be one of GIT_CONFIG_LEVEL_SYSTEM, GIT_CONFIG_LEVEL_GLOBAL, or
159
- * GIT_CONFIG_LEVEL_XDG. The search path is written to the `out`
160
- * buffer up to size `len`. Returns GIT_EBUFS if buffer is too small.
161
- *
162
- * opts(GIT_OPT_SET_SEARCH_PATH, int level, const char *path)
163
- * Set the search path for a level of config data. The search path
164
- * applied to shared attributes and ignore files, too.
165
- * - `path` lists directories delimited by GIT_PATH_LIST_SEPARATOR.
166
- * Pass NULL to reset to the default (generally based on environment
167
- * variables). Use magic path `$PATH` to include the old value
168
- * of the path (if you want to prepend or append, for instance).
169
- * - `level` must be GIT_CONFIG_LEVEL_SYSTEM, GIT_CONFIG_LEVEL_GLOBAL,
170
- * or GIT_CONFIG_LEVEL_XDG.
171
- *
172
- * opts(GIT_OPT_GET_ODB_CACHE_SIZE):
173
- * Get the size of the libgit2 odb cache.
174
- *
175
- * opts(GIT_OPT_SET_ODB_CACHE_SIZE):
176
- * Set the size of the of the libgit2 odb cache. This needs
177
- * to be done before git_repository_open is called, since
178
- * git_repository_open initializes the odb layer. Defaults
179
- * to 128.
163
+ * * opts(GIT_OPT_GET_SEARCH_PATH, int level, char *out, size_t len)
164
+ *
165
+ * > Get the search path for a given level of config data. "level" must
166
+ * > be one of `GIT_CONFIG_LEVEL_SYSTEM`, `GIT_CONFIG_LEVEL_GLOBAL`, or
167
+ * > `GIT_CONFIG_LEVEL_XDG`. The search path is written to the `out`
168
+ * > buffer up to size `len`. Returns GIT_EBUFS if buffer is too small.
169
+ *
170
+ * * opts(GIT_OPT_SET_SEARCH_PATH, int level, const char *path)
171
+ *
172
+ * > Set the search path for a level of config data. The search path
173
+ * > applied to shared attributes and ignore files, too.
174
+ * >
175
+ * > - `path` lists directories delimited by GIT_PATH_LIST_SEPARATOR.
176
+ * > Pass NULL to reset to the default (generally based on environment
177
+ * > variables). Use magic path `$PATH` to include the old value
178
+ * > of the path (if you want to prepend or append, for instance).
179
+ * >
180
+ * > - `level` must be GIT_CONFIG_LEVEL_SYSTEM, GIT_CONFIG_LEVEL_GLOBAL,
181
+ * > or GIT_CONFIG_LEVEL_XDG.
182
+ *
183
+ * * opts(GIT_OPT_SET_CACHE_OBJECT_LIMIT, git_otype type, size_t size)
184
+ *
185
+ * > Set the maximum data size for the given type of object to be
186
+ * > considered eligible for caching in memory. Setting to value to
187
+ * > zero means that that type of object will not be cached.
188
+ * > Defaults to 0 for GIT_OBJ_BLOB (i.e. won't cache blobs) and 4k
189
+ * > for GIT_OBJ_COMMIT, GIT_OBJ_TREE, and GIT_OBJ_TAG.
190
+ *
191
+ * * opts(GIT_OPT_SET_CACHE_MAX_SIZE, ssize_t max_storage_bytes)
192
+ *
193
+ * > Set the maximum total data size that will be cached in memory
194
+ * > across all repositories before libgit2 starts evicting objects
195
+ * > from the cache. This is a soft limit, in that the library might
196
+ * > briefly exceed it, but will start aggressively evicting objects
197
+ * > from cache when that happens. The default cache size is 256Mb.
198
+ *
199
+ * * opts(GIT_OPT_ENABLE_CACHING, int enabled)
200
+ *
201
+ * > Enable or disable caching completely.
202
+ * >
203
+ * > Because caches are repository-specific, disabling the cache
204
+ * > cannot immediately clear all cached objects, but each cache will
205
+ * > be cleared on the next attempt to update anything in it.
206
+ *
207
+ * * opts(GIT_OPT_GET_CACHED_MEMORY, ssize_t *current, ssize_t *allowed)
208
+ *
209
+ * > Get the current bytes in cache and the maximum that would be
210
+ * > allowed in the cache.
180
211
  *
181
212
  * @param option Option key
182
213
  * @param ... value to set the option
@@ -27,45 +27,41 @@ GIT_BEGIN_DECL
27
27
  * git_config_open_default() and git_repository_config() honor those
28
28
  * priority levels as well.
29
29
  */
30
- enum {
31
- GIT_CONFIG_LEVEL_SYSTEM = 1, /**< System-wide configuration file. */
32
- GIT_CONFIG_LEVEL_XDG = 2, /**< XDG compatible configuration file (.config/git/config). */
33
- GIT_CONFIG_LEVEL_GLOBAL = 3, /**< User-specific configuration file, also called Global configuration file. */
34
- GIT_CONFIG_LEVEL_LOCAL = 4, /**< Repository specific configuration file. */
35
- GIT_CONFIG_HIGHEST_LEVEL = -1, /**< Represents the highest level of a config file. */
36
- };
30
+ typedef enum {
31
+ /** System-wide configuration file; /etc/gitconfig on Linux systems */
32
+ GIT_CONFIG_LEVEL_SYSTEM = 1,
33
+
34
+ /** XDG compatible configuration file; typically ~/.config/git/config */
35
+ GIT_CONFIG_LEVEL_XDG = 2,
36
+
37
+ /** User-specific configuration file (also called Global configuration
38
+ * file); typically ~/.gitconfig
39
+ */
40
+ GIT_CONFIG_LEVEL_GLOBAL = 3,
41
+
42
+ /** Repository specific configuration file; $WORK_DIR/.git/config on
43
+ * non-bare repos
44
+ */
45
+ GIT_CONFIG_LEVEL_LOCAL = 4,
46
+
47
+ /** Application specific configuration file; freely defined by applications
48
+ */
49
+ GIT_CONFIG_LEVEL_APP = 5,
50
+
51
+ /** Represents the highest level available config file (i.e. the most
52
+ * specific config file available that actually is loaded)
53
+ */
54
+ GIT_CONFIG_HIGHEST_LEVEL = -1,
55
+ } git_config_level_t;
37
56
 
38
57
  typedef struct {
39
58
  const char *name;
40
59
  const char *value;
41
- unsigned int level;
60
+ git_config_level_t level;
42
61
  } git_config_entry;
43
62
 
44
63
  typedef int (*git_config_foreach_cb)(const git_config_entry *, void *);
45
64
 
46
-
47
- /**
48
- * Generic backend that implements the interface to
49
- * access a configuration file
50
- */
51
- struct git_config_backend {
52
- unsigned int version;
53
- struct git_config *cfg;
54
-
55
- /* Open means open the file/database and parse if necessary */
56
- int (*open)(struct git_config_backend *, unsigned int level);
57
- int (*get)(const struct git_config_backend *, const char *key, const git_config_entry **entry);
58
- int (*get_multivar)(struct git_config_backend *, const char *key, const char *regexp, git_config_foreach_cb callback, void *payload);
59
- int (*set)(struct git_config_backend *, const char *key, const char *value);
60
- int (*set_multivar)(git_config_backend *cfg, const char *name, const char *regexp, const char *value);
61
- int (*del)(struct git_config_backend *, const char *key);
62
- int (*foreach)(struct git_config_backend *, const char *, git_config_foreach_cb callback, void *payload);
63
- int (*refresh)(struct git_config_backend *);
64
- void (*free)(struct git_config_backend *);
65
- };
66
- #define GIT_CONFIG_BACKEND_VERSION 1
67
- #define GIT_CONFIG_BACKEND_INIT {GIT_CONFIG_BACKEND_VERSION}
68
-
69
65
  typedef enum {
70
66
  GIT_CVAR_FALSE = 0,
71
67
  GIT_CVAR_TRUE = 1,
@@ -123,7 +119,7 @@ GIT_EXTERN(int) git_config_find_xdg(char *out, size_t length);
123
119
  * If /etc/gitconfig doesn't exist, it will look for
124
120
  * %PROGRAMFILES%\Git\etc\gitconfig.
125
121
 
126
- * @param global_config_path Buffer to store the path in
122
+ * @param out Buffer to store the path in
127
123
  * @param length size of the buffer in bytes
128
124
  * @return 0 if a system configuration file has been
129
125
  * found. Its path will be stored in `buffer`.
@@ -153,30 +149,6 @@ GIT_EXTERN(int) git_config_open_default(git_config **out);
153
149
  */
154
150
  GIT_EXTERN(int) git_config_new(git_config **out);
155
151
 
156
- /**
157
- * Add a generic config file instance to an existing config
158
- *
159
- * Note that the configuration object will free the file
160
- * automatically.
161
- *
162
- * Further queries on this config object will access each
163
- * of the config file instances in order (instances with
164
- * a higher priority level will be accessed first).
165
- *
166
- * @param cfg the configuration to add the file to
167
- * @param file the configuration file (backend) to add
168
- * @param level the priority level of the backend
169
- * @param force if a config file already exists for the given
170
- * priority level, replace it
171
- * @return 0 on success, GIT_EEXISTS when adding more than one file
172
- * for a given priority level (and force_replace set to 0), or error code
173
- */
174
- GIT_EXTERN(int) git_config_add_backend(
175
- git_config *cfg,
176
- git_config_backend *file,
177
- unsigned int level,
178
- int force);
179
-
180
152
  /**
181
153
  * Add an on-disk config file instance to an existing config
182
154
  *
@@ -192,10 +164,9 @@ GIT_EXTERN(int) git_config_add_backend(
192
164
  * a higher priority level will be accessed first).
193
165
  *
194
166
  * @param cfg the configuration to add the file to
195
- * @param path path to the configuration file (backend) to add
167
+ * @param path path to the configuration file to add
196
168
  * @param level the priority level of the backend
197
- * @param force if a config file already exists for the given
198
- * priority level, replace it
169
+ * @param force replace config file at the given priority level
199
170
  * @return 0 on success, GIT_EEXISTS when adding more than one file
200
171
  * for a given priority level (and force_replace set to 0),
201
172
  * GIT_ENOTFOUND when the file doesn't exist or error code
@@ -203,7 +174,7 @@ GIT_EXTERN(int) git_config_add_backend(
203
174
  GIT_EXTERN(int) git_config_add_file_ondisk(
204
175
  git_config *cfg,
205
176
  const char *path,
206
- unsigned int level,
177
+ git_config_level_t level,
207
178
  int force);
208
179
 
209
180
  /**
@@ -238,9 +209,24 @@ GIT_EXTERN(int) git_config_open_ondisk(git_config **out, const char *path);
238
209
  * multi-level parent config, or an error code
239
210
  */
240
211
  GIT_EXTERN(int) git_config_open_level(
241
- git_config **out,
242
- const git_config *parent,
243
- unsigned int level);
212
+ git_config **out,
213
+ const git_config *parent,
214
+ git_config_level_t level);
215
+
216
+ /**
217
+ * Open the global/XDG configuration file according to git's rules
218
+ *
219
+ * Git allows you to store your global configuration at
220
+ * `$HOME/.config` or `$XDG_CONFIG_HOME/git/config`. For backwards
221
+ * compatability, the XDG file shouldn't be used unless the use has
222
+ * created it explicitly. With this function you'll open the correct
223
+ * one to write to.
224
+ *
225
+ * @param out pointer in which to store the config object
226
+ * @param config the config object in which to look
227
+ */
228
+ GIT_EXTERN(int) git_config_open_global(git_config **out, git_config *config);
229
+
244
230
 
245
231
  /**
246
232
  * Reload changed config files
@@ -274,7 +260,7 @@ GIT_EXTERN(void) git_config_free(git_config *cfg);
274
260
  * @return 0 or an error code
275
261
  */
276
262
  GIT_EXTERN(int) git_config_get_entry(
277
- const git_config_entry **out,
263
+ const git_config_entry **out,
278
264
  const git_config *cfg,
279
265
  const char *name);
280
266
 
@@ -349,8 +335,8 @@ GIT_EXTERN(int) git_config_get_string(const char **out, const git_config *cfg, c
349
335
  * @param name the variable's name
350
336
  * @param regexp regular expression to filter which variables we're
351
337
  * interested in. Use NULL to indicate all
352
- * @param fn the function to be called on each value of the variable
353
- * @param data opaque pointer to pass to the callback
338
+ * @param callback the function to be called on each value of the variable
339
+ * @param payload opaque pointer to pass to the callback
354
340
  */
355
341
  GIT_EXTERN(int) git_config_get_multivar(const git_config *cfg, const char *name, const char *regexp, git_config_foreach_cb callback, void *payload);
356
342
 
@@ -492,11 +478,11 @@ GIT_EXTERN(int) git_config_foreach_match(
492
478
  * @return 0 on success, error code otherwise
493
479
  */
494
480
  GIT_EXTERN(int) git_config_get_mapped(
495
- int *out,
496
- const git_config *cfg,
497
- const char *name,
498
- const git_cvar_map *maps,
499
- size_t map_n);
481
+ int *out,
482
+ const git_config *cfg,
483
+ const char *name,
484
+ const git_cvar_map *maps,
485
+ size_t map_n);
500
486
 
501
487
  /**
502
488
  * Maps a string value to an integer constant
@@ -30,11 +30,11 @@ typedef struct git_cred_userpass_payload {
30
30
  /**
31
31
  * Stock callback usable as a git_cred_acquire_cb. This calls
32
32
  * git_cred_userpass_plaintext_new unless the protocol has not specified
33
- * GIT_CREDTYPE_USERPASS_PLAINTEXT as an allowed type.
33
+ * `GIT_CREDTYPE_USERPASS_PLAINTEXT` as an allowed type.
34
34
  *
35
35
  * @param cred The newly created credential object.
36
36
  * @param url The resource for which we are demanding a credential.
37
- * @param username_from_url The username that was embedded in a "user@host"
37
+ * @param user_from_url The username that was embedded in a "user@host"
38
38
  * remote url, or NULL if not included.
39
39
  * @param allowed_types A bitmask stating which cred types are OK to return.
40
40
  * @param payload The payload provided when specifying this callback. (This is
@@ -88,42 +88,69 @@ typedef enum {
88
88
  GIT_DIFF_INCLUDE_UNTRACKED = (1 << 8),
89
89
  /** Include unmodified files in the diff list */
90
90
  GIT_DIFF_INCLUDE_UNMODIFIED = (1 << 9),
91
- /** Even with GIT_DIFF_INCLUDE_UNTRACKED, an entire untracked directory
92
- * will be marked with only a single entry in the diff list; this flag
93
- * adds all files under the directory as UNTRACKED entries, too.
91
+
92
+ /** Even with GIT_DIFF_INCLUDE_UNTRACKED, an entire untracked
93
+ * directory will be marked with only a single entry in the diff list
94
+ * (a la what core Git does in `git status`); this flag adds *all*
95
+ * files under untracked directories as UNTRACKED entries, too.
94
96
  */
95
97
  GIT_DIFF_RECURSE_UNTRACKED_DIRS = (1 << 10),
98
+
96
99
  /** If the pathspec is set in the diff options, this flags means to
97
100
  * apply it as an exact match instead of as an fnmatch pattern.
98
101
  */
99
102
  GIT_DIFF_DISABLE_PATHSPEC_MATCH = (1 << 11),
103
+
100
104
  /** Use case insensitive filename comparisons */
101
105
  GIT_DIFF_DELTAS_ARE_ICASE = (1 << 12),
102
- /** When generating patch text, include the content of untracked files */
106
+
107
+ /** When generating patch text, include the content of untracked
108
+ * files. This automatically turns on GIT_DIFF_INCLUDE_UNTRACKED but
109
+ * it does not turn on GIT_DIFF_RECURSE_UNTRACKED_DIRS. Add that
110
+ * flag if you want the content of every single UNTRACKED file.
111
+ */
103
112
  GIT_DIFF_INCLUDE_UNTRACKED_CONTENT = (1 << 13),
113
+
104
114
  /** Disable updating of the `binary` flag in delta records. This is
105
115
  * useful when iterating over a diff if you don't need hunk and data
106
116
  * callbacks and want to avoid having to load file completely.
107
117
  */
108
118
  GIT_DIFF_SKIP_BINARY_CHECK = (1 << 14),
119
+
109
120
  /** Normally, a type change between files will be converted into a
110
121
  * DELETED record for the old and an ADDED record for the new; this
111
122
  * options enabled the generation of TYPECHANGE delta records.
112
123
  */
113
124
  GIT_DIFF_INCLUDE_TYPECHANGE = (1 << 15),
125
+
114
126
  /** Even with GIT_DIFF_INCLUDE_TYPECHANGE, blob->tree changes still
115
127
  * generally show as a DELETED blob. This flag tries to correctly
116
128
  * label blob->tree transitions as TYPECHANGE records with new_file's
117
129
  * mode set to tree. Note: the tree SHA will not be available.
118
130
  */
119
131
  GIT_DIFF_INCLUDE_TYPECHANGE_TREES = (1 << 16),
132
+
120
133
  /** Ignore file mode changes */
121
134
  GIT_DIFF_IGNORE_FILEMODE = (1 << 17),
135
+
122
136
  /** Even with GIT_DIFF_INCLUDE_IGNORED, an entire ignored directory
123
137
  * will be marked with only a single entry in the diff list; this flag
124
138
  * adds all files under the directory as IGNORED entries, too.
125
139
  */
126
140
  GIT_DIFF_RECURSE_IGNORED_DIRS = (1 << 18),
141
+
142
+ /** Core Git scans inside untracked directories, labeling them IGNORED
143
+ * if they are empty or only contain ignored files; a directory is
144
+ * consider UNTRACKED only if it has an actual untracked file in it.
145
+ * This scan is extra work for a case you often don't care about. This
146
+ * flag makes libgit2 immediately label an untracked directory as
147
+ * UNTRACKED without looking inside it (which differs from core Git).
148
+ * Of course, ignore rules are still checked for the directory itself.
149
+ */
150
+ GIT_DIFF_FAST_UNTRACKED_DIRS = (1 << 19),
151
+
152
+ /** Treat all files as binary, disabling text diffs */
153
+ GIT_DIFF_FORCE_BINARY = (1 << 20),
127
154
  } git_diff_option_t;
128
155
 
129
156
  /**
@@ -224,6 +251,19 @@ typedef struct {
224
251
  * `NOT_BINARY` flag set to avoid examining file contents if you do not pass
225
252
  * in hunk and/or line callbacks to the diff foreach iteration function. It
226
253
  * will just use the git attributes for those files.
254
+ *
255
+ * The similarity score is zero unless you call `git_diff_find_similar()`
256
+ * which does a similarity analysis of files in the diff. Use that
257
+ * function to do rename and copy detection, and to split heavily modified
258
+ * files in add/delete pairs. After that call, deltas with a status of
259
+ * GIT_DELTA_RENAMED or GIT_DELTA_COPIED will have a similarity score
260
+ * between 0 and 100 indicating how similar the old and new sides are.
261
+ *
262
+ * If you ask `git_diff_find_similar` to find heavily modified files to
263
+ * break, but to not *actually* break the records, then GIT_DELTA_MODIFIED
264
+ * records may have a non-zero similarity score if the self-similarity is
265
+ * below the split threshold. To display this value like core Git, invert
266
+ * the score (a la `printf("M%03d", 100 - delta->similarity)`).
227
267
  */
228
268
  typedef struct {
229
269
  git_diff_file old_file;
@@ -337,8 +377,10 @@ typedef enum {
337
377
  GIT_DIFF_LINE_CONTEXT = ' ',
338
378
  GIT_DIFF_LINE_ADDITION = '+',
339
379
  GIT_DIFF_LINE_DELETION = '-',
340
- GIT_DIFF_LINE_ADD_EOFNL = '\n', /**< Removed line w/o LF & added one with */
341
- GIT_DIFF_LINE_DEL_EOFNL = '\0', /**< LF was removed at end of file */
380
+
381
+ GIT_DIFF_LINE_CONTEXT_EOFNL = '=', /**< Both files have no LF at end */
382
+ GIT_DIFF_LINE_ADD_EOFNL = '>', /**< Old has no LF at end, new does */
383
+ GIT_DIFF_LINE_DEL_EOFNL = '<', /**< Old has LF at end, new does not */
342
384
 
343
385
  /* The following values will only be sent to a `git_diff_data_cb` when
344
386
  * the content of a diff is being formatted (eg. through
@@ -387,18 +429,28 @@ typedef enum {
387
429
  /** consider unmodified as copy sources? (`--find-copies-harder`) */
388
430
  GIT_DIFF_FIND_COPIES_FROM_UNMODIFIED = (1 << 3),
389
431
 
390
- /** split large rewrites into delete/add pairs (`--break-rewrites=/M`) */
391
- GIT_DIFF_FIND_AND_BREAK_REWRITES = (1 << 4),
432
+ /** mark large rewrites for split (`--break-rewrites=/M`) */
433
+ GIT_DIFF_FIND_REWRITES = (1 << 4),
434
+ /** actually split large rewrites into delete/add pairs */
435
+ GIT_DIFF_BREAK_REWRITES = (1 << 5),
436
+ /** mark rewrites for split and break into delete/add pairs */
437
+ GIT_DIFF_FIND_AND_BREAK_REWRITES =
438
+ (GIT_DIFF_FIND_REWRITES | GIT_DIFF_BREAK_REWRITES),
439
+
440
+ /** find renames/copies for untracked items in working directory */
441
+ GIT_DIFF_FIND_FOR_UNTRACKED = (1 << 6),
392
442
 
393
443
  /** turn on all finding features */
394
- GIT_DIFF_FIND_ALL = (0x1f),
444
+ GIT_DIFF_FIND_ALL = (0x0ff),
395
445
 
396
446
  /** measure similarity ignoring leading whitespace (default) */
397
447
  GIT_DIFF_FIND_IGNORE_LEADING_WHITESPACE = 0,
398
448
  /** measure similarity ignoring all whitespace */
399
- GIT_DIFF_FIND_IGNORE_WHITESPACE = (1 << 6),
449
+ GIT_DIFF_FIND_IGNORE_WHITESPACE = (1 << 12),
400
450
  /** measure similarity including all data */
401
- GIT_DIFF_FIND_DONT_IGNORE_WHITESPACE = (1 << 7),
451
+ GIT_DIFF_FIND_DONT_IGNORE_WHITESPACE = (1 << 13),
452
+ /** measure similarity only by comparing SHAs (fast and cheap) */
453
+ GIT_DIFF_FIND_EXACT_MATCH_ONLY = (1 << 14),
402
454
  } git_diff_find_t;
403
455
 
404
456
  /**
@@ -425,7 +477,10 @@ typedef struct {
425
477
  * - `copy_threshold` is the same as the -C option with a value
426
478
  * - `rename_from_rewrite_threshold` matches the top of the -B option
427
479
  * - `break_rewrite_threshold` matches the bottom of the -B option
428
- * - `target_limit` matches the -l option
480
+ * - `rename_limit` is the maximum number of matches to consider for
481
+ * a particular file. This is a little different from the `-l` option
482
+ * to regular Git because we will still process up to this many matches
483
+ * before abandoning the search.
429
484
  *
430
485
  * The `metric` option allows you to plug in a custom similarity metric.
431
486
  * Set it to NULL for the default internal metric which is based on sampling
@@ -437,21 +492,21 @@ typedef struct {
437
492
  unsigned int version;
438
493
 
439
494
  /** Combination of git_diff_find_t values (default FIND_RENAMES) */
440
- unsigned int flags;
495
+ uint32_t flags;
441
496
 
442
497
  /** Similarity to consider a file renamed (default 50) */
443
- unsigned int rename_threshold;
498
+ uint16_t rename_threshold;
444
499
  /** Similarity of modified to be eligible rename source (default 50) */
445
- unsigned int rename_from_rewrite_threshold;
500
+ uint16_t rename_from_rewrite_threshold;
446
501
  /** Similarity to consider a file a copy (default 50) */
447
- unsigned int copy_threshold;
502
+ uint16_t copy_threshold;
448
503
  /** Similarity to split modify into delete/add pair (default 60) */
449
- unsigned int break_rewrite_threshold;
504
+ uint16_t break_rewrite_threshold;
450
505
 
451
- /** Maximum similarity sources to examine (a la diff's `-l` option or
452
- * the `diff.renameLimit` config) (default 200)
506
+ /** Maximum similarity sources to examine for a file (somewhat like
507
+ * git-diff's `-l` option or `diff.renameLimit` config) (default 200)
453
508
  */
454
- unsigned int target_limit;
509
+ size_t rename_limit;
455
510
 
456
511
  /** Pluggable similarity metric; pass NULL to use internal metric */
457
512
  git_diff_similarity_metric *metric;
@@ -469,6 +524,8 @@ typedef struct {
469
524
 
470
525
  /**
471
526
  * Deallocate a diff list.
527
+ *
528
+ * @param diff The previously created diff list; cannot be used after free.
472
529
  */
473
530
  GIT_EXTERN(void) git_diff_list_free(git_diff_list *diff);
474
531
 
@@ -478,12 +535,14 @@ GIT_EXTERN(void) git_diff_list_free(git_diff_list *diff);
478
535
  * This is equivalent to `git diff <old-tree> <new-tree>`
479
536
  *
480
537
  * The first tree will be used for the "old_file" side of the delta and the
481
- * second tree will be used for the "new_file" side of the delta.
538
+ * second tree will be used for the "new_file" side of the delta. You can
539
+ * pass NULL to indicate an empty tree, although it is an error to pass
540
+ * NULL for both the `old_tree` and `new_tree`.
482
541
  *
483
542
  * @param diff Output pointer to a git_diff_list pointer to be allocated.
484
543
  * @param repo The repository containing the trees.
485
- * @param old_tree A git_tree object to diff from.
486
- * @param new_tree A git_tree object to diff to.
544
+ * @param old_tree A git_tree object to diff from, or NULL for empty tree.
545
+ * @param new_tree A git_tree object to diff to, or NULL for empty tree.
487
546
  * @param opts Structure with options to influence diff or NULL for defaults.
488
547
  */
489
548
  GIT_EXTERN(int) git_diff_tree_to_tree(
@@ -504,7 +563,7 @@ GIT_EXTERN(int) git_diff_tree_to_tree(
504
563
  *
505
564
  * @param diff Output pointer to a git_diff_list pointer to be allocated.
506
565
  * @param repo The repository containing the tree and index.
507
- * @param old_tree A git_tree object to diff from.
566
+ * @param old_tree A git_tree object to diff from, or NULL for empty tree.
508
567
  * @param index The index to diff with; repo index used if NULL.
509
568
  * @param opts Structure with options to influence diff or NULL for defaults.
510
569
  */
@@ -563,7 +622,7 @@ GIT_EXTERN(int) git_diff_index_to_workdir(
563
622
  *
564
623
  * @param diff A pointer to a git_diff_list pointer that will be allocated.
565
624
  * @param repo The repository containing the tree.
566
- * @param old_tree A git_tree object to diff from.
625
+ * @param old_tree A git_tree object to diff from, or NULL for empty tree.
567
626
  * @param opts Structure with options to influence diff or NULL for defaults.
568
627
  */
569
628
  GIT_EXTERN(int) git_diff_tree_to_workdir(
@@ -663,6 +722,22 @@ GIT_EXTERN(int) git_diff_print_compact(
663
722
  git_diff_data_cb print_cb,
664
723
  void *payload);
665
724
 
725
+ /**
726
+ * Iterate over a diff generating text output like "git diff --raw".
727
+ *
728
+ * Returning a non-zero value from the callbacks will terminate the
729
+ * iteration and cause this return `GIT_EUSER`.
730
+ *
731
+ * @param diff A git_diff_list generated by one of the above functions.
732
+ * @param print_cb Callback to make per line of diff text.
733
+ * @param payload Reference pointer that will be passed to your callback.
734
+ * @return 0 on success, GIT_EUSER on non-zero callback, or error code
735
+ */
736
+ GIT_EXTERN(int) git_diff_print_raw(
737
+ git_diff_list *diff,
738
+ git_diff_data_cb print_cb,
739
+ void *payload);
740
+
666
741
  /**
667
742
  * Look up the single character abbreviation for a delta status code.
668
743
  *
@@ -672,7 +747,7 @@ GIT_EXTERN(int) git_diff_print_compact(
672
747
  * letters for your own purposes. This function does just that. By the
673
748
  * way, unmodified will return a space (i.e. ' ').
674
749
  *
675
- * @param delta_t The git_delta_t value to look up
750
+ * @param status The git_delta_t value to look up
676
751
  * @return The single character label for that code
677
752
  */
678
753
  GIT_EXTERN(char) git_diff_status_char(git_delta_t status);
@@ -785,7 +860,7 @@ GIT_EXTERN(size_t) git_diff_patch_num_hunks(
785
860
  * @param total_additions Count of addition lines in output, can be NULL.
786
861
  * @param total_deletions Count of deletion lines in output, can be NULL.
787
862
  * @param patch The git_diff_patch object
788
- * @return Number of lines in hunk or -1 if invalid hunk index
863
+ * @return 0 on success, <0 on error
789
864
  */
790
865
  GIT_EXTERN(int) git_diff_patch_line_stats(
791
866
  size_t *total_context,
@@ -843,7 +918,7 @@ GIT_EXTERN(int) git_diff_patch_num_lines_in_hunk(
843
918
  * @param new_lineno Line number in new file or -1 if line is deleted
844
919
  * @param patch The patch to look in
845
920
  * @param hunk_idx The index of the hunk
846
- * @param line_of_index The index of the line in the hunk
921
+ * @param line_of_hunk The index of the line in the hunk
847
922
  * @return 0 on success, <0 on failure
848
923
  */
849
924
  GIT_EXTERN(int) git_diff_patch_get_line_in_hunk(
@@ -907,17 +982,52 @@ GIT_EXTERN(int) git_diff_patch_to_str(
907
982
  * to 1 and no call to the hunk_cb nor line_cb will be made (unless you pass
908
983
  * `GIT_DIFF_FORCE_TEXT` of course).
909
984
  *
910
- * @return 0 on success, GIT_EUSER on non-zero callback, or error code
985
+ * @param old_blob Blob for old side of diff, or NULL for empty blob
986
+ * @param old_as_path Treat old blob as if it had this filename; can be NULL
987
+ * @param new_blob Blob for new side of diff, or NULL for empty blob
988
+ * @param new_as_path Treat new blob as if it had this filename; can be NULL
989
+ * @param options Options for diff, or NULL for default options
990
+ * @param file_cb Callback for "file"; made once if there is a diff; can be NULL
991
+ * @param hunk_cb Callback for each hunk in diff; can be NULL
992
+ * @param line_cb Callback for each line in diff; can be NULL
993
+ * @param payload Payload passed to each callback function
994
+ * @return 0 on success, GIT_EUSER on non-zero callback return, or error code
911
995
  */
912
996
  GIT_EXTERN(int) git_diff_blobs(
913
997
  const git_blob *old_blob,
998
+ const char *old_as_path,
914
999
  const git_blob *new_blob,
1000
+ const char *new_as_path,
915
1001
  const git_diff_options *options,
916
1002
  git_diff_file_cb file_cb,
917
1003
  git_diff_hunk_cb hunk_cb,
918
1004
  git_diff_data_cb line_cb,
919
1005
  void *payload);
920
1006
 
1007
+ /**
1008
+ * Directly generate a patch from the difference between two blobs.
1009
+ *
1010
+ * This is just like `git_diff_blobs()` except it generates a patch object
1011
+ * for the difference instead of directly making callbacks. You can use the
1012
+ * standard `git_diff_patch` accessor functions to read the patch data, and
1013
+ * you must call `git_diff_patch_free()` on the patch when done.
1014
+ *
1015
+ * @param out The generated patch; NULL on error
1016
+ * @param old_blob Blob for old side of diff, or NULL for empty blob
1017
+ * @param old_as_path Treat old blob as if it had this filename; can be NULL
1018
+ * @param new_blob Blob for new side of diff, or NULL for empty blob
1019
+ * @param new_as_path Treat new blob as if it had this filename; can be NULL
1020
+ * @param opts Options for diff, or NULL for default options
1021
+ * @return 0 on success or error code < 0
1022
+ */
1023
+ GIT_EXTERN(int) git_diff_patch_from_blobs(
1024
+ git_diff_patch **out,
1025
+ const git_blob *old_blob,
1026
+ const char *old_as_path,
1027
+ const git_blob *new_blob,
1028
+ const char *new_as_path,
1029
+ const git_diff_options *opts);
1030
+
921
1031
  /**
922
1032
  * Directly run a diff between a blob and a buffer.
923
1033
  *
@@ -930,18 +1040,57 @@ GIT_EXTERN(int) git_diff_blobs(
930
1040
  * entire content of the buffer added). Passing NULL to the buffer will do
931
1041
  * the reverse, with GIT_DELTA_REMOVED and blob content removed.
932
1042
  *
933
- * @return 0 on success, GIT_EUSER on non-zero callback, or error code
1043
+ * @param old_blob Blob for old side of diff, or NULL for empty blob
1044
+ * @param old_as_path Treat old blob as if it had this filename; can be NULL
1045
+ * @param buffer Raw data for new side of diff, or NULL for empty
1046
+ * @param buffer_len Length of raw data for new side of diff
1047
+ * @param buffer_as_path Treat buffer as if it had this filename; can be NULL
1048
+ * @param options Options for diff, or NULL for default options
1049
+ * @param file_cb Callback for "file"; made once if there is a diff; can be NULL
1050
+ * @param hunk_cb Callback for each hunk in diff; can be NULL
1051
+ * @param data_cb Callback for each line in diff; can be NULL
1052
+ * @param payload Payload passed to each callback function
1053
+ * @return 0 on success, GIT_EUSER on non-zero callback return, or error code
934
1054
  */
935
1055
  GIT_EXTERN(int) git_diff_blob_to_buffer(
936
1056
  const git_blob *old_blob,
1057
+ const char *old_as_path,
937
1058
  const char *buffer,
938
1059
  size_t buffer_len,
1060
+ const char *buffer_as_path,
939
1061
  const git_diff_options *options,
940
1062
  git_diff_file_cb file_cb,
941
1063
  git_diff_hunk_cb hunk_cb,
942
1064
  git_diff_data_cb data_cb,
943
1065
  void *payload);
944
1066
 
1067
+ /**
1068
+ * Directly generate a patch from the difference between a blob and a buffer.
1069
+ *
1070
+ * This is just like `git_diff_blob_to_buffer()` except it generates a patch
1071
+ * object for the difference instead of directly making callbacks. You can
1072
+ * use the standard `git_diff_patch` accessor functions to read the patch
1073
+ * data, and you must call `git_diff_patch_free()` on the patch when done.
1074
+ *
1075
+ * @param out The generated patch; NULL on error
1076
+ * @param old_blob Blob for old side of diff, or NULL for empty blob
1077
+ * @param old_as_path Treat old blob as if it had this filename; can be NULL
1078
+ * @param buffer Raw data for new side of diff, or NULL for empty
1079
+ * @param buffer_len Length of raw data for new side of diff
1080
+ * @param buffer_as_path Treat buffer as if it had this filename; can be NULL
1081
+ * @param opts Options for diff, or NULL for default options
1082
+ * @return 0 on success or error code < 0
1083
+ */
1084
+ GIT_EXTERN(int) git_diff_patch_from_blob_and_buffer(
1085
+ git_diff_patch **out,
1086
+ const git_blob *old_blob,
1087
+ const char *old_as_path,
1088
+ const char *buffer,
1089
+ size_t buffer_len,
1090
+ const char *buffer_as_path,
1091
+ const git_diff_options *opts);
1092
+
1093
+
945
1094
  GIT_END_DECL
946
1095
 
947
1096
  /** @} */