rugged 0.27.10.1 → 0.28.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (297) hide show
  1. checksums.yaml +4 -4
  2. data/ext/rugged/extconf.rb +23 -2
  3. data/ext/rugged/rugged.c +48 -2
  4. data/ext/rugged/rugged.h +5 -0
  5. data/ext/rugged/rugged_allocator.c +89 -0
  6. data/ext/rugged/rugged_blob.c +3 -3
  7. data/ext/rugged/rugged_branch.c +1 -1
  8. data/ext/rugged/rugged_commit.c +8 -8
  9. data/ext/rugged/rugged_config.c +1 -1
  10. data/ext/rugged/rugged_diff.c +24 -4
  11. data/ext/rugged/rugged_note.c +1 -1
  12. data/ext/rugged/rugged_repo.c +10 -10
  13. data/ext/rugged/rugged_settings.c +1 -1
  14. data/lib/rugged/version.rb +1 -1
  15. data/vendor/libgit2/CMakeLists.txt +69 -47
  16. data/vendor/libgit2/cmake/Modules/AddCFlagIfSupported.cmake +15 -1
  17. data/vendor/libgit2/cmake/Modules/EnableWarnings.cmake +5 -8
  18. data/vendor/libgit2/cmake/Modules/FindmbedTLS.cmake +93 -0
  19. data/vendor/libgit2/deps/http-parser/CMakeLists.txt +2 -0
  20. data/vendor/libgit2/deps/http-parser/{LICENSE-MIT → COPYING} +0 -0
  21. data/vendor/libgit2/deps/regex/COPYING +502 -0
  22. data/vendor/libgit2/deps/winhttp/COPYING.GPL +993 -0
  23. data/vendor/libgit2/deps/winhttp/COPYING.LGPL +502 -0
  24. data/vendor/libgit2/deps/zlib/CMakeLists.txt +1 -0
  25. data/vendor/libgit2/deps/zlib/COPYING +27 -0
  26. data/vendor/libgit2/include/git2.h +3 -0
  27. data/vendor/libgit2/include/git2/annotated_commit.h +9 -0
  28. data/vendor/libgit2/include/git2/apply.h +129 -0
  29. data/vendor/libgit2/include/git2/attr.h +19 -8
  30. data/vendor/libgit2/include/git2/blame.h +41 -24
  31. data/vendor/libgit2/include/git2/blob.h +1 -1
  32. data/vendor/libgit2/include/git2/branch.h +1 -1
  33. data/vendor/libgit2/include/git2/buffer.h +2 -2
  34. data/vendor/libgit2/include/git2/checkout.h +20 -19
  35. data/vendor/libgit2/include/git2/cherrypick.h +6 -4
  36. data/vendor/libgit2/include/git2/clone.h +11 -9
  37. data/vendor/libgit2/include/git2/commit.h +30 -2
  38. data/vendor/libgit2/include/git2/common.h +54 -4
  39. data/vendor/libgit2/include/git2/config.h +18 -7
  40. data/vendor/libgit2/include/git2/deprecated.h +253 -0
  41. data/vendor/libgit2/include/git2/describe.h +30 -7
  42. data/vendor/libgit2/include/git2/diff.h +193 -143
  43. data/vendor/libgit2/include/git2/errors.h +54 -46
  44. data/vendor/libgit2/include/git2/ignore.h +2 -2
  45. data/vendor/libgit2/include/git2/index.h +72 -51
  46. data/vendor/libgit2/include/git2/indexer.h +30 -4
  47. data/vendor/libgit2/include/git2/mailmap.h +115 -0
  48. data/vendor/libgit2/include/git2/merge.h +29 -8
  49. data/vendor/libgit2/include/git2/net.h +1 -1
  50. data/vendor/libgit2/include/git2/notes.h +1 -1
  51. data/vendor/libgit2/include/git2/object.h +16 -16
  52. data/vendor/libgit2/include/git2/odb.h +10 -10
  53. data/vendor/libgit2/include/git2/odb_backend.h +7 -7
  54. data/vendor/libgit2/include/git2/oid.h +1 -1
  55. data/vendor/libgit2/include/git2/pack.h +2 -2
  56. data/vendor/libgit2/include/git2/proxy.h +9 -5
  57. data/vendor/libgit2/include/git2/rebase.h +7 -4
  58. data/vendor/libgit2/include/git2/refs.h +14 -15
  59. data/vendor/libgit2/include/git2/refspec.h +17 -0
  60. data/vendor/libgit2/include/git2/remote.h +92 -16
  61. data/vendor/libgit2/include/git2/repository.h +52 -37
  62. data/vendor/libgit2/include/git2/revert.h +5 -3
  63. data/vendor/libgit2/include/git2/revwalk.h +7 -7
  64. data/vendor/libgit2/include/git2/signature.h +2 -2
  65. data/vendor/libgit2/include/git2/stash.h +13 -10
  66. data/vendor/libgit2/include/git2/status.h +8 -4
  67. data/vendor/libgit2/include/git2/submodule.h +11 -10
  68. data/vendor/libgit2/include/git2/sys/alloc.h +101 -0
  69. data/vendor/libgit2/include/git2/sys/commit.h +1 -1
  70. data/vendor/libgit2/include/git2/sys/config.h +13 -13
  71. data/vendor/libgit2/include/git2/sys/filter.h +6 -6
  72. data/vendor/libgit2/include/git2/sys/index.h +3 -0
  73. data/vendor/libgit2/include/git2/sys/mempack.h +35 -35
  74. data/vendor/libgit2/include/git2/sys/merge.h +9 -4
  75. data/vendor/libgit2/include/git2/sys/odb_backend.h +19 -19
  76. data/vendor/libgit2/include/git2/sys/path.h +64 -0
  77. data/vendor/libgit2/include/git2/sys/refdb_backend.h +19 -19
  78. data/vendor/libgit2/include/git2/sys/stream.h +92 -12
  79. data/vendor/libgit2/include/git2/sys/transport.h +127 -81
  80. data/vendor/libgit2/include/git2/tag.h +2 -2
  81. data/vendor/libgit2/include/git2/trace.h +1 -1
  82. data/vendor/libgit2/include/git2/transaction.h +1 -0
  83. data/vendor/libgit2/include/git2/transport.h +47 -18
  84. data/vendor/libgit2/include/git2/tree.h +3 -3
  85. data/vendor/libgit2/include/git2/types.h +35 -28
  86. data/vendor/libgit2/include/git2/version.h +4 -4
  87. data/vendor/libgit2/include/git2/worktree.h +47 -12
  88. data/vendor/libgit2/src/CMakeLists.txt +87 -26
  89. data/vendor/libgit2/src/alloc.c +55 -0
  90. data/vendor/libgit2/src/alloc.h +40 -0
  91. data/vendor/libgit2/src/annotated_commit.c +15 -8
  92. data/vendor/libgit2/src/apply.c +490 -14
  93. data/vendor/libgit2/src/apply.h +3 -1
  94. data/vendor/libgit2/src/array.h +2 -2
  95. data/vendor/libgit2/src/attr.c +11 -11
  96. data/vendor/libgit2/src/attr_file.c +20 -15
  97. data/vendor/libgit2/src/attrcache.c +11 -11
  98. data/vendor/libgit2/src/blame.c +30 -15
  99. data/vendor/libgit2/src/blame.h +1 -0
  100. data/vendor/libgit2/src/blame_git.c +16 -13
  101. data/vendor/libgit2/src/blob.c +50 -28
  102. data/vendor/libgit2/src/blob.h +18 -1
  103. data/vendor/libgit2/src/branch.c +38 -38
  104. data/vendor/libgit2/src/buf_text.c +7 -6
  105. data/vendor/libgit2/src/buffer.c +55 -50
  106. data/vendor/libgit2/src/buffer.h +1 -1
  107. data/vendor/libgit2/src/cache.c +16 -16
  108. data/vendor/libgit2/src/cache.h +2 -2
  109. data/vendor/libgit2/src/cc-compat.h +15 -3
  110. data/vendor/libgit2/src/checkout.c +83 -74
  111. data/vendor/libgit2/src/cherrypick.c +6 -6
  112. data/vendor/libgit2/src/clone.c +20 -20
  113. data/vendor/libgit2/src/commit.c +53 -33
  114. data/vendor/libgit2/src/commit.h +1 -0
  115. data/vendor/libgit2/src/commit_list.c +6 -10
  116. data/vendor/libgit2/src/common.h +32 -30
  117. data/vendor/libgit2/src/config.c +167 -147
  118. data/vendor/libgit2/src/config.h +1 -14
  119. data/vendor/libgit2/src/config_backend.h +84 -0
  120. data/vendor/libgit2/src/config_cache.c +7 -1
  121. data/vendor/libgit2/src/config_entries.c +259 -0
  122. data/vendor/libgit2/src/config_entries.h +23 -0
  123. data/vendor/libgit2/src/config_file.c +167 -439
  124. data/vendor/libgit2/src/config_mem.c +224 -0
  125. data/vendor/libgit2/src/config_parse.c +69 -38
  126. data/vendor/libgit2/src/config_parse.h +4 -4
  127. data/vendor/libgit2/src/crlf.c +215 -186
  128. data/vendor/libgit2/src/delta.c +25 -18
  129. data/vendor/libgit2/src/describe.c +23 -23
  130. data/vendor/libgit2/src/diff.c +12 -12
  131. data/vendor/libgit2/src/diff_driver.c +14 -15
  132. data/vendor/libgit2/src/diff_file.c +10 -10
  133. data/vendor/libgit2/src/diff_generate.c +29 -23
  134. data/vendor/libgit2/src/diff_generate.h +1 -1
  135. data/vendor/libgit2/src/diff_parse.c +3 -3
  136. data/vendor/libgit2/src/diff_print.c +17 -17
  137. data/vendor/libgit2/src/diff_stats.c +22 -7
  138. data/vendor/libgit2/src/diff_tform.c +12 -12
  139. data/vendor/libgit2/src/diff_xdiff.c +15 -3
  140. data/vendor/libgit2/src/errors.c +42 -20
  141. data/vendor/libgit2/src/features.h.in +2 -1
  142. data/vendor/libgit2/src/fetch.c +3 -3
  143. data/vendor/libgit2/src/fetchhead.c +16 -16
  144. data/vendor/libgit2/src/filebuf.c +28 -28
  145. data/vendor/libgit2/src/fileops.c +54 -54
  146. data/vendor/libgit2/src/fileops.h +1 -1
  147. data/vendor/libgit2/src/filter.c +30 -30
  148. data/vendor/libgit2/src/filter.h +0 -10
  149. data/vendor/libgit2/src/global.c +36 -23
  150. data/vendor/libgit2/src/hash.h +4 -1
  151. data/vendor/libgit2/src/hash/hash_collisiondetect.h +6 -2
  152. data/vendor/libgit2/src/hash/hash_common_crypto.h +5 -1
  153. data/vendor/libgit2/src/hash/hash_generic.h +5 -1
  154. data/vendor/libgit2/src/hash/hash_mbedtls.c +38 -0
  155. data/vendor/libgit2/src/hash/hash_mbedtls.h +24 -0
  156. data/vendor/libgit2/src/hash/hash_openssl.h +8 -4
  157. data/vendor/libgit2/src/hash/hash_win32.c +13 -13
  158. data/vendor/libgit2/src/hashsig.c +4 -4
  159. data/vendor/libgit2/src/idxmap.c +25 -5
  160. data/vendor/libgit2/src/idxmap.h +4 -18
  161. data/vendor/libgit2/src/ignore.c +9 -9
  162. data/vendor/libgit2/src/index.c +280 -198
  163. data/vendor/libgit2/src/index.h +16 -0
  164. data/vendor/libgit2/src/indexer.c +311 -139
  165. data/vendor/libgit2/src/integer.h +32 -22
  166. data/vendor/libgit2/src/iterator.c +116 -49
  167. data/vendor/libgit2/src/iterator.h +15 -0
  168. data/vendor/libgit2/src/khash.h +3 -1
  169. data/vendor/libgit2/src/mailmap.c +485 -0
  170. data/vendor/libgit2/src/mailmap.h +35 -0
  171. data/vendor/libgit2/src/merge.c +89 -59
  172. data/vendor/libgit2/src/merge_driver.c +7 -7
  173. data/vendor/libgit2/src/merge_file.c +1 -1
  174. data/vendor/libgit2/src/mwindow.c +8 -8
  175. data/vendor/libgit2/src/netops.c +22 -13
  176. data/vendor/libgit2/src/netops.h +2 -0
  177. data/vendor/libgit2/src/notes.c +15 -10
  178. data/vendor/libgit2/src/object.c +118 -67
  179. data/vendor/libgit2/src/object.h +20 -9
  180. data/vendor/libgit2/src/object_api.c +8 -8
  181. data/vendor/libgit2/src/odb.c +72 -72
  182. data/vendor/libgit2/src/odb.h +7 -7
  183. data/vendor/libgit2/src/odb_loose.c +46 -46
  184. data/vendor/libgit2/src/odb_mempack.c +14 -14
  185. data/vendor/libgit2/src/odb_pack.c +14 -10
  186. data/vendor/libgit2/src/offmap.c +30 -0
  187. data/vendor/libgit2/src/offmap.h +20 -11
  188. data/vendor/libgit2/src/oid.c +6 -6
  189. data/vendor/libgit2/src/oidmap.c +20 -0
  190. data/vendor/libgit2/src/oidmap.h +9 -12
  191. data/vendor/libgit2/src/pack-objects.c +71 -63
  192. data/vendor/libgit2/src/pack-objects.h +1 -7
  193. data/vendor/libgit2/src/pack.c +58 -58
  194. data/vendor/libgit2/src/pack.h +6 -6
  195. data/vendor/libgit2/src/parse.h +1 -1
  196. data/vendor/libgit2/src/patch.c +3 -3
  197. data/vendor/libgit2/src/patch_generate.c +18 -18
  198. data/vendor/libgit2/src/patch_parse.c +13 -13
  199. data/vendor/libgit2/src/path.c +93 -225
  200. data/vendor/libgit2/src/path.h +2 -84
  201. data/vendor/libgit2/src/pathspec.c +6 -6
  202. data/vendor/libgit2/src/posix.c +3 -3
  203. data/vendor/libgit2/src/proxy.c +1 -1
  204. data/vendor/libgit2/src/push.c +27 -26
  205. data/vendor/libgit2/src/push.h +2 -1
  206. data/vendor/libgit2/src/reader.c +265 -0
  207. data/vendor/libgit2/src/reader.h +107 -0
  208. data/vendor/libgit2/src/rebase.c +49 -52
  209. data/vendor/libgit2/src/refdb.c +3 -3
  210. data/vendor/libgit2/src/refdb_fs.c +181 -103
  211. data/vendor/libgit2/src/reflog.c +3 -3
  212. data/vendor/libgit2/src/refs.c +98 -74
  213. data/vendor/libgit2/src/refs.h +5 -3
  214. data/vendor/libgit2/src/refspec.c +47 -21
  215. data/vendor/libgit2/src/refspec.h +1 -1
  216. data/vendor/libgit2/src/remote.c +219 -166
  217. data/vendor/libgit2/src/remote.h +9 -0
  218. data/vendor/libgit2/src/repository.c +173 -133
  219. data/vendor/libgit2/src/repository.h +6 -3
  220. data/vendor/libgit2/src/reset.c +8 -8
  221. data/vendor/libgit2/src/revert.c +6 -6
  222. data/vendor/libgit2/src/revparse.c +30 -30
  223. data/vendor/libgit2/src/revwalk.c +60 -30
  224. data/vendor/libgit2/src/revwalk.h +2 -1
  225. data/vendor/libgit2/src/settings.c +42 -10
  226. data/vendor/libgit2/src/signature.c +11 -11
  227. data/vendor/libgit2/src/sortedcache.c +13 -13
  228. data/vendor/libgit2/src/stash.c +91 -45
  229. data/vendor/libgit2/src/status.c +13 -13
  230. data/vendor/libgit2/src/stdalloc.c +120 -0
  231. data/vendor/libgit2/src/{streams/curl.h → stdalloc.h} +6 -6
  232. data/vendor/libgit2/src/stream.h +17 -2
  233. data/vendor/libgit2/src/streams/mbedtls.c +483 -0
  234. data/vendor/libgit2/src/streams/mbedtls.h +23 -0
  235. data/vendor/libgit2/src/streams/openssl.c +204 -114
  236. data/vendor/libgit2/src/streams/openssl.h +4 -108
  237. data/vendor/libgit2/src/streams/registry.c +118 -0
  238. data/vendor/libgit2/src/streams/registry.h +19 -0
  239. data/vendor/libgit2/src/streams/socket.c +54 -29
  240. data/vendor/libgit2/src/streams/stransport.c +57 -32
  241. data/vendor/libgit2/src/streams/stransport.h +5 -0
  242. data/vendor/libgit2/src/streams/tls.c +50 -19
  243. data/vendor/libgit2/src/streams/tls.h +12 -4
  244. data/vendor/libgit2/src/strmap.c +22 -2
  245. data/vendor/libgit2/src/strmap.h +18 -15
  246. data/vendor/libgit2/src/submodule.c +179 -155
  247. data/vendor/libgit2/src/sysdir.c +18 -18
  248. data/vendor/libgit2/src/tag.c +31 -26
  249. data/vendor/libgit2/src/tag.h +2 -1
  250. data/vendor/libgit2/src/trace.c +1 -1
  251. data/vendor/libgit2/src/trace.h +1 -1
  252. data/vendor/libgit2/src/trailer.c +6 -6
  253. data/vendor/libgit2/src/transaction.c +23 -23
  254. data/vendor/libgit2/src/transport.c +5 -5
  255. data/vendor/libgit2/src/transports/auth.c +7 -4
  256. data/vendor/libgit2/src/transports/auth.h +1 -1
  257. data/vendor/libgit2/src/transports/auth_negotiate.c +12 -11
  258. data/vendor/libgit2/src/transports/cred.c +18 -18
  259. data/vendor/libgit2/src/transports/git.c +15 -15
  260. data/vendor/libgit2/src/transports/http.c +606 -216
  261. data/vendor/libgit2/src/transports/http.h +2 -0
  262. data/vendor/libgit2/src/transports/local.c +26 -26
  263. data/vendor/libgit2/src/transports/smart.c +54 -31
  264. data/vendor/libgit2/src/transports/smart.h +1 -2
  265. data/vendor/libgit2/src/transports/smart_pkt.c +43 -40
  266. data/vendor/libgit2/src/transports/smart_protocol.c +61 -57
  267. data/vendor/libgit2/src/transports/ssh.c +34 -33
  268. data/vendor/libgit2/src/transports/winhttp.c +99 -119
  269. data/vendor/libgit2/src/tree-cache.c +5 -5
  270. data/vendor/libgit2/src/tree.c +96 -121
  271. data/vendor/libgit2/src/tree.h +1 -12
  272. data/vendor/libgit2/src/unix/map.c +2 -2
  273. data/vendor/libgit2/src/util.c +22 -6
  274. data/vendor/libgit2/src/util.h +12 -135
  275. data/vendor/libgit2/src/vector.c +4 -4
  276. data/vendor/libgit2/src/win32/dir.c +3 -3
  277. data/vendor/libgit2/src/win32/findfile.c +3 -3
  278. data/vendor/libgit2/src/win32/map.c +6 -6
  279. data/vendor/libgit2/src/win32/msvc-compat.h +6 -0
  280. data/vendor/libgit2/src/win32/path_w32.c +101 -7
  281. data/vendor/libgit2/src/win32/path_w32.h +18 -0
  282. data/vendor/libgit2/src/win32/posix_w32.c +24 -43
  283. data/vendor/libgit2/src/win32/w32_buffer.c +2 -2
  284. data/vendor/libgit2/src/win32/w32_crtdbg_stacktrace.c +96 -2
  285. data/vendor/libgit2/src/win32/w32_crtdbg_stacktrace.h +28 -75
  286. data/vendor/libgit2/src/win32/w32_stack.c +2 -2
  287. data/vendor/libgit2/src/win32/w32_util.c +1 -69
  288. data/vendor/libgit2/src/win32/w32_util.h +1 -19
  289. data/vendor/libgit2/src/worktree.c +75 -54
  290. data/vendor/libgit2/src/worktree.h +2 -0
  291. data/vendor/libgit2/src/xdiff/xdiffi.c +7 -5
  292. data/vendor/libgit2/src/xdiff/xhistogram.c +1 -1
  293. data/vendor/libgit2/src/xdiff/xmerge.c +15 -15
  294. data/vendor/libgit2/src/zstream.c +4 -4
  295. metadata +33 -7
  296. data/vendor/libgit2/src/config_file.h +0 -73
  297. data/vendor/libgit2/src/streams/curl.c +0 -385
