rugged 1.1.1 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (277) hide show
  1. checksums.yaml +4 -4
  2. data/LICENSE +1 -0
  3. data/README.md +1 -1
  4. data/ext/rugged/rugged.c +7 -4
  5. data/ext/rugged/rugged_object.c +1 -1
  6. data/ext/rugged/rugged_repo.c +3 -3
  7. data/lib/rugged/repository.rb +2 -2
  8. data/lib/rugged/version.rb +1 -1
  9. data/vendor/libgit2/CMakeLists.txt +11 -6
  10. data/vendor/libgit2/COPYING +109 -1
  11. data/vendor/libgit2/cmake/Findfutimens.cmake +14 -0
  12. data/vendor/libgit2/cmake/SelectHTTPSBackend.cmake +4 -0
  13. data/vendor/libgit2/cmake/SelectHashes.cmake +1 -0
  14. data/vendor/libgit2/deps/chromium-zlib/CMakeLists.txt +101 -0
  15. data/vendor/libgit2/deps/ntlmclient/CMakeLists.txt +17 -5
  16. data/vendor/libgit2/deps/ntlmclient/crypt.h +14 -9
  17. data/vendor/libgit2/deps/ntlmclient/crypt_commoncrypto.c +20 -20
  18. data/vendor/libgit2/deps/ntlmclient/crypt_commoncrypto.h +3 -3
  19. data/vendor/libgit2/deps/ntlmclient/crypt_mbedtls.c +37 -36
  20. data/vendor/libgit2/deps/ntlmclient/crypt_mbedtls.h +4 -3
  21. data/vendor/libgit2/deps/ntlmclient/crypt_openssl.c +178 -51
  22. data/vendor/libgit2/deps/ntlmclient/crypt_openssl.h +74 -5
  23. data/vendor/libgit2/deps/ntlmclient/ntlm.c +150 -118
  24. data/vendor/libgit2/deps/ntlmclient/ntlm.h +13 -9
  25. data/vendor/libgit2/deps/ntlmclient/ntlmclient.h +16 -3
  26. data/vendor/libgit2/deps/ntlmclient/unicode.h +10 -4
  27. data/vendor/libgit2/deps/ntlmclient/unicode_builtin.c +16 -27
  28. data/vendor/libgit2/deps/ntlmclient/unicode_builtin.h +20 -0
  29. data/vendor/libgit2/deps/ntlmclient/unicode_iconv.c +28 -52
  30. data/vendor/libgit2/deps/ntlmclient/unicode_iconv.h +22 -0
  31. data/vendor/libgit2/include/git2/attr.h +89 -0
  32. data/vendor/libgit2/include/git2/blame.h +93 -42
  33. data/vendor/libgit2/include/git2/blob.h +14 -2
  34. data/vendor/libgit2/include/git2/branch.h +25 -0
  35. data/vendor/libgit2/include/git2/cert.h +42 -5
  36. data/vendor/libgit2/include/git2/checkout.h +28 -12
  37. data/vendor/libgit2/include/git2/commit.h +35 -19
  38. data/vendor/libgit2/include/git2/common.h +14 -4
  39. data/vendor/libgit2/include/git2/deprecated.h +206 -6
  40. data/vendor/libgit2/include/git2/diff.h +34 -19
  41. data/vendor/libgit2/include/git2/errors.h +6 -6
  42. data/vendor/libgit2/include/git2/filter.h +57 -17
  43. data/vendor/libgit2/include/git2/graph.h +20 -2
  44. data/vendor/libgit2/include/git2/index.h +2 -2
  45. data/vendor/libgit2/include/git2/odb.h +29 -0
  46. data/vendor/libgit2/include/git2/patch.h +8 -0
  47. data/vendor/libgit2/include/git2/rebase.h +25 -1
  48. data/vendor/libgit2/include/git2/refs.h +6 -2
  49. data/vendor/libgit2/include/git2/remote.h +59 -6
  50. data/vendor/libgit2/include/git2/revparse.h +5 -5
  51. data/vendor/libgit2/include/git2/status.h +115 -59
  52. data/vendor/libgit2/include/git2/submodule.h +9 -0
  53. data/vendor/libgit2/include/git2/sys/commit_graph.h +174 -0
  54. data/vendor/libgit2/include/git2/sys/filter.h +49 -28
  55. data/vendor/libgit2/include/git2/sys/midx.h +74 -0
  56. data/vendor/libgit2/include/git2/sys/odb_backend.h +7 -0
  57. data/vendor/libgit2/include/git2/sys/transport.h +1 -0
  58. data/vendor/libgit2/include/git2/tag.h +12 -0
  59. data/vendor/libgit2/include/git2/tree.h +0 -14
  60. data/vendor/libgit2/include/git2/types.h +9 -0
  61. data/vendor/libgit2/include/git2/version.h +4 -4
  62. data/vendor/libgit2/include/git2/worktree.h +1 -0
  63. data/vendor/libgit2/src/CMakeLists.txt +25 -4
  64. data/vendor/libgit2/src/alloc.c +21 -8
  65. data/vendor/libgit2/src/allocators/failalloc.c +92 -0
  66. data/vendor/libgit2/src/allocators/failalloc.h +23 -0
  67. data/vendor/libgit2/src/allocators/stdalloc.c +41 -10
  68. data/vendor/libgit2/src/allocators/win32_leakcheck.c +118 -0
  69. data/vendor/libgit2/src/allocators/{win32_crtdbg.h → win32_leakcheck.h} +3 -3
  70. data/vendor/libgit2/src/annotated_commit.c +21 -9
  71. data/vendor/libgit2/src/apply.c +16 -7
  72. data/vendor/libgit2/src/array.h +11 -11
  73. data/vendor/libgit2/src/attr.c +181 -74
  74. data/vendor/libgit2/src/attr_file.c +84 -39
  75. data/vendor/libgit2/src/attr_file.h +32 -11
  76. data/vendor/libgit2/src/attrcache.c +42 -37
  77. data/vendor/libgit2/src/attrcache.h +4 -5
  78. data/vendor/libgit2/src/blame.c +11 -5
  79. data/vendor/libgit2/src/blob.c +35 -24
  80. data/vendor/libgit2/src/branch.c +69 -17
  81. data/vendor/libgit2/src/buffer.c +334 -25
  82. data/vendor/libgit2/src/buffer.h +153 -2
  83. data/vendor/libgit2/src/cache.c +2 -2
  84. data/vendor/libgit2/src/cache.h +7 -7
  85. data/vendor/libgit2/src/cc-compat.h +10 -2
  86. data/vendor/libgit2/src/checkout.c +48 -26
  87. data/vendor/libgit2/src/cherrypick.c +6 -2
  88. data/vendor/libgit2/src/clone.c +41 -47
  89. data/vendor/libgit2/src/commit.c +41 -28
  90. data/vendor/libgit2/src/commit_graph.c +1209 -0
  91. data/vendor/libgit2/src/commit_graph.h +162 -0
  92. data/vendor/libgit2/src/commit_list.c +46 -0
  93. data/vendor/libgit2/src/commit_list.h +2 -0
  94. data/vendor/libgit2/src/common.h +25 -2
  95. data/vendor/libgit2/src/config.c +37 -15
  96. data/vendor/libgit2/src/config_cache.c +5 -3
  97. data/vendor/libgit2/src/config_file.c +16 -8
  98. data/vendor/libgit2/src/config_parse.c +4 -6
  99. data/vendor/libgit2/src/crlf.c +16 -6
  100. data/vendor/libgit2/src/date.c +4 -3
  101. data/vendor/libgit2/src/delta.c +1 -1
  102. data/vendor/libgit2/src/describe.c +6 -3
  103. data/vendor/libgit2/src/diff.c +11 -8
  104. data/vendor/libgit2/src/diff_driver.c +21 -17
  105. data/vendor/libgit2/src/diff_file.c +2 -6
  106. data/vendor/libgit2/src/diff_generate.c +46 -17
  107. data/vendor/libgit2/src/diff_print.c +19 -6
  108. data/vendor/libgit2/src/diff_stats.c +7 -5
  109. data/vendor/libgit2/src/diff_tform.c +9 -8
  110. data/vendor/libgit2/src/diff_xdiff.c +4 -2
  111. data/vendor/libgit2/src/diff_xdiff.h +1 -1
  112. data/vendor/libgit2/src/errors.c +24 -19
  113. data/vendor/libgit2/src/features.h.in +5 -1
  114. data/vendor/libgit2/src/fetch.c +5 -2
  115. data/vendor/libgit2/src/fetchhead.c +8 -4
  116. data/vendor/libgit2/src/filebuf.c +9 -7
  117. data/vendor/libgit2/src/filter.c +206 -110
  118. data/vendor/libgit2/src/filter.h +24 -5
  119. data/vendor/libgit2/src/futils.c +5 -5
  120. data/vendor/libgit2/src/futils.h +1 -1
  121. data/vendor/libgit2/src/graph.c +64 -9
  122. data/vendor/libgit2/src/hash/sha1/collisiondetect.c +3 -3
  123. data/vendor/libgit2/src/hash/sha1/common_crypto.c +3 -3
  124. data/vendor/libgit2/src/hash/sha1/generic.h +1 -1
  125. data/vendor/libgit2/src/hash/sha1/mbedtls.c +12 -12
  126. data/vendor/libgit2/src/hash/sha1/openssl.c +3 -3
  127. data/vendor/libgit2/src/hash/sha1/sha1dc/sha1.c +0 -2
  128. data/vendor/libgit2/src/hash/sha1/win32.c +15 -11
  129. data/vendor/libgit2/src/hash.c +16 -13
  130. data/vendor/libgit2/src/hash.h +1 -1
  131. data/vendor/libgit2/src/hashsig.c +23 -10
  132. data/vendor/libgit2/src/ident.c +13 -3
  133. data/vendor/libgit2/src/ignore.c +35 -19
  134. data/vendor/libgit2/src/index.c +106 -70
  135. data/vendor/libgit2/src/index.h +1 -1
  136. data/vendor/libgit2/src/indexer.c +31 -29
  137. data/vendor/libgit2/src/integer.h +64 -2
  138. data/vendor/libgit2/src/iterator.c +36 -24
  139. data/vendor/libgit2/src/iterator.h +1 -1
  140. data/vendor/libgit2/src/khash.h +2 -11
  141. data/vendor/libgit2/src/{settings.c → libgit2.c} +117 -50
  142. data/vendor/libgit2/src/libgit2.h +15 -0
  143. data/vendor/libgit2/src/mailmap.c +23 -10
  144. data/vendor/libgit2/src/map.h +3 -3
  145. data/vendor/libgit2/src/merge.c +70 -30
  146. data/vendor/libgit2/src/merge.h +2 -1
  147. data/vendor/libgit2/src/merge_driver.c +19 -13
  148. data/vendor/libgit2/src/merge_file.c +11 -3
  149. data/vendor/libgit2/src/message.c +3 -1
  150. data/vendor/libgit2/src/midx.c +471 -10
  151. data/vendor/libgit2/src/midx.h +28 -1
  152. data/vendor/libgit2/src/mwindow.c +103 -59
  153. data/vendor/libgit2/src/mwindow.h +3 -3
  154. data/vendor/libgit2/src/net.c +127 -3
  155. data/vendor/libgit2/src/net.h +16 -2
  156. data/vendor/libgit2/src/netops.c +6 -4
  157. data/vendor/libgit2/src/netops.h +2 -2
  158. data/vendor/libgit2/src/notes.c +10 -10
  159. data/vendor/libgit2/src/object.c +22 -14
  160. data/vendor/libgit2/src/odb.c +285 -48
  161. data/vendor/libgit2/src/odb.h +16 -2
  162. data/vendor/libgit2/src/odb_loose.c +28 -18
  163. data/vendor/libgit2/src/odb_mempack.c +1 -1
  164. data/vendor/libgit2/src/odb_pack.c +391 -114
  165. data/vendor/libgit2/src/oid.c +5 -4
  166. data/vendor/libgit2/src/pack-objects.c +54 -48
  167. data/vendor/libgit2/src/pack.c +329 -119
  168. data/vendor/libgit2/src/pack.h +25 -7
  169. data/vendor/libgit2/src/patch.c +14 -7
  170. data/vendor/libgit2/src/patch_generate.c +2 -2
  171. data/vendor/libgit2/src/patch_parse.c +2 -1
  172. data/vendor/libgit2/src/path.c +98 -53
  173. data/vendor/libgit2/src/path.h +79 -6
  174. data/vendor/libgit2/src/pathspec.c +8 -8
  175. data/vendor/libgit2/src/pool.c +13 -7
  176. data/vendor/libgit2/src/posix.c +11 -3
  177. data/vendor/libgit2/src/reader.c +10 -6
  178. data/vendor/libgit2/src/rebase.c +93 -49
  179. data/vendor/libgit2/src/refdb.c +30 -13
  180. data/vendor/libgit2/src/refdb_fs.c +121 -69
  181. data/vendor/libgit2/src/reflog.c +19 -14
  182. data/vendor/libgit2/src/refs.c +76 -41
  183. data/vendor/libgit2/src/refspec.c +32 -12
  184. data/vendor/libgit2/src/remote.c +272 -102
  185. data/vendor/libgit2/src/remote.h +2 -1
  186. data/vendor/libgit2/src/repository.c +176 -103
  187. data/vendor/libgit2/src/repository.h +12 -1
  188. data/vendor/libgit2/src/reset.c +7 -6
  189. data/vendor/libgit2/src/revert.c +6 -2
  190. data/vendor/libgit2/src/revparse.c +14 -9
  191. data/vendor/libgit2/src/revwalk.c +32 -15
  192. data/vendor/libgit2/src/runtime.c +162 -0
  193. data/vendor/libgit2/src/runtime.h +62 -0
  194. data/vendor/libgit2/src/settings.h +11 -0
  195. data/vendor/libgit2/src/signature.c +6 -5
  196. data/vendor/libgit2/src/sortedcache.h +10 -8
  197. data/vendor/libgit2/src/stash.c +3 -1
  198. data/vendor/libgit2/src/status.c +7 -4
  199. data/vendor/libgit2/src/strarray.c +2 -1
  200. data/vendor/libgit2/src/streams/mbedtls.c +14 -17
  201. data/vendor/libgit2/src/streams/mbedtls.h +1 -1
  202. data/vendor/libgit2/src/streams/openssl.c +101 -201
  203. data/vendor/libgit2/src/streams/openssl.h +9 -1
  204. data/vendor/libgit2/src/streams/openssl_dynamic.c +309 -0
  205. data/vendor/libgit2/src/streams/openssl_dynamic.h +348 -0
  206. data/vendor/libgit2/src/streams/openssl_legacy.c +203 -0
  207. data/vendor/libgit2/src/streams/openssl_legacy.h +63 -0
  208. data/vendor/libgit2/src/streams/registry.c +5 -6
  209. data/vendor/libgit2/src/streams/socket.c +6 -2
  210. data/vendor/libgit2/src/streams/stransport.c +6 -3
  211. data/vendor/libgit2/src/streams/tls.c +5 -3
  212. data/vendor/libgit2/src/submodule.c +128 -62
  213. data/vendor/libgit2/src/submodule.h +9 -9
  214. data/vendor/libgit2/src/sysdir.c +4 -6
  215. data/vendor/libgit2/src/tag.c +47 -11
  216. data/vendor/libgit2/src/thread.c +140 -0
  217. data/vendor/libgit2/src/thread.h +479 -0
  218. data/vendor/libgit2/src/threadstate.c +83 -0
  219. data/vendor/libgit2/src/threadstate.h +24 -0
  220. data/vendor/libgit2/src/trace.c +2 -2
  221. data/vendor/libgit2/src/trace.h +17 -13
  222. data/vendor/libgit2/src/transaction.c +19 -8
  223. data/vendor/libgit2/src/transport.c +3 -3
  224. data/vendor/libgit2/src/transports/auth.c +1 -1
  225. data/vendor/libgit2/src/transports/auth_negotiate.c +11 -4
  226. data/vendor/libgit2/src/transports/auth_ntlm.c +10 -6
  227. data/vendor/libgit2/src/transports/credential.c +15 -7
  228. data/vendor/libgit2/src/transports/git.c +1 -3
  229. data/vendor/libgit2/src/transports/http.c +19 -17
  230. data/vendor/libgit2/src/transports/http.h +1 -0
  231. data/vendor/libgit2/src/transports/httpclient.c +53 -26
  232. data/vendor/libgit2/src/transports/httpclient.h +1 -1
  233. data/vendor/libgit2/src/transports/local.c +3 -3
  234. data/vendor/libgit2/src/transports/smart.c +12 -7
  235. data/vendor/libgit2/src/transports/smart.h +1 -1
  236. data/vendor/libgit2/src/transports/smart_protocol.c +11 -5
  237. data/vendor/libgit2/src/transports/ssh.c +51 -17
  238. data/vendor/libgit2/src/transports/winhttp.c +41 -31
  239. data/vendor/libgit2/src/tree.c +100 -77
  240. data/vendor/libgit2/src/tree.h +1 -0
  241. data/vendor/libgit2/src/tsort.c +0 -2
  242. data/vendor/libgit2/src/unix/map.c +3 -1
  243. data/vendor/libgit2/src/unix/pthread.h +2 -1
  244. data/vendor/libgit2/src/utf8.c +150 -0
  245. data/vendor/libgit2/src/utf8.h +52 -0
  246. data/vendor/libgit2/src/util.c +53 -129
  247. data/vendor/libgit2/src/util.h +33 -39
  248. data/vendor/libgit2/src/vector.c +23 -19
  249. data/vendor/libgit2/src/vector.h +4 -2
  250. data/vendor/libgit2/src/win32/findfile.c +4 -2
  251. data/vendor/libgit2/src/win32/map.c +1 -1
  252. data/vendor/libgit2/src/win32/msvc-compat.h +9 -1
  253. data/vendor/libgit2/src/win32/path_w32.c +22 -24
  254. data/vendor/libgit2/src/win32/path_w32.h +0 -1
  255. data/vendor/libgit2/src/win32/posix_w32.c +7 -1
  256. data/vendor/libgit2/src/win32/precompiled.h +0 -1
  257. data/vendor/libgit2/src/win32/reparse.h +4 -4
  258. data/vendor/libgit2/src/win32/thread.c +24 -15
  259. data/vendor/libgit2/src/win32/thread.h +1 -1
  260. data/vendor/libgit2/src/win32/w32_buffer.c +3 -3
  261. data/vendor/libgit2/src/win32/w32_common.h +18 -9
  262. data/vendor/libgit2/src/win32/{w32_crtdbg_stacktrace.c → w32_leakcheck.c} +269 -33
  263. data/vendor/libgit2/src/win32/w32_leakcheck.h +222 -0
  264. data/vendor/libgit2/src/win32/w32_util.h +6 -6
  265. data/vendor/libgit2/src/worktree.c +27 -16
  266. data/vendor/libgit2/src/zstream.c +1 -1
  267. metadata +32 -16
  268. data/vendor/libgit2/src/allocators/win32_crtdbg.c +0 -118
  269. data/vendor/libgit2/src/buf_text.c +0 -316
  270. data/vendor/libgit2/src/buf_text.h +0 -122
  271. data/vendor/libgit2/src/global.c +0 -363
  272. data/vendor/libgit2/src/global.h +0 -41
  273. data/vendor/libgit2/src/thread-utils.c +0 -58
  274. data/vendor/libgit2/src/thread-utils.h +0 -369
  275. data/vendor/libgit2/src/win32/w32_crtdbg_stacktrace.h +0 -127
  276. data/vendor/libgit2/src/win32/w32_stack.c +0 -188
  277. data/vendor/libgit2/src/win32/w32_stack.h +0 -140