@@ -36,7 +36,8 @@ struct git_revwalk {
36
36
  unsigned walking:1,
37
37
  first_parent: 1,
38
38
  did_hide: 1,
39
- did_push: 1;
39
+ did_push: 1,
40
+ limited: 1;
40
41
  unsigned int sorting;
41
42
 
42
43
  /* the pushes and hides */
@@ -11,15 +11,22 @@
11
11
  # include <openssl/err.h>
12
12
  #endif
13
13
 
14
+ #ifdef GIT_MBEDTLS
15
+ # include <mbedtls/error.h>
16
+ #endif
17
+
14
18
  #include <git2.h>
19
+ #include "alloc.h"
15
20
  #include "sysdir.h"
16
21
  #include "cache.h"
17
22
  #include "global.h"
18
23
  #include "object.h"
19
24
  #include "odb.h"
20
25
  #include "refs.h"
26
+ #include "index.h"
21
27
  #include "transports/smart.h"
22
28
  #include "streams/openssl.h"
29
+ #include "streams/mbedtls.h"
23
30
 
24
31
  void git_libgit2_version(int *major, int *minor, int *rev)
25
32
  {
@@ -49,6 +56,7 @@ int git_libgit2_features(void)
49
56
  /* Declarations for tuneable settings */
50
57
  extern size_t git_mwindow__window_size;
51
58
  extern size_t git_mwindow__mapped_limit;
59
+ extern size_t git_indexer__max_objects;
52
60
 
53
61
  static int config_level_to_sysdir(int config_level)
54
62
  {
@@ -68,8 +76,8 @@ static int config_level_to_sysdir(int config_level)
68
76
  val = GIT_SYSDIR_PROGRAMDATA;
69
77
  break;
70
78
  default:
71
- giterr_set(
72
- GITERR_INVALID, "invalid config path selector %d", config_level);
79
+ git_error_set(
80
+ GIT_ERROR_INVALID, "invalid config path selector %d", config_level);
73
81
  }
74
82
 
75
83
  return val;
@@ -132,7 +140,7 @@ int git_libgit2_opts(int key, ...)
132
140
 
133
141
  case GIT_OPT_SET_CACHE_OBJECT_LIMIT:
134
142
  {
135
- git_otype type = (git_otype)va_arg(ap, int);
143
+ git_object_t type = (git_object_t)va_arg(ap, int);
136
144
  size_t size = va_arg(ap, size_t);
137
145
  error = git_cache_set_max_object_size(type, size);
138
146
  break;
@@ -175,8 +183,17 @@ int git_libgit2_opts(int key, ...)
175
183
  const char *path = va_arg(ap, const char *);
176
184
  error = git_openssl__set_cert_location(file, path);
177
185
  }
186
+ #elif defined(GIT_MBEDTLS)
187
+ {
188
+ const char *file = va_arg(ap, const char *);
189
+ const char *path = va_arg(ap, const char *);
190
+ if (file)
191
+ error = git_mbedtls__set_cert_location(file, 0);
192
+ if (error && path)
193
+ error = git_mbedtls__set_cert_location(path, 1);
194
+ }
178
195
  #else
179
- giterr_set(GITERR_SSL, "TLS backend doesn't support certificate locations");
196
+ git_error_set(GIT_ERROR_SSL, "TLS backend doesn't support certificate locations");
180
197
  error = -1;
181
198
  #endif
182
199
  break;
@@ -184,7 +201,7 @@ int git_libgit2_opts(int key, ...)
184
201
  git__free(git__user_agent);
185
202
  git__user_agent = git__strdup(va_arg(ap, const char *));
186
203
  if (!git__user_agent) {
187
- giterr_set_oom();
204
+ git_error_set_oom();
188
205
  error = -1;
189
206
  }
190
207
 
@@ -199,17 +216,17 @@ int git_libgit2_opts(int key, ...)
199
216
  break;
200
217
 
201
218
  case GIT_OPT_SET_SSL_CIPHERS:
202
- #ifdef GIT_OPENSSL
219
+ #if (GIT_OPENSSL || GIT_MBEDTLS)
203
220
  {
204
221
  git__free(git__ssl_ciphers);
205
222
  git__ssl_ciphers = git__strdup(va_arg(ap, const char *));
206
223
  if (!git__ssl_ciphers) {
207
- giterr_set_oom();
224
+ git_error_set_oom();
208
225
  error = -1;
209
226
  }
210
227
  }
211
228
  #else
212
- giterr_set(GITERR_SSL, "TLS backend doesn't support custom ciphers");
229
+ git_error_set(GIT_ERROR_SSL, "TLS backend doesn't support custom ciphers");
213
230
  error = -1;
214
231
  #endif
215
232
  break;
@@ -246,8 +263,24 @@ int git_libgit2_opts(int key, ...)
246
263
  git_odb__strict_hash_verification = (va_arg(ap, int) != 0);
247
264
  break;
248
265
 
266
+ case GIT_OPT_SET_ALLOCATOR:
267
+ error = git_allocator_setup(va_arg(ap, git_allocator *));
268
+ break;
269
+
270
+ case GIT_OPT_ENABLE_UNSAVED_INDEX_SAFETY:
271
+ git_index__enforce_unsaved_safety = (va_arg(ap, int) != 0);
272
+ break;
273
+
274
+ case GIT_OPT_SET_PACK_MAX_OBJECTS:
275
+ git_indexer__max_objects = va_arg(ap, size_t);
276
+ break;
277
+
278
+ case GIT_OPT_GET_PACK_MAX_OBJECTS:
279
+ *(va_arg(ap, size_t *)) = git_indexer__max_objects;
280
+ break;
281
+
249
282
  default:
250
- giterr_set(GITERR_INVALID, "invalid option key");
283
+ git_error_set(GIT_ERROR_INVALID, "invalid option key");
251
284
  error = -1;
252
285
  }
253
286
 
@@ -255,4 +288,3 @@ int git_libgit2_opts(int key, ...)
255
288
 
256
289
  return error;
257
290
  }
258
-
@@ -25,7 +25,7 @@ void git_signature_free(git_signature *sig)
25
25
 
26
26
  static int signature_error(const char *msg)
27
27
  {
28
- giterr_set(GITERR_INVALID, "failed to parse signature - %s", msg);
28
+ git_error_set(GIT_ERROR_INVALID, "failed to parse signature - %s", msg);
29
29
  return -1;
30
30
  }
31
31
 
@@ -76,12 +76,12 @@ int git_signature_new(git_signature **sig_out, const char *name, const char *ema
76
76
  }
77
77
 
78
78
  p = git__calloc(1, sizeof(git_signature));
79
- GITERR_CHECK_ALLOC(p);
79
+ GIT_ERROR_CHECK_ALLOC(p);
80
80
 
81
81
  p->name = extract_trimmed(name, strlen(name));
82
- GITERR_CHECK_ALLOC(p->name);
82
+ GIT_ERROR_CHECK_ALLOC(p->name);
83
83
  p->email = extract_trimmed(email, strlen(email));
84
- GITERR_CHECK_ALLOC(p->email);
84
+ GIT_ERROR_CHECK_ALLOC(p->email);
85
85
 
86
86
  if (p->name[0] == '\0' || p->email[0] == '\0') {
87
87
  git_signature_free(p);
@@ -104,13 +104,13 @@ int git_signature_dup(git_signature **dest, const git_signature *source)
104
104
  return 0;
105
105
 
106
106
  signature = git__calloc(1, sizeof(git_signature));
107
- GITERR_CHECK_ALLOC(signature);
107
+ GIT_ERROR_CHECK_ALLOC(signature);
108
108
 
109
109
  signature->name = git__strdup(source->name);
110
- GITERR_CHECK_ALLOC(signature->name);
110
+ GIT_ERROR_CHECK_ALLOC(signature->name);
111
111
 
112
112
  signature->email = git__strdup(source->email);
113
- GITERR_CHECK_ALLOC(signature->email);
113
+ GIT_ERROR_CHECK_ALLOC(signature->email);
114
114
 
115
115
  signature->when.time = source->when.time;
116
116
  signature->when.offset = source->when.offset;
@@ -129,13 +129,13 @@ int git_signature__pdup(git_signature **dest, const git_signature *source, git_p
129
129
  return 0;
130
130
 
131
131
  signature = git_pool_mallocz(pool, sizeof(git_signature));
132
- GITERR_CHECK_ALLOC(signature);
132
+ GIT_ERROR_CHECK_ALLOC(signature);
133
133
 
134
134
  signature->name = git_pool_strdup(pool, source->name);
135
- GITERR_CHECK_ALLOC(signature->name);
135
+ GIT_ERROR_CHECK_ALLOC(signature->name);
136
136
 
137
137
  signature->email = git_pool_strdup(pool, source->email);
138
- GITERR_CHECK_ALLOC(signature->email);
138
+ GIT_ERROR_CHECK_ALLOC(signature->email);
139
139
 
140
140
  signature->when.time = source->when.time;
141
141
  signature->when.offset = source->when.offset;
@@ -284,7 +284,7 @@ int git_signature_from_buffer(git_signature **out, const char *buf)
284
284
  *out = NULL;
285
285
 
286
286
  sig = git__calloc(1, sizeof(git_signature));
287
- GITERR_CHECK_ALLOC(sig);
287
+ GIT_ERROR_CHECK_ALLOC(sig);
288
288
 
289
289
  buf_end = buf + strlen(buf);
290
290
  error = git_signature__parse(sig, &buf, buf_end, NULL, '\0');
@@ -20,10 +20,10 @@ int git_sortedcache_new(
20
20
 
21
21
  pathlen = path ? strlen(path) : 0;
22
22
 
23
- GITERR_CHECK_ALLOC_ADD(&alloclen, sizeof(git_sortedcache), pathlen);
24
- GITERR_CHECK_ALLOC_ADD(&alloclen, alloclen, 1);
23
+ GIT_ERROR_CHECK_ALLOC_ADD(&alloclen, sizeof(git_sortedcache), pathlen);
24
+ GIT_ERROR_CHECK_ALLOC_ADD(&alloclen, alloclen, 1);
25
25
  sc = git__calloc(1, alloclen);
26
- GITERR_CHECK_ALLOC(sc);
26
+ GIT_ERROR_CHECK_ALLOC(sc);
27
27
 
28
28
  git_pool_init(&sc->pool, 1);
29
29
 
@@ -32,7 +32,7 @@ int git_sortedcache_new(
32
32
  goto fail;
33
33
 
34
34
  if (git_rwlock_init(&sc->lock)) {
35
- giterr_set(GITERR_OS, "failed to initialize lock");
35
+ git_error_set(GIT_ERROR_OS, "failed to initialize lock");
36
36
  goto fail;
37
37
  }
38
38
 
@@ -167,7 +167,7 @@ int git_sortedcache_wlock(git_sortedcache *sc)
167
167
  GIT_UNUSED(sc); /* prevent warning when compiled w/o threads */
168
168
 
169
169
  if (git_rwlock_wrlock(&sc->lock) < 0) {
170
- giterr_set(GITERR_OS, "unable to acquire write lock on cache");
170
+ git_error_set(GIT_ERROR_OS, "unable to acquire write lock on cache");
171
171
  return -1;
172
172
  }
173
173
  return 0;
@@ -186,7 +186,7 @@ int git_sortedcache_rlock(git_sortedcache *sc)
186
186
  GIT_UNUSED(sc); /* prevent warning when compiled w/o threads */
187
187
 
188
188
  if (git_rwlock_rdlock(&sc->lock) < 0) {
189
- giterr_set(GITERR_OS, "unable to acquire read lock on cache");
189
+ git_error_set(GIT_ERROR_OS, "unable to acquire read lock on cache");
190
190
  return -1;
191
191
  }
192
192
  return 0;
@@ -219,14 +219,14 @@ int git_sortedcache_lockandload(git_sortedcache *sc, git_buf *buf)
219
219
  }
220
220
 
221
221
  if (p_fstat(fd, &st) < 0) {
222
- giterr_set(GITERR_OS, "failed to stat file");
222
+ git_error_set(GIT_ERROR_OS, "failed to stat file");
223
223
  error = -1;
224
224
  (void)p_close(fd);
225
225
  goto unlock;
226
226
  }
227
227
 
228
228
  if (!git__is_sizet(st.st_size)) {
229
- giterr_set(GITERR_INVALID, "unable to load file larger than size_t");
229
+ git_error_set(GIT_ERROR_INVALID, "unable to load file larger than size_t");
230
230
  error = -1;
231
231
  (void)p_close(fd);
232
232
  goto unlock;
@@ -270,8 +270,8 @@ int git_sortedcache_clear(git_sortedcache *sc, bool wlock)
270
270
  /* find and/or insert item, returning pointer to item data */
271
271
  int git_sortedcache_upsert(void **out, git_sortedcache *sc, const char *key)
272
272
  {
273
+ size_t pos;
273
274
  int error = 0;
274
- khiter_t pos;
275
275
  void *item;
276
276
  size_t keylen, itemlen;
277
277
  char *item_key;
@@ -287,7 +287,7 @@ int git_sortedcache_upsert(void **out, git_sortedcache *sc, const char *key)
287
287
  itemlen = (itemlen + 7) & ~7;
288
288
 
289
289
  if ((item = git_pool_mallocz(&sc->pool, (uint32_t)itemlen)) == NULL) {
290
- /* don't use GITERR_CHECK_ALLOC b/c of lock */
290
+ /* don't use GIT_ERROR_CHECK_ALLOC b/c of lock */
291
291
  error = -1;
292
292
  goto done;
293
293
  }
@@ -320,7 +320,7 @@ done:
320
320
  /* lookup item by key */
321
321
  void *git_sortedcache_lookup(const git_sortedcache *sc, const char *key)
322
322
  {
323
- khiter_t pos = git_strmap_lookup_index(sc->map, key);
323
+ size_t pos = git_strmap_lookup_index(sc->map, key);
324
324
  if (git_strmap_valid_index(sc->map, pos))
325
325
  return git_strmap_value_at(sc->map, pos);
326
326
  return NULL;
@@ -371,14 +371,14 @@ int git_sortedcache_lookup_index(
371
371
  int git_sortedcache_remove(git_sortedcache *sc, size_t pos)
372
372
  {
373
373
  char *item;
374
- khiter_t mappos;
374
+ size_t mappos;
375
375
 
376
376
  /* because of pool allocation, this can't actually remove the item,
377
377
  * but we can remove it from the items vector and the hash table.
378
378
  */
379
379
 
380
380
  if ((item = git_vector_get(&sc->items, pos)) == NULL) {
381
- giterr_set(GITERR_INVALID, "removing item out of range");
381
+ git_error_set(GIT_ERROR_INVALID, "removing item out of range");
382
382
  return GIT_ENOTFOUND;
383
383
  }
384
384
 
@@ -12,6 +12,7 @@
12
12
  #include "message.h"
13
13
  #include "tree.h"
14
14
  #include "reflog.h"
15
+ #include "blob.h"
15
16
  #include "git2/diff.h"
16
17
  #include "git2/stash.h"
17
18
  #include "git2/status.h"
@@ -28,7 +29,7 @@
28
29
 
29
30
  static int create_error(int error, const char *msg)
30
31
  {
31
- giterr_set(GITERR_STASH, "cannot stash changes - %s", msg);
32
+ git_error_set(GIT_ERROR_STASH, "cannot stash changes - %s", msg);
32
33
  return error;
33
34
  }
34
35
 
@@ -47,7 +48,7 @@ static int append_abbreviated_oid(git_buf *out, const git_oid *b_commit)
47
48
  char *formatted_oid;
48
49
 
49
50
  formatted_oid = git_oid_allocfmt(b_commit);
50
- GITERR_CHECK_ALLOC(formatted_oid);
51
+ GIT_ERROR_CHECK_ALLOC(formatted_oid);
51
52
 
52
53
  git_buf_put(out, formatted_oid, 7);
53
54
  git__free(formatted_oid);
@@ -58,7 +59,7 @@ static int append_abbreviated_oid(git_buf *out, const git_oid *b_commit)
58
59
  static int append_commit_description(git_buf *out, git_commit* commit)
59
60
  {
60
61
  const char *summary = git_commit_summary(commit);
61
- GITERR_CHECK_ALLOC(summary);
62
+ GIT_ERROR_CHECK_ALLOC(summary);
62
63
 
63
64
  if (append_abbreviated_oid(out, git_commit_id(commit)) < 0)
64
65
  return -1;
@@ -103,19 +104,23 @@ cleanup:
103
104
  return error;
104
105
  }
105
106
 
106
- static int build_tree_from_index(git_tree **out, git_index *index)
107
+ static int build_tree_from_index(
108
+ git_tree **out,
109
+ git_repository *repo,
110
+ git_index *index)
107
111
  {
108
112
  int error;
109
113
  git_oid i_tree_oid;
110
114
 
111
- if ((error = git_index_write_tree(&i_tree_oid, index)) < 0)
115
+ if ((error = git_index_write_tree_to(&i_tree_oid, index, repo)) < 0)
112
116
  return error;
113
117
 
114
- return git_tree_lookup(out, git_index_owner(index), &i_tree_oid);
118
+ return git_tree_lookup(out, repo, &i_tree_oid);
115
119
  }
116
120
 
117
121
  static int commit_index(
118
122
  git_commit **i_commit,
123
+ git_repository *repo,
119
124
  git_index *index,
120
125
  const git_signature *stasher,
121
126
  const char *message,
@@ -126,7 +131,7 @@ static int commit_index(
126
131
  git_buf msg = GIT_BUF_INIT;
127
132
  int error;
128
133
 
129
- if ((error = build_tree_from_index(&i_tree, index)) < 0)
134
+ if ((error = build_tree_from_index(&i_tree, repo, index)) < 0)
130
135
  goto cleanup;
131
136
 
132
137
  if ((error = git_buf_printf(&msg, "index on %s\n", message)) < 0)
@@ -149,7 +154,7 @@ static int commit_index(
149
154
 
150
155
  cleanup:
151
156
  git_tree_free(i_tree);
152
- git_buf_free(&msg);
157
+ git_buf_dispose(&msg);
153
158
  return error;
154
159
  }
155
160
 
@@ -159,7 +164,38 @@ struct stash_update_rules {
159
164
  bool include_ignored;
160
165
  };
161
166
 
167
+ /*
168
+ * Similar to git_index_add_bypath but able to operate on any
169
+ * index without making assumptions about the repository's index
170
+ */
171
+ static int stash_to_index(
172
+ git_repository *repo,
173
+ git_index *index,
174
+ const char *path)
175
+ {
176
+ git_index *repo_index;
177
+ git_index_entry entry = {{0}};
178
+ struct stat st;
179
+ int error;
180
+
181
+ if (!git_repository_is_bare(repo) &&
182
+ (error = git_repository_index__weakptr(&repo_index, repo)) < 0)
183
+ return error;
184
+
185
+ if ((error = git_blob__create_from_paths(
186
+ &entry.id, &st, repo, NULL, path, 0, true)) < 0)
187
+ return error;
188
+
189
+ git_index_entry__init_from_stat(&entry, &st,
190
+ (repo_index != NULL || !repo_index->distrust_filemode));
191
+
192
+ entry.path = path;
193
+
194
+ return git_index_add(index, &entry);
195
+ }
196
+
162
197
  static int stash_update_index_from_diff(
198
+ git_repository *repo,
163
199
  git_index *index,
164
200
  const git_diff *diff,
165
201
  struct stash_update_rules *data)
@@ -197,15 +233,15 @@ static int stash_update_index_from_diff(
197
233
 
198
234
  default:
199
235
  /* Unimplemented */
200
- giterr_set(
201
- GITERR_INVALID,
236
+ git_error_set(
237
+ GIT_ERROR_INVALID,
202
238
  "cannot update index. Unimplemented status (%d)",
203
239
  delta->status);
204
240
  return -1;
205
241
  }
206
242
 
207
243
  if (add_path != NULL)
208
- error = git_index_add_bypath(index, add_path);
244
+ error = stash_to_index(repo, index, add_path);
209
245
  }
210
246
 
211
247
  return error;
@@ -213,17 +249,19 @@ static int stash_update_index_from_diff(
213
249
 
214
250
  static int build_untracked_tree(
215
251
  git_tree **tree_out,
216
- git_index *index,
252
+ git_repository *repo,
217
253
  git_commit *i_commit,
218
254
  uint32_t flags)
219
255
  {
256
+ git_index *i_index = NULL;
220
257
  git_tree *i_tree = NULL;
221
258
  git_diff *diff = NULL;
222
259
  git_diff_options opts = GIT_DIFF_OPTIONS_INIT;
223
260
  struct stash_update_rules data = {0};
224
261
  int error;
225
262
 
226
- git_index_clear(index);
263
+ if ((error = git_index_new(&i_index)) < 0)
264
+ goto cleanup;
227
265
 
228
266
  if (flags & GIT_STASH_INCLUDE_UNTRACKED) {
229
267
  opts.flags |= GIT_DIFF_INCLUDE_UNTRACKED |
@@ -240,24 +278,24 @@ static int build_untracked_tree(
240
278
  if ((error = git_commit_tree(&i_tree, i_commit)) < 0)
241
279
  goto cleanup;
242
280
 
243
- if ((error = git_diff_tree_to_workdir(
244
- &diff, git_index_owner(index), i_tree, &opts)) < 0)
281
+ if ((error = git_diff_tree_to_workdir(&diff, repo, i_tree, &opts)) < 0)
245
282
  goto cleanup;
246
283
 
247
- if ((error = stash_update_index_from_diff(index, diff, &data)) < 0)
284
+ if ((error = stash_update_index_from_diff(repo, i_index, diff, &data)) < 0)
248
285
  goto cleanup;
249
286
 
250
- error = build_tree_from_index(tree_out, index);
287
+ error = build_tree_from_index(tree_out, repo, i_index);
251
288
 
252
289
  cleanup:
253
290
  git_diff_free(diff);
254
291
  git_tree_free(i_tree);
292
+ git_index_free(i_index);
255
293
  return error;
256
294
  }
257
295
 
258
296
  static int commit_untracked(
259
297
  git_commit **u_commit,
260
- git_index *index,
298
+ git_repository *repo,
261
299
  const git_signature *stasher,
262
300
  const char *message,
263
301
  git_commit *i_commit,
@@ -268,7 +306,7 @@ static int commit_untracked(
268
306
  git_buf msg = GIT_BUF_INIT;
269
307
  int error;
270
308
 
271
- if ((error = build_untracked_tree(&u_tree, index, i_commit, flags)) < 0)
309
+ if ((error = build_untracked_tree(&u_tree, repo, i_commit, flags)) < 0)
272
310
  goto cleanup;
273
311
 
274
312
  if ((error = git_buf_printf(&msg, "untracked files on %s\n", message)) < 0)
@@ -276,7 +314,7 @@ static int commit_untracked(
276
314
 
277
315
  if ((error = git_commit_create(
278
316
  &u_commit_oid,
279
- git_index_owner(index),
317
+ repo,
280
318
  NULL,
281
319
  stasher,
282
320
  stasher,
@@ -287,11 +325,11 @@ static int commit_untracked(
287
325
  NULL)) < 0)
288
326
  goto cleanup;
289
327
 
290
- error = git_commit_lookup(u_commit, git_index_owner(index), &u_commit_oid);
328
+ error = git_commit_lookup(u_commit, repo, &u_commit_oid);
291
329
 
292
330
  cleanup:
293
331
  git_tree_free(u_tree);
294
- git_buf_free(&msg);
332
+ git_buf_dispose(&msg);
295
333
  return error;
296
334
  }
297
335
 
@@ -316,10 +354,10 @@ static git_diff_delta *stash_delta_merge(
316
354
 
317
355
  static int build_workdir_tree(
318
356
  git_tree **tree_out,
319
- git_index *index,
357
+ git_repository *repo,
358
+ git_index *i_index,
320
359
  git_commit *b_commit)
321
360
  {
322
- git_repository *repo = git_index_owner(index);
323
361
  git_tree *b_tree = NULL;
324
362
  git_diff *diff = NULL, *idx_to_wd = NULL;
325
363
  git_diff_options opts = GIT_DIFF_OPTIONS_INIT;
@@ -331,17 +369,17 @@ static int build_workdir_tree(
331
369
  if ((error = git_commit_tree(&b_tree, b_commit)) < 0)
332
370
  goto cleanup;
333
371
 
334
- if ((error = git_diff_tree_to_index(&diff, repo, b_tree, index, &opts)) < 0 ||
335
- (error = git_diff_index_to_workdir(&idx_to_wd, repo, index, &opts)) < 0 ||
372
+ if ((error = git_diff_tree_to_index(&diff, repo, b_tree, i_index, &opts)) < 0 ||
373
+ (error = git_diff_index_to_workdir(&idx_to_wd, repo, i_index, &opts)) < 0 ||
336
374
  (error = git_diff__merge(diff, idx_to_wd, stash_delta_merge)) < 0)
337
375
  goto cleanup;
338
376
 
339
377
  data.include_changed = true;
340
378
 
341
- if ((error = stash_update_index_from_diff(index, diff, &data)) < 0)
379
+ if ((error = stash_update_index_from_diff(repo, i_index, diff, &data)) < 0)
342
380
  goto cleanup;
343
381
 
344
- error = build_tree_from_index(tree_out, index);
382
+ error = build_tree_from_index(tree_out, repo, i_index);
345
383
 
346
384
  cleanup:
347
385
  git_diff_free(idx_to_wd);
@@ -353,7 +391,7 @@ cleanup:
353
391
 
354
392
  static int commit_worktree(
355
393
  git_oid *w_commit_oid,
356
- git_index *index,
394
+ git_repository *repo,
357
395
  const git_signature *stasher,
358
396
  const char *message,
359
397
  git_commit *i_commit,
@@ -362,7 +400,9 @@ static int commit_worktree(
362
400
  {
363
401
  int error = 0;
364
402
  git_tree *w_tree = NULL, *i_tree = NULL;
403
+ git_index *i_index = NULL;
365
404
  const git_commit *parents[] = { NULL, NULL, NULL };
405
+ int ignorecase;
366
406
 
367
407
  parents[0] = b_commit;
368
408
  parents[1] = i_commit;
@@ -371,15 +411,21 @@ static int commit_worktree(
371
411
  if ((error = git_commit_tree(&i_tree, i_commit)) < 0)
372
412
  goto cleanup;
373
413
 
374
- if ((error = git_index_read_tree(index, i_tree)) < 0)
414
+ if ((error = git_index_new(&i_index)) < 0 ||
415
+ (error = git_repository__cvar(&ignorecase, repo, GIT_CVAR_IGNORECASE)) < 0)
416
+ goto cleanup;
417
+
418
+ git_index__set_ignore_case(i_index, ignorecase);
419
+
420
+ if ((error = git_index_read_tree(i_index, i_tree)) < 0)
375
421
  goto cleanup;
376
422
 
377
- if ((error = build_workdir_tree(&w_tree, index, b_commit)) < 0)
423
+ if ((error = build_workdir_tree(&w_tree, repo, i_index, b_commit)) < 0)
378
424
  goto cleanup;
379
425
 
380
426
  error = git_commit_create(
381
427
  w_commit_oid,
382
- git_index_owner(index),
428
+ repo,
383
429
  NULL,
384
430
  stasher,
385
431
  stasher,
@@ -392,6 +438,7 @@ static int commit_worktree(
392
438
  cleanup:
393
439
  git_tree_free(i_tree);
394
440
  git_tree_free(w_tree);
441
+ git_index_free(i_index);
395
442
  return error;
396
443
  }
397
444
 
@@ -423,7 +470,7 @@ static int prepare_worktree_commit_message(
423
470
  error = (git_buf_oom(msg) || git_buf_oom(&buf)) ? -1 : 0;
424
471
 
425
472
  cleanup:
426
- git_buf_free(&buf);
473
+ git_buf_dispose(&buf);
427
474
 
428
475
  return error;
429
476
  }
@@ -534,12 +581,12 @@ int git_stash_save(
534
581
  goto cleanup;
535
582
 
536
583
  if ((error = commit_index(
537
- &i_commit, index, stasher, git_buf_cstr(&msg), b_commit)) < 0)
584
+ &i_commit, repo, index, stasher, git_buf_cstr(&msg), b_commit)) < 0)
538
585
  goto cleanup;
539
586
 
540
587
  if ((flags & (GIT_STASH_INCLUDE_UNTRACKED | GIT_STASH_INCLUDE_IGNORED)) &&
541
588
  (error = commit_untracked(
542
- &u_commit, index, stasher, git_buf_cstr(&msg),
589
+ &u_commit, repo, stasher, git_buf_cstr(&msg),
543
590
  i_commit, flags)) < 0)
544
591
  goto cleanup;
545
592
 
@@ -547,7 +594,7 @@ int git_stash_save(
547
594
  goto cleanup;
548
595
 
549
596
  if ((error = commit_worktree(
550
- out, index, stasher, git_buf_cstr(&msg),
597
+ out, repo, stasher, git_buf_cstr(&msg),
551
598
  i_commit, b_commit, u_commit)) < 0)
552
599
  goto cleanup;
553
600
 
@@ -565,7 +612,7 @@ int git_stash_save(
565
612
 
566
613
  cleanup:
567
614
 
568
- git_buf_free(&msg);
615
+ git_buf_dispose(&msg);
569
616
  git_commit_free(i_commit);
570
617
  git_commit_free(b_commit);
571
618
  git_commit_free(u_commit);
@@ -594,7 +641,7 @@ static int retrieve_stash_commit(
594
641
  max = git_reflog_entrycount(reflog);
595
642
  if (!max || index > max - 1) {
596
643
  error = GIT_ENOTFOUND;
597
- giterr_set(GITERR_STASH, "no stashed state at position %" PRIuZ, index);
644
+ git_error_set(GIT_ERROR_STASH, "no stashed state at position %" PRIuZ, index);
598
645
  goto cleanup;
599
646
  }
600
647
 
@@ -738,8 +785,7 @@ static void normalize_apply_options(
738
785
  memcpy(opts, &default_apply_opts, sizeof(git_stash_apply_options));
739
786
  }
740
787
 
741
- if ((opts->checkout_options.checkout_strategy & (GIT_CHECKOUT_SAFE | GIT_CHECKOUT_FORCE)) == 0)
742
- opts->checkout_options.checkout_strategy = GIT_CHECKOUT_SAFE;
788
+ opts->checkout_options.checkout_strategy |= GIT_CHECKOUT_NO_REFRESH;
743
789
 
744
790
  if (!opts->checkout_options.our_label)
745
791
  opts->checkout_options.our_label = "Updated upstream";
@@ -776,7 +822,7 @@ static int ensure_clean_index(git_repository *repo, git_index *index)
776
822
  goto done;
777
823
 
778
824
  if (git_diff_num_deltas(index_diff) > 0) {
779
- giterr_set(GITERR_STASH, "%" PRIuZ " uncommitted changes exist in the index",
825
+ git_error_set(GIT_ERROR_STASH, "%" PRIuZ " uncommitted changes exist in the index",
780
826
  git_diff_num_deltas(index_diff));
781
827
  error = GIT_EUNCOMMITTED;
782
828
  }
@@ -848,7 +894,7 @@ int git_stash_apply(
848
894
  git_index *untracked_index = NULL;
849
895
  int error;
850
896
 
851
- GITERR_CHECK_VERSION(given_opts, GIT_STASH_APPLY_OPTIONS_VERSION, "git_stash_apply_options");
897
+ GIT_ERROR_CHECK_VERSION(given_opts, GIT_STASH_APPLY_OPTIONS_VERSION, "git_stash_apply_options");
852
898
 
853
899
  normalize_apply_options(&opts, given_opts);
854
900
  checkout_strategy = opts.checkout_options.checkout_strategy;
@@ -981,7 +1027,7 @@ int git_stash_foreach(
981
1027
 
982
1028
  error = git_reference_lookup(&stash, repo, GIT_REFS_STASH_FILE);
983
1029
  if (error == GIT_ENOTFOUND) {
984
- giterr_clear();
1030
+ git_error_clear();
985
1031
  return 0;
986
1032
  }
987
1033
  if (error < 0)
@@ -1000,7 +1046,7 @@ int git_stash_foreach(
1000
1046
  payload);
1001
1047
 
1002
1048
  if (error) {
1003
- giterr_set_after_callback(error);
1049
+ git_error_set_after_callback(error);
1004
1050
  break;
1005
1051
  }
1006
1052
  }
@@ -1037,7 +1083,7 @@ int git_stash_drop(
1037
1083
 
1038
1084
  if (!max || index > max - 1) {
1039
1085
  error = GIT_ENOTFOUND;
1040
- giterr_set(GITERR_STASH, "no stashed state at position %" PRIuZ, index);
1086
+ git_error_set(GIT_ERROR_STASH, "no stashed state at position %" PRIuZ, index);
1041
1087
  goto cleanup;
1042
1088
  }
1043
1089