@@ -86,6 +86,7 @@ static struct map_data _configmaps[] = {
86
86
  {"core.protecthfs", NULL, 0, GIT_PROTECTHFS_DEFAULT },
87
87
  {"core.protectntfs", NULL, 0, GIT_PROTECTNTFS_DEFAULT },
88
88
  {"core.fsyncobjectfiles", NULL, 0, GIT_FSYNCOBJECTFILES_DEFAULT },
89
+ {"core.longpaths", NULL, 0, GIT_LONGPATHS_DEFAULT },
89
90
  };
90
91
 
91
92
  int git_config__configmap_lookup(int *out, git_config *config, git_configmap_item item)
@@ -111,20 +112,21 @@ int git_config__configmap_lookup(int *out, git_config *config, git_configmap_ite
111
112
 
112
113
  int git_repository__configmap_lookup(int *out, git_repository *repo, git_configmap_item item)
113
114
  {
114
- intptr_t value = repo->configmap_cache[(int)item];
115
+ intptr_t value = (intptr_t)git_atomic_load(repo->configmap_cache[(int)item]);
115
116
 
116
117
  *out = (int)value;
117
118
 
118
119
  if (value == GIT_CONFIGMAP_NOT_CACHED) {
119
- int error;
120
120
  git_config *config;
121
+ intptr_t oldval = value;
122
+ int error;
121
123
 
122
124
  if ((error = git_repository_config__weakptr(&config, repo)) < 0 ||
123
125
  (error = git_config__configmap_lookup(out, config, item)) < 0)
124
126
  return error;
125
127
 
126
128
  value = *out;
127
- repo->configmap_cache[(int)item] = value;
129
+ git_atomic_compare_and_swap(&repo->configmap_cache[(int)item], (void *)oldval, (void *)value);
128
130
  }
129
131
 
130
132
  return 0;
@@ -164,23 +164,27 @@ out:
164
164
  return error;
165
165
  }
166
166
 
167
+ static void config_file_clear_includes(config_file_backend* cfg)
168
+ {
169
+ config_file *include;
170
+ uint32_t i;
171
+
172
+ git_array_foreach(cfg->file.includes, i, include)
173
+ config_file_clear(include);
174
+ git_array_clear(cfg->file.includes);
175
+ }
176
+
167
177
  static int config_file_set_entries(git_config_backend *cfg, git_config_entries *entries)
168
178
  {
169
179
  config_file_backend *b = GIT_CONTAINER_OF(cfg, config_file_backend, parent);
170
180
  git_config_entries *old = NULL;
171
- config_file *include;
172
181
  int error;
173
- uint32_t i;
174
182
 
175
183
  if (b->parent.readonly) {
176
184
  git_error_set(GIT_ERROR_CONFIG, "this backend is read-only");
177
185
  return -1;
178
186
  }
179
187
 
180
- git_array_foreach(b->file.includes, i, include)
181
- config_file_clear(include);
182
- git_array_clear(b->file.includes);
183
-
184
188
  if ((error = git_mutex_lock(&b->values_mutex)) < 0) {
185
189
  git_error_set(GIT_ERROR_OS, "failed to lock config backend");
186
190
  goto out;
@@ -202,6 +206,8 @@ static int config_file_refresh_from_buffer(git_config_backend *cfg, const char *
202
206
  git_config_entries *entries = NULL;
203
207
  int error;
204
208
 
209
+ config_file_clear_includes(b);
210
+
205
211
  if ((error = git_config_entries_new(&entries)) < 0 ||
206
212
  (error = config_file_read_buffer(entries, b->repo, &b->file,
207
213
  b->level, 0, buf, buflen)) < 0 ||
@@ -229,6 +235,8 @@ static int config_file_refresh(git_config_backend *cfg)
229
235
  if (!modified)
230
236
  return 0;
231
237
 
238
+ config_file_clear_includes(b);
239
+
232
240
  if ((error = git_config_entries_new(&entries)) < 0 ||
233
241
  (error = config_file_read(entries, b->repo, &b->file, b->level, 0)) < 0 ||
234
242
  (error = config_file_set_entries(cfg, entries)) < 0)
@@ -365,7 +373,7 @@ static int config_file_set_multivar(
365
373
  int result;
366
374
  char *key;
367
375
 
368
- assert(regexp);
376
+ GIT_ASSERT_ARG(regexp);
369
377
 
370
378
  if ((result = git_config__normalize_name(name, &key)) < 0)
371
379
  return result;
@@ -531,7 +539,7 @@ static char *escape_value(const char *ptr)
531
539
  size_t len;
532
540
  const char *esc;
533
541
 
534
- assert(ptr);
542
+ GIT_ASSERT_ARG_WITH_RETVAL(ptr, NULL);
535
543
 
536
544
  len = strlen(ptr);
537
545
  if (!len)
@@ -7,8 +7,6 @@
7
7
 
8
8
  #include "config_parse.h"
9
9
 
10
- #include "buf_text.h"
11
-
12
10
  #include <ctype.h>
13
11
 
14
12
  const char *git_config_escapes = "ntb\"\\";
@@ -187,7 +185,7 @@ static int parse_section_header(git_config_parser *reader, char **section_out)
187
185
 
188
186
  /* Make sure we were given a section header */
189
187
  c = line[pos++];
190
- assert(c == '[');
188
+ GIT_ASSERT(c == '[');
191
189
 
192
190
  c = line[pos++];
193
191
 
@@ -230,10 +228,10 @@ fail_parse:
230
228
  static int skip_bom(git_parse_ctx *parser)
231
229
  {
232
230
  git_buf buf = GIT_BUF_INIT_CONST(parser->content, parser->content_len);
233
- git_bom_t bom;
234
- int bom_offset = git_buf_text_detect_bom(&bom, &buf);
231
+ git_buf_bom_t bom;
232
+ int bom_offset = git_buf_detect_bom(&bom, &buf);
235
233
 
236
- if (bom == GIT_BOM_UTF8)
234
+ if (bom == GIT_BUF_BOM_UTF8)
237
235
  git_parse_advance_chars(parser, bom_offset);
238
236
 
239
237
  /* TODO: reference implementation is pretty stupid with BoM */
@@ -15,7 +15,6 @@
15
15
  #include "futils.h"
16
16
  #include "hash.h"
17
17
  #include "filter.h"
18
- #include "buf_text.h"
19
18
  #include "repository.h"
20
19
 
21
20
  typedef enum {
@@ -219,7 +218,7 @@ static int crlf_apply_to_odb(
219
218
  if (ca->crlf_action == GIT_CRLF_BINARY || !git_buf_len(from))
220
219
  return GIT_PASSTHROUGH;
221
220
 
222
- is_binary = git_buf_text_gather_stats(&stats, from, false);
221
+ is_binary = git_buf_gather_text_stats(&stats, from, false);
223
222
 
224
223
  /* Heuristics to see if we can skip the conversion.
225
224
  * Straight from Core Git.
@@ -247,7 +246,7 @@ static int crlf_apply_to_odb(
247
246
  return GIT_PASSTHROUGH;
248
247
 
249
248
  /* Actually drop the carriage returns */
250
- return git_buf_text_crlf_to_lf(to, from);
249
+ return git_buf_crlf_to_lf(to, from);
251
250
  }
252
251
 
253
252
  static int crlf_apply_to_workdir(
@@ -262,7 +261,7 @@ static int crlf_apply_to_workdir(
262
261
  if (git_buf_len(from) == 0 || output_eol(ca) != GIT_EOL_CRLF)
263
262
  return GIT_PASSTHROUGH;
264
263
 
265
- is_binary = git_buf_text_gather_stats(&stats, from, false);
264
+ is_binary = git_buf_gather_text_stats(&stats, from, false);
266
265
 
267
266
  /* If there are no LFs, or all LFs are part of a CRLF, nothing to do */
268
267
  if (stats.lf == 0 || stats.lf == stats.crlf)
@@ -281,7 +280,7 @@ static int crlf_apply_to_workdir(
281
280
  return GIT_PASSTHROUGH;
282
281
  }
283
282
 
284
- return git_buf_text_lf_to_crlf(to, from);
283
+ return git_buf_lf_to_crlf(to, from);
285
284
  }
286
285
 
287
286
  static int convert_attrs(
@@ -387,6 +386,17 @@ static int crlf_apply(
387
386
  return crlf_apply_to_odb(*payload, to, from, src);
388
387
  }
389
388
 
389
+ static int crlf_stream(
390
+ git_writestream **out,
391
+ git_filter *self,
392
+ void **payload,
393
+ const git_filter_source *src,
394
+ git_writestream *next)
395
+ {
396
+ return git_filter_buffered_stream_new(out,
397
+ self, crlf_apply, NULL, payload, src, next);
398
+ }
399
+
390
400
  static void crlf_cleanup(
391
401
  git_filter *self,
392
402
  void *payload)
@@ -406,7 +416,7 @@ git_filter *git_crlf_filter_new(void)
406
416
  f->f.initialize = NULL;
407
417
  f->f.shutdown = git_filter_free;
408
418
  f->f.check = crlf_check;
409
- f->f.apply = crlf_apply;
419
+ f->f.stream = crlf_stream;
410
420
  f->f.cleanup = crlf_cleanup;
411
421
 
412
422
  return (git_filter *)f;
@@ -204,7 +204,7 @@ static int is_date(int year, int month, int day, struct tm *now_tm, time_t now,
204
204
  if (month > 0 && month < 13 && day > 0 && day < 32) {
205
205
  struct tm check = *tm;
206
206
  struct tm *r = (now_tm ? &check : tm);
207
- time_t specified;
207
+ git_time_t specified;
208
208
 
209
209
  r->tm_mon = month - 1;
210
210
  r->tm_mday = day;
@@ -722,7 +722,7 @@ static const char *approxidate_alpha(const char *date, struct tm *tm, struct tm
722
722
  while (tl->type) {
723
723
  size_t len = strlen(tl->type);
724
724
  if (match_string(date, tl->type) >= len-1) {
725
- update_tm(tm, now, tl->length * *num);
725
+ update_tm(tm, now, tl->length * (unsigned long)*num);
726
726
  *num = 0;
727
727
  *touched = 1;
728
728
  return end;
@@ -881,7 +881,8 @@ int git__date_rfc2822_fmt(char *out, size_t len, const git_time *date)
881
881
  struct tm gmt;
882
882
  time_t t;
883
883
 
884
- assert(out && date);
884
+ GIT_ASSERT_ARG(out);
885
+ GIT_ASSERT_ARG(date);
885
886
 
886
887
  t = (time_t) (date->time + date->offset * 60);
887
888
 
@@ -256,7 +256,7 @@ void git_delta_index_free(git_delta_index *index)
256
256
 
257
257
  size_t git_delta_index_size(git_delta_index *index)
258
258
  {
259
- assert(index);
259
+ GIT_ASSERT_ARG(index);
260
260
 
261
261
  return index->memsize;
262
262
  }
@@ -655,7 +655,8 @@ int git_describe_commit(
655
655
  int error = -1;
656
656
  git_describe_options normalized;
657
657
 
658
- assert(committish);
658
+ GIT_ASSERT_ARG(result);
659
+ GIT_ASSERT_ARG(committish);
659
660
 
660
661
  data.result = git__calloc(1, sizeof(git_describe_result));
661
662
  GIT_ERROR_CHECK_ALLOC(data.result);
@@ -775,12 +776,14 @@ int git_describe_format(git_buf *out, const git_describe_result *result, const g
775
776
  struct commit_name *name;
776
777
  git_describe_format_options opts;
777
778
 
778
- assert(out && result);
779
+ GIT_ASSERT_ARG(out);
780
+ GIT_ASSERT_ARG(result);
779
781
 
780
782
  GIT_ERROR_CHECK_VERSION(given, GIT_DESCRIBE_FORMAT_OPTIONS_VERSION, "git_describe_format_options");
781
783
  normalize_format_options(&opts, given);
782
784
 
783
- git_buf_sanitize(out);
785
+ if ((error = git_buf_sanitize(out)) < 0)
786
+ return error;
784
787
 
785
788
 
786
789
  if (opts.always_use_long_format && opts.abbreviated_size == 0) {
@@ -77,7 +77,7 @@ void git_diff_addref(git_diff *diff)
77
77
 
78
78
  size_t git_diff_num_deltas(const git_diff *diff)
79
79
  {
80
- assert(diff);
80
+ GIT_ASSERT_ARG(diff);
81
81
  return diff->deltas.length;
82
82
  }
83
83
 
@@ -86,7 +86,7 @@ size_t git_diff_num_deltas_of_type(const git_diff *diff, git_delta_t type)
86
86
  size_t i, count = 0;
87
87
  const git_diff_delta *delta;
88
88
 
89
- assert(diff);
89
+ GIT_ASSERT_ARG(diff);
90
90
 
91
91
  git_vector_foreach(&diff->deltas, i, delta) {
92
92
  count += (delta->status == type);
@@ -97,7 +97,7 @@ size_t git_diff_num_deltas_of_type(const git_diff *diff, git_delta_t type)
97
97
 
98
98
  const git_diff_delta *git_diff_get_delta(const git_diff *diff, size_t idx)
99
99
  {
100
- assert(diff);
100
+ GIT_ASSERT_ARG_WITH_RETVAL(diff, NULL);
101
101
  return git_vector_get(&diff->deltas, idx);
102
102
  }
103
103
 
@@ -108,7 +108,7 @@ int git_diff_is_sorted_icase(const git_diff *diff)
108
108
 
109
109
  int git_diff_get_perfdata(git_diff_perfdata *out, const git_diff *diff)
110
110
  {
111
- assert(out);
111
+ GIT_ASSERT_ARG(out);
112
112
  GIT_ERROR_CHECK_VERSION(out, GIT_DIFF_PERFDATA_VERSION, "git_diff_perfdata");
113
113
  out->stat_calls = diff->perf.stat_calls;
114
114
  out->oid_calculations = diff->perf.oid_calculations;
@@ -127,7 +127,7 @@ int git_diff_foreach(
127
127
  git_diff_delta *delta;
128
128
  size_t idx;
129
129
 
130
- assert(diff);
130
+ GIT_ASSERT_ARG(diff);
131
131
 
132
132
  git_vector_foreach(&diff->deltas, idx, delta) {
133
133
  git_patch *patch;
@@ -243,8 +243,9 @@ int git_diff_format_email(
243
243
  size_t allocsize;
244
244
  int error;
245
245
 
246
- assert(out && diff && opts);
247
- assert(opts->summary && opts->id && opts->author);
246
+ GIT_ASSERT_ARG(out);
247
+ GIT_ASSERT_ARG(diff);
248
+ GIT_ASSERT_ARG(opts && opts->summary && opts->id && opts->author);
248
249
 
249
250
  GIT_ERROR_CHECK_VERSION(opts,
250
251
  GIT_DIFF_FORMAT_EMAIL_OPTIONS_VERSION,
@@ -326,7 +327,9 @@ int git_diff_commit_as_email(
326
327
  GIT_DIFF_FORMAT_EMAIL_OPTIONS_INIT;
327
328
  int error;
328
329
 
329
- assert (out && repo && commit);
330
+ GIT_ASSERT_ARG(out);
331
+ GIT_ASSERT_ARG(repo);
332
+ GIT_ASSERT_ARG(commit);
330
333
 
331
334
  opts.flags = flags;
332
335
  opts.patch_no = patch_no;
@@ -13,7 +13,6 @@
13
13
  #include "diff.h"
14
14
  #include "strmap.h"
15
15
  #include "map.h"
16
- #include "buf_text.h"
17
16
  #include "config.h"
18
17
  #include "regexp.h"
19
18
  #include "repository.h"
@@ -142,18 +141,23 @@ static int diff_driver_funcname(const git_config_entry *entry, void *payload)
142
141
  static git_diff_driver_registry *git_repository_driver_registry(
143
142
  git_repository *repo)
144
143
  {
145
- if (!repo->diff_drivers) {
146
- git_diff_driver_registry *reg = git_diff_driver_registry_new();
147
- reg = git__compare_and_swap(&repo->diff_drivers, NULL, reg);
144
+ git_diff_driver_registry *reg = git_atomic_load(repo->diff_drivers), *newreg;
145
+ if (reg)
146
+ return reg;
148
147
 
149
- if (reg != NULL) /* if we race, free losing allocation */
150
- git_diff_driver_registry_free(reg);
151
- }
152
-
153
- if (!repo->diff_drivers)
148
+ newreg = git_diff_driver_registry_new();
149
+ if (!newreg) {
154
150
  git_error_set(GIT_ERROR_REPOSITORY, "unable to create diff driver registry");
155
-
156
- return repo->diff_drivers;
151
+ return newreg;
152
+ }
153
+ reg = git_atomic_compare_and_swap(&repo->diff_drivers, NULL, newreg);
154
+ if (!reg) {
155
+ reg = newreg;
156
+ } else {
157
+ /* if we race, free losing allocation */
158
+ git_diff_driver_registry_free(newreg);
159
+ }
160
+ return reg;
157
161
  }
158
162
 
159
163
  static int diff_driver_alloc(
@@ -358,7 +362,7 @@ int git_diff_driver_lookup(
358
362
  int error = 0;
359
363
  const char *values[1], *attrs[] = { "diff" };
360
364
 
361
- assert(out);
365
+ GIT_ASSERT_ARG(out);
362
366
  *out = NULL;
363
367
 
364
368
  if (!repo || !path || !strlen(path))
@@ -390,13 +394,13 @@ int git_diff_driver_lookup(
390
394
 
391
395
  void git_diff_driver_free(git_diff_driver *driver)
392
396
  {
393
- size_t i;
397
+ git_diff_driver_pattern *pat;
394
398
 
395
399
  if (!driver)
396
400
  return;
397
401
 
398
- for (i = 0; i < git_array_size(driver->fn_patterns); ++i)
399
- git_regexp_dispose(& git_array_get(driver->fn_patterns, i)->re);
402
+ while ((pat = git_array_pop(driver->fn_patterns)) != NULL)
403
+ git_regexp_dispose(&pat->re);
400
404
  git_array_clear(driver->fn_patterns);
401
405
 
402
406
  git_regexp_dispose(&driver->word_pattern);
@@ -428,8 +432,8 @@ int git_diff_driver_content_is_binary(
428
432
  * let's just use the simple NUL-byte detection that core git uses.
429
433
  */
430
434
 
431
- /* previously was: if (git_buf_text_is_binary(&search)) */
432
- if (git_buf_text_contains_nul(&search))
435
+ /* previously was: if (git_buf_is_binary(&search)) */
436
+ if (git_buf_contains_nul(&search))
433
437
  return 1;
434
438
 
435
439
  return 0;
@@ -362,10 +362,7 @@ static int diff_file_content_load_workdir_file(
362
362
  if (!(error = git_futils_readbuffer_fd(&raw, fd, (size_t)fc->file->size))) {
363
363
  git_buf out = GIT_BUF_INIT;
364
364
 
365
- error = git_filter_list_apply_to_data(&out, fl, &raw);
366
-
367
- if (out.ptr != raw.ptr)
368
- git_buf_dispose(&raw);
365
+ error = git_filter_list__convert_buf(&out, fl, &raw);
369
366
 
370
367
  if (!error) {
371
368
  fc->map.len = out.size;
@@ -394,8 +391,7 @@ static int diff_file_content_load_workdir(
394
391
  if (fc->file->mode == GIT_FILEMODE_TREE)
395
392
  return 0;
396
393
 
397
- if (git_buf_joinpath(
398
- &path, git_repository_workdir(fc->repo), fc->file->path) < 0)
394
+ if (git_repository_workdir_path(&path, fc->repo, fc->file->path) < 0)
399
395
  return -1;
400
396
 
401
397
  if (S_ISLNK(fc->file->mode))
@@ -128,7 +128,7 @@ static int diff_delta__from_one(
128
128
  git_diff_delta *delta;
129
129
  const char *matched_pathspec;
130
130
 
131
- assert((oitem != NULL) ^ (nitem != NULL));
131
+ GIT_ASSERT_ARG((oitem != NULL) ^ (nitem != NULL));
132
132
 
133
133
  if (oitem) {
134
134
  entry = oitem;
@@ -160,7 +160,7 @@ static int diff_delta__from_one(
160
160
  GIT_ERROR_CHECK_ALLOC(delta);
161
161
 
162
162
  /* This fn is just for single-sided diffs */
163
- assert(status != GIT_DELTA_MODIFIED);
163
+ GIT_ASSERT(status != GIT_DELTA_MODIFIED);
164
164
  delta->nfiles = 1;
165
165
 
166
166
  if (has_old) {
@@ -408,7 +408,9 @@ static git_diff_generated *diff_generated_alloc(
408
408
  git_diff_generated *diff;
409
409
  git_diff_options dflt = GIT_DIFF_OPTIONS_INIT;
410
410
 
411
- assert(repo && old_iter && new_iter);
411
+ GIT_ASSERT_ARG_WITH_RETVAL(repo, NULL);
412
+ GIT_ASSERT_ARG_WITH_RETVAL(old_iter, NULL);
413
+ GIT_ASSERT_ARG_WITH_RETVAL(new_iter, NULL);
412
414
 
413
415
  if ((diff = git__calloc(1, sizeof(git_diff_generated))) == NULL)
414
416
  return NULL;
@@ -589,13 +591,12 @@ int git_diff__oid_for_entry(
589
591
  git_filter_list *fl = NULL;
590
592
  int error = 0;
591
593
 
592
- assert(d->type == GIT_DIFF_TYPE_GENERATED);
594
+ GIT_ASSERT(d->type == GIT_DIFF_TYPE_GENERATED);
593
595
  diff = (git_diff_generated *)d;
594
596
 
595
597
  memset(out, 0, sizeof(*out));
596
598
 
597
- if (git_buf_joinpath(&full_path,
598
- git_repository_workdir(diff->base.repo), entry.path) < 0)
599
+ if (git_repository_workdir_path(&full_path, diff->base.repo, entry.path) < 0)
599
600
  return -1;
600
601
 
601
602
  if (!mode) {
@@ -678,6 +679,8 @@ typedef struct {
678
679
  git_iterator *new_iter;
679
680
  const git_index_entry *oitem;
680
681
  const git_index_entry *nitem;
682
+ git_strmap *submodule_cache;
683
+ bool submodule_cache_initialized;
681
684
  } diff_in_progress;
682
685
 
683
686
  #define MODE_BITS_MASK 0000777
@@ -692,6 +695,7 @@ static int maybe_modified_submodule(
692
695
  git_submodule *sub;
693
696
  unsigned int sm_status = 0;
694
697
  git_submodule_ignore_t ign = diff->base.opts.ignore_submodules;
698
+ git_strmap *submodule_cache = NULL;
695
699
 
696
700
  *status = GIT_DELTA_UNMODIFIED;
697
701
 
@@ -699,8 +703,23 @@ static int maybe_modified_submodule(
699
703
  ign == GIT_SUBMODULE_IGNORE_ALL)
700
704
  return 0;
701
705
 
702
- if ((error = git_submodule_lookup(
703
- &sub, diff->base.repo, info->nitem->path)) < 0) {
706
+ if (diff->base.repo->submodule_cache != NULL) {
707
+ submodule_cache = diff->base.repo->submodule_cache;
708
+ } else {
709
+ if (!info->submodule_cache_initialized) {
710
+ info->submodule_cache_initialized = true;
711
+ /*
712
+ * Try to cache the submodule information to avoid having to parse it for
713
+ * every submodule. It is okay if it fails, the cache will still be NULL
714
+ * and the submodules will be attempted to be looked up individually.
715
+ */
716
+ git_submodule_cache_init(&info->submodule_cache, diff->base.repo);
717
+ }
718
+ submodule_cache = info->submodule_cache;
719
+ }
720
+
721
+ if ((error = git_submodule__lookup_with_cache(
722
+ &sub, diff->base.repo, info->nitem->path, submodule_cache)) < 0) {
704
723
 
705
724
  /* GIT_EEXISTS means dir with .git in it was found - ignore it */
706
725
  if (error == GIT_EEXISTS) {
@@ -1190,7 +1209,7 @@ int git_diff__from_iterators(
1190
1209
  const git_diff_options *opts)
1191
1210
  {
1192
1211
  git_diff_generated *diff;
1193
- diff_in_progress info;
1212
+ diff_in_progress info = {0};
1194
1213
  int error = 0;
1195
1214
 
1196
1215
  *out = NULL;
@@ -1204,8 +1223,9 @@ int git_diff__from_iterators(
1204
1223
 
1205
1224
  /* make iterators have matching icase behavior */
1206
1225
  if (DIFF_FLAG_IS_SET(diff, GIT_DIFF_IGNORE_CASE)) {
1207
- git_iterator_set_ignore_case(old_iter, true);
1208
- git_iterator_set_ignore_case(new_iter, true);
1226
+ if ((error = git_iterator_set_ignore_case(old_iter, true)) < 0 ||
1227
+ (error = git_iterator_set_ignore_case(new_iter, true)) < 0)
1228
+ goto cleanup;
1209
1229
  }
1210
1230
 
1211
1231
  /* finish initialization */
@@ -1257,6 +1277,8 @@ cleanup:
1257
1277
  *out = &diff->base;
1258
1278
  else
1259
1279
  git_diff_free(&diff->base);
1280
+ if (info.submodule_cache)
1281
+ git_submodule_cache_free(info.submodule_cache);
1260
1282
 
1261
1283
  return error;
1262
1284
  }
@@ -1302,7 +1324,8 @@ int git_diff_tree_to_tree(
1302
1324
  char *prefix = NULL;
1303
1325
  int error = 0;
1304
1326
 
1305
- assert(out && repo);
1327
+ GIT_ASSERT_ARG(out);
1328
+ GIT_ASSERT_ARG(repo);
1306
1329
 
1307
1330
  *out = NULL;
1308
1331
 
@@ -1358,7 +1381,8 @@ int git_diff_tree_to_index(
1358
1381
  bool index_ignore_case = false;
1359
1382
  int error = 0;
1360
1383
 
1361
- assert(out && repo);
1384
+ GIT_ASSERT_ARG(out);
1385
+ GIT_ASSERT_ARG(repo);
1362
1386
 
1363
1387
  *out = NULL;
1364
1388
 
@@ -1401,7 +1425,8 @@ int git_diff_index_to_workdir(
1401
1425
  char *prefix = NULL;
1402
1426
  int error = 0;
1403
1427
 
1404
- assert(out && repo);
1428
+ GIT_ASSERT_ARG(out);
1429
+ GIT_ASSERT_ARG(repo);
1405
1430
 
1406
1431
  *out = NULL;
1407
1432
 
@@ -1444,7 +1469,8 @@ int git_diff_tree_to_workdir(
1444
1469
  git_index *index;
1445
1470
  int error;
1446
1471
 
1447
- assert(out && repo);
1472
+ GIT_ASSERT_ARG(out);
1473
+ GIT_ASSERT_ARG(repo);
1448
1474
 
1449
1475
  *out = NULL;
1450
1476
 
@@ -1477,7 +1503,8 @@ int git_diff_tree_to_workdir_with_index(
1477
1503
  git_index *index = NULL;
1478
1504
  int error = 0;
1479
1505
 
1480
- assert(out && repo);
1506
+ GIT_ASSERT_ARG(out);
1507
+ GIT_ASSERT_ARG(repo);
1481
1508
 
1482
1509
  *out = NULL;
1483
1510
 
@@ -1513,7 +1540,9 @@ int git_diff_index_to_index(
1513
1540
  char *prefix = NULL;
1514
1541
  int error;
1515
1542
 
1516
- assert(out && old_index && new_index);
1543
+ GIT_ASSERT_ARG(out);
1544
+ GIT_ASSERT_ARG(old_index);
1545
+ GIT_ASSERT_ARG(new_index);
1517
1546
 
1518
1547
  *out = NULL;
1519
1548