rugged 1.1.1 → 1.4.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (407) hide show
  1. checksums.yaml +4 -4
  2. data/LICENSE +1 -0
  3. data/README.md +1 -1
  4. data/ext/rugged/extconf.rb +2 -2
  5. data/ext/rugged/rugged.c +7 -4
  6. data/ext/rugged/rugged_config.c +7 -2
  7. data/ext/rugged/rugged_object.c +1 -1
  8. data/ext/rugged/rugged_remote.c +17 -0
  9. data/ext/rugged/rugged_repo.c +3 -3
  10. data/lib/rugged/repository.rb +2 -2
  11. data/lib/rugged/version.rb +1 -1
  12. data/vendor/libgit2/CMakeLists.txt +103 -271
  13. data/vendor/libgit2/COPYING +149 -24
  14. data/vendor/libgit2/cmake/AddCFlagIfSupported.cmake +21 -21
  15. data/vendor/libgit2/cmake/DefaultCFlags.cmake +154 -0
  16. data/vendor/libgit2/cmake/EnableWarnings.cmake +13 -13
  17. data/vendor/libgit2/cmake/FindCoreFoundation.cmake +13 -13
  18. data/vendor/libgit2/cmake/FindGSSAPI.cmake +171 -287
  19. data/vendor/libgit2/cmake/FindGSSFramework.cmake +13 -13
  20. data/vendor/libgit2/cmake/{FindHTTP_Parser.cmake → FindHTTPParser.cmake} +17 -17
  21. data/vendor/libgit2/cmake/FindIconv.cmake +27 -27
  22. data/vendor/libgit2/cmake/FindLibSSH2.cmake +13 -0
  23. data/vendor/libgit2/cmake/FindPCRE.cmake +13 -13
  24. data/vendor/libgit2/cmake/FindPCRE2.cmake +12 -12
  25. data/vendor/libgit2/cmake/FindPkgLibraries.cmake +19 -19
  26. data/vendor/libgit2/cmake/FindSecurity.cmake +14 -14
  27. data/vendor/libgit2/cmake/FindStatNsec.cmake +12 -18
  28. data/vendor/libgit2/cmake/Findfutimens.cmake +14 -0
  29. data/vendor/libgit2/cmake/FindmbedTLS.cmake +63 -70
  30. data/vendor/libgit2/cmake/IdeSplitSources.cmake +18 -18
  31. data/vendor/libgit2/cmake/PkgBuildConfig.cmake +60 -60
  32. data/vendor/libgit2/cmake/SanitizeBool.cmake +20 -20
  33. data/vendor/libgit2/cmake/SelectGSSAPI.cmake +37 -37
  34. data/vendor/libgit2/cmake/SelectHTTPParser.cmake +19 -0
  35. data/vendor/libgit2/cmake/SelectHTTPSBackend.cmake +100 -96
  36. data/vendor/libgit2/cmake/SelectHashes.cmake +39 -48
  37. data/vendor/libgit2/cmake/SelectRegex.cmake +51 -0
  38. data/vendor/libgit2/cmake/SelectSSH.cmake +41 -0
  39. data/vendor/libgit2/cmake/SelectWinHTTP.cmake +17 -0
  40. data/vendor/libgit2/cmake/SelectZlib.cmake +34 -0
  41. data/vendor/libgit2/deps/chromium-zlib/CMakeLists.txt +101 -0
  42. data/vendor/libgit2/deps/ntlmclient/CMakeLists.txt +32 -20
  43. data/vendor/libgit2/deps/ntlmclient/crypt.h +14 -9
  44. data/vendor/libgit2/deps/ntlmclient/crypt_commoncrypto.c +20 -20
  45. data/vendor/libgit2/deps/ntlmclient/crypt_commoncrypto.h +3 -3
  46. data/vendor/libgit2/deps/ntlmclient/crypt_mbedtls.c +37 -36
  47. data/vendor/libgit2/deps/ntlmclient/crypt_mbedtls.h +4 -3
  48. data/vendor/libgit2/deps/ntlmclient/crypt_openssl.c +178 -51
  49. data/vendor/libgit2/deps/ntlmclient/crypt_openssl.h +74 -5
  50. data/vendor/libgit2/deps/ntlmclient/ntlm.c +154 -122
  51. data/vendor/libgit2/deps/ntlmclient/ntlm.h +17 -13
  52. data/vendor/libgit2/deps/ntlmclient/ntlmclient.h +17 -4
  53. data/vendor/libgit2/deps/ntlmclient/unicode.h +10 -4
  54. data/vendor/libgit2/deps/ntlmclient/unicode_builtin.c +16 -27
  55. data/vendor/libgit2/deps/ntlmclient/unicode_builtin.h +20 -0
  56. data/vendor/libgit2/deps/ntlmclient/unicode_iconv.c +28 -52
  57. data/vendor/libgit2/deps/ntlmclient/unicode_iconv.h +22 -0
  58. data/vendor/libgit2/deps/pcre/CMakeLists.txt +88 -88
  59. data/vendor/libgit2/deps/winhttp/CMakeLists.txt +14 -16
  60. data/vendor/libgit2/include/git2/apply.h +16 -2
  61. data/vendor/libgit2/include/git2/attr.h +106 -2
  62. data/vendor/libgit2/include/git2/blame.h +97 -43
  63. data/vendor/libgit2/include/git2/blob.h +33 -2
  64. data/vendor/libgit2/include/git2/branch.h +27 -0
  65. data/vendor/libgit2/include/git2/buffer.h +18 -78
  66. data/vendor/libgit2/include/git2/cert.h +43 -6
  67. data/vendor/libgit2/include/git2/checkout.h +32 -13
  68. data/vendor/libgit2/include/git2/clone.h +4 -4
  69. data/vendor/libgit2/include/git2/commit.h +37 -19
  70. data/vendor/libgit2/include/git2/common.h +46 -5
  71. data/vendor/libgit2/include/git2/config.h +19 -3
  72. data/vendor/libgit2/include/git2/credential.h +2 -1
  73. data/vendor/libgit2/include/git2/credential_helpers.h +1 -0
  74. data/vendor/libgit2/include/git2/deprecated.h +326 -6
  75. data/vendor/libgit2/include/git2/describe.h +7 -2
  76. data/vendor/libgit2/include/git2/diff.h +50 -121
  77. data/vendor/libgit2/include/git2/email.h +127 -0
  78. data/vendor/libgit2/include/git2/errors.h +7 -6
  79. data/vendor/libgit2/include/git2/filter.h +69 -18
  80. data/vendor/libgit2/include/git2/graph.h +21 -2
  81. data/vendor/libgit2/include/git2/ignore.h +1 -1
  82. data/vendor/libgit2/include/git2/index.h +13 -7
  83. data/vendor/libgit2/include/git2/indexer.h +19 -0
  84. data/vendor/libgit2/include/git2/merge.h +23 -3
  85. data/vendor/libgit2/include/git2/message.h +2 -0
  86. data/vendor/libgit2/include/git2/notes.h +2 -2
  87. data/vendor/libgit2/include/git2/object.h +23 -0
  88. data/vendor/libgit2/include/git2/odb.h +65 -6
  89. data/vendor/libgit2/include/git2/odb_backend.h +1 -1
  90. data/vendor/libgit2/include/git2/oidarray.h +5 -8
  91. data/vendor/libgit2/include/git2/pack.h +24 -8
  92. data/vendor/libgit2/include/git2/patch.h +16 -0
  93. data/vendor/libgit2/include/git2/pathspec.h +1 -1
  94. data/vendor/libgit2/include/git2/proxy.h +1 -1
  95. data/vendor/libgit2/include/git2/rebase.h +34 -2
  96. data/vendor/libgit2/include/git2/refdb.h +3 -0
  97. data/vendor/libgit2/include/git2/reflog.h +1 -1
  98. data/vendor/libgit2/include/git2/refs.h +8 -4
  99. data/vendor/libgit2/include/git2/remote.h +246 -46
  100. data/vendor/libgit2/include/git2/repository.h +25 -18
  101. data/vendor/libgit2/include/git2/reset.h +2 -2
  102. data/vendor/libgit2/include/git2/revparse.h +5 -5
  103. data/vendor/libgit2/include/git2/revwalk.h +4 -1
  104. data/vendor/libgit2/include/git2/signature.h +1 -1
  105. data/vendor/libgit2/include/git2/stash.h +4 -4
  106. data/vendor/libgit2/include/git2/status.h +124 -62
  107. data/vendor/libgit2/include/git2/stdint.h +3 -3
  108. data/vendor/libgit2/include/git2/submodule.h +16 -2
  109. data/vendor/libgit2/include/git2/sys/commit_graph.h +174 -0
  110. data/vendor/libgit2/include/git2/sys/email.h +45 -0
  111. data/vendor/libgit2/include/git2/sys/filter.h +49 -28
  112. data/vendor/libgit2/include/git2/sys/midx.h +74 -0
  113. data/vendor/libgit2/include/git2/sys/odb_backend.h +9 -5
  114. data/vendor/libgit2/include/git2/sys/remote.h +31 -0
  115. data/vendor/libgit2/include/git2/sys/stream.h +1 -1
  116. data/vendor/libgit2/include/git2/sys/transport.h +26 -34
  117. data/vendor/libgit2/include/git2/tag.h +13 -0
  118. data/vendor/libgit2/include/git2/tree.h +4 -17
  119. data/vendor/libgit2/include/git2/types.h +16 -7
  120. data/vendor/libgit2/include/git2/version.h +4 -4
  121. data/vendor/libgit2/include/git2/worktree.h +13 -2
  122. data/vendor/libgit2/include/git2.h +1 -0
  123. data/vendor/libgit2/src/CMakeLists.txt +192 -290
  124. data/vendor/libgit2/src/alloc.c +21 -8
  125. data/vendor/libgit2/src/allocators/failalloc.c +92 -0
  126. data/vendor/libgit2/src/allocators/failalloc.h +23 -0
  127. data/vendor/libgit2/src/allocators/stdalloc.c +41 -10
  128. data/vendor/libgit2/src/allocators/win32_leakcheck.c +118 -0
  129. data/vendor/libgit2/src/allocators/{win32_crtdbg.h → win32_leakcheck.h} +3 -3
  130. data/vendor/libgit2/src/annotated_commit.c +21 -9
  131. data/vendor/libgit2/src/annotated_commit.h +1 -1
  132. data/vendor/libgit2/src/apply.c +34 -25
  133. data/vendor/libgit2/src/apply.h +2 -2
  134. data/vendor/libgit2/src/array.h +11 -11
  135. data/vendor/libgit2/src/attr.c +204 -82
  136. data/vendor/libgit2/src/attr_file.c +105 -52
  137. data/vendor/libgit2/src/attr_file.h +36 -15
  138. data/vendor/libgit2/src/attrcache.c +55 -45
  139. data/vendor/libgit2/src/attrcache.h +4 -5
  140. data/vendor/libgit2/src/blame.c +15 -9
  141. data/vendor/libgit2/src/blame_git.c +2 -2
  142. data/vendor/libgit2/src/blob.c +76 -52
  143. data/vendor/libgit2/src/blob.h +1 -1
  144. data/vendor/libgit2/src/branch.c +203 -110
  145. data/vendor/libgit2/src/branch.h +15 -3
  146. data/vendor/libgit2/src/buf.c +126 -0
  147. data/vendor/libgit2/src/buf.h +50 -0
  148. data/vendor/libgit2/src/cache.c +2 -2
  149. data/vendor/libgit2/src/cache.h +7 -7
  150. data/vendor/libgit2/src/cc-compat.h +11 -9
  151. data/vendor/libgit2/src/checkout.c +118 -91
  152. data/vendor/libgit2/src/cherrypick.c +16 -12
  153. data/vendor/libgit2/src/clone.c +97 -103
  154. data/vendor/libgit2/src/commit.c +167 -84
  155. data/vendor/libgit2/src/commit.h +24 -1
  156. data/vendor/libgit2/src/commit_graph.c +1224 -0
  157. data/vendor/libgit2/src/commit_graph.h +169 -0
  158. data/vendor/libgit2/src/commit_list.c +48 -3
  159. data/vendor/libgit2/src/commit_list.h +2 -0
  160. data/vendor/libgit2/src/common.h +35 -5
  161. data/vendor/libgit2/src/config.c +119 -64
  162. data/vendor/libgit2/src/config.h +15 -2
  163. data/vendor/libgit2/src/config_cache.c +5 -3
  164. data/vendor/libgit2/src/config_file.c +120 -100
  165. data/vendor/libgit2/src/config_mem.c +9 -9
  166. data/vendor/libgit2/src/config_parse.c +29 -27
  167. data/vendor/libgit2/src/crlf.c +36 -23
  168. data/vendor/libgit2/src/date.c +13 -19
  169. data/vendor/libgit2/src/date.h +33 -0
  170. data/vendor/libgit2/src/delta.c +1 -1
  171. data/vendor/libgit2/src/describe.c +32 -21
  172. data/vendor/libgit2/src/diff.c +71 -183
  173. data/vendor/libgit2/src/diff.h +2 -4
  174. data/vendor/libgit2/src/diff_driver.c +53 -51
  175. data/vendor/libgit2/src/diff_driver.h +3 -3
  176. data/vendor/libgit2/src/diff_file.c +31 -26
  177. data/vendor/libgit2/src/diff_generate.c +76 -23
  178. data/vendor/libgit2/src/diff_generate.h +5 -3
  179. data/vendor/libgit2/src/diff_print.c +120 -95
  180. data/vendor/libgit2/src/diff_stats.c +47 -34
  181. data/vendor/libgit2/src/{message.h → diff_stats.h} +7 -6
  182. data/vendor/libgit2/src/diff_tform.c +18 -16
  183. data/vendor/libgit2/src/diff_xdiff.c +7 -10
  184. data/vendor/libgit2/src/diff_xdiff.h +1 -1
  185. data/vendor/libgit2/src/email.c +315 -0
  186. data/vendor/libgit2/src/email.h +25 -0
  187. data/vendor/libgit2/src/errors.c +37 -32
  188. data/vendor/libgit2/src/features.h.in +11 -2
  189. data/vendor/libgit2/src/fetch.c +77 -26
  190. data/vendor/libgit2/src/fetch.h +1 -1
  191. data/vendor/libgit2/src/fetchhead.c +27 -23
  192. data/vendor/libgit2/src/filebuf.c +36 -34
  193. data/vendor/libgit2/src/filebuf.h +1 -1
  194. data/vendor/libgit2/src/filter.c +278 -132
  195. data/vendor/libgit2/src/filter.h +46 -6
  196. data/vendor/libgit2/src/fs_path.c +2071 -0
  197. data/vendor/libgit2/src/fs_path.h +772 -0
  198. data/vendor/libgit2/src/futils.c +96 -90
  199. data/vendor/libgit2/src/futils.h +27 -15
  200. data/vendor/libgit2/src/graph.c +64 -9
  201. data/vendor/libgit2/src/hash/sha1/collisiondetect.c +5 -5
  202. data/vendor/libgit2/src/hash/sha1/common_crypto.c +5 -5
  203. data/vendor/libgit2/src/hash/sha1/generic.c +2 -2
  204. data/vendor/libgit2/src/hash/sha1/generic.h +1 -1
  205. data/vendor/libgit2/src/hash/sha1/mbedtls.c +13 -13
  206. data/vendor/libgit2/src/hash/sha1/openssl.c +5 -5
  207. data/vendor/libgit2/src/hash/sha1/sha1dc/sha1.c +9 -11
  208. data/vendor/libgit2/src/hash/sha1/win32.c +21 -17
  209. data/vendor/libgit2/src/hash/sha1.h +3 -1
  210. data/vendor/libgit2/src/hash.c +71 -36
  211. data/vendor/libgit2/src/hash.h +13 -13
  212. data/vendor/libgit2/src/hashsig.c +23 -10
  213. data/vendor/libgit2/src/ident.c +30 -20
  214. data/vendor/libgit2/src/ignore.c +63 -46
  215. data/vendor/libgit2/src/ignore.h +2 -2
  216. data/vendor/libgit2/src/index.c +184 -149
  217. data/vendor/libgit2/src/index.h +7 -4
  218. data/vendor/libgit2/src/indexer.c +143 -89
  219. data/vendor/libgit2/src/integer.h +64 -2
  220. data/vendor/libgit2/src/iterator.c +93 -73
  221. data/vendor/libgit2/src/iterator.h +6 -6
  222. data/vendor/libgit2/src/khash.h +3 -12
  223. data/vendor/libgit2/src/{settings.c → libgit2.c} +165 -56
  224. data/vendor/libgit2/src/libgit2.h +15 -0
  225. data/vendor/libgit2/src/mailmap.c +60 -45
  226. data/vendor/libgit2/src/map.h +3 -3
  227. data/vendor/libgit2/src/merge.c +104 -61
  228. data/vendor/libgit2/src/merge.h +3 -15
  229. data/vendor/libgit2/src/merge_driver.c +21 -15
  230. data/vendor/libgit2/src/merge_file.c +24 -6
  231. data/vendor/libgit2/src/message.c +21 -8
  232. data/vendor/libgit2/src/midx.c +501 -18
  233. data/vendor/libgit2/src/midx.h +29 -2
  234. data/vendor/libgit2/src/mwindow.c +103 -59
  235. data/vendor/libgit2/src/mwindow.h +3 -3
  236. data/vendor/libgit2/src/net.c +405 -71
  237. data/vendor/libgit2/src/net.h +26 -5
  238. data/vendor/libgit2/src/netops.c +7 -5
  239. data/vendor/libgit2/src/netops.h +3 -3
  240. data/vendor/libgit2/src/notes.c +40 -49
  241. data/vendor/libgit2/src/object.c +68 -20
  242. data/vendor/libgit2/src/object.h +1 -1
  243. data/vendor/libgit2/src/odb.c +320 -80
  244. data/vendor/libgit2/src/odb.h +17 -3
  245. data/vendor/libgit2/src/odb_loose.c +96 -86
  246. data/vendor/libgit2/src/odb_mempack.c +19 -6
  247. data/vendor/libgit2/src/odb_pack.c +402 -125
  248. data/vendor/libgit2/src/oid.c +16 -8
  249. data/vendor/libgit2/src/oid.h +15 -0
  250. data/vendor/libgit2/src/oidarray.c +10 -1
  251. data/vendor/libgit2/src/pack-objects.c +90 -69
  252. data/vendor/libgit2/src/pack-objects.h +11 -6
  253. data/vendor/libgit2/src/pack.c +337 -127
  254. data/vendor/libgit2/src/pack.h +25 -7
  255. data/vendor/libgit2/src/patch.c +17 -10
  256. data/vendor/libgit2/src/patch.h +1 -0
  257. data/vendor/libgit2/src/patch_generate.c +29 -13
  258. data/vendor/libgit2/src/patch_generate.h +5 -5
  259. data/vendor/libgit2/src/patch_parse.c +26 -25
  260. data/vendor/libgit2/src/path.c +86 -1768
  261. data/vendor/libgit2/src/path.h +39 -635
  262. data/vendor/libgit2/src/pathspec.c +12 -12
  263. data/vendor/libgit2/src/pathspec.h +2 -2
  264. data/vendor/libgit2/src/pool.c +13 -7
  265. data/vendor/libgit2/src/posix.c +14 -6
  266. data/vendor/libgit2/src/posix.h +1 -0
  267. data/vendor/libgit2/src/pqueue.h +1 -1
  268. data/vendor/libgit2/src/proxy.c +4 -1
  269. data/vendor/libgit2/src/proxy.h +1 -1
  270. data/vendor/libgit2/src/push.c +30 -35
  271. data/vendor/libgit2/src/push.h +4 -16
  272. data/vendor/libgit2/src/rand.c +226 -0
  273. data/vendor/libgit2/src/rand.h +37 -0
  274. data/vendor/libgit2/src/reader.c +18 -14
  275. data/vendor/libgit2/src/reader.h +2 -2
  276. data/vendor/libgit2/src/rebase.c +177 -132
  277. data/vendor/libgit2/src/refdb.c +30 -13
  278. data/vendor/libgit2/src/refdb_fs.c +548 -222
  279. data/vendor/libgit2/src/reflog.c +19 -14
  280. data/vendor/libgit2/src/refs.c +107 -72
  281. data/vendor/libgit2/src/refs.h +2 -2
  282. data/vendor/libgit2/src/refspec.c +53 -38
  283. data/vendor/libgit2/src/refspec.h +5 -2
  284. data/vendor/libgit2/src/regexp.c +1 -1
  285. data/vendor/libgit2/src/remote.c +960 -486
  286. data/vendor/libgit2/src/remote.h +16 -10
  287. data/vendor/libgit2/src/repository.c +702 -422
  288. data/vendor/libgit2/src/repository.h +26 -8
  289. data/vendor/libgit2/src/reset.c +16 -12
  290. data/vendor/libgit2/src/revert.c +16 -12
  291. data/vendor/libgit2/src/revparse.c +66 -48
  292. data/vendor/libgit2/src/revwalk.c +39 -22
  293. data/vendor/libgit2/src/runtime.c +162 -0
  294. data/vendor/libgit2/src/runtime.h +62 -0
  295. data/vendor/libgit2/src/settings.h +11 -0
  296. data/vendor/libgit2/src/signature.c +18 -11
  297. data/vendor/libgit2/src/signature.h +1 -1
  298. data/vendor/libgit2/src/sortedcache.c +1 -1
  299. data/vendor/libgit2/src/sortedcache.h +10 -8
  300. data/vendor/libgit2/src/stash.c +39 -38
  301. data/vendor/libgit2/src/status.c +11 -5
  302. data/vendor/libgit2/src/{buffer.c → str.c} +459 -136
  303. data/vendor/libgit2/src/str.h +357 -0
  304. data/vendor/libgit2/src/strarray.c +2 -1
  305. data/vendor/libgit2/src/streams/mbedtls.c +22 -23
  306. data/vendor/libgit2/src/streams/mbedtls.h +1 -1
  307. data/vendor/libgit2/src/streams/openssl.c +101 -201
  308. data/vendor/libgit2/src/streams/openssl.h +9 -1
  309. data/vendor/libgit2/src/streams/openssl_dynamic.c +309 -0
  310. data/vendor/libgit2/src/streams/openssl_dynamic.h +348 -0
  311. data/vendor/libgit2/src/streams/openssl_legacy.c +203 -0
  312. data/vendor/libgit2/src/streams/openssl_legacy.h +63 -0
  313. data/vendor/libgit2/src/streams/registry.c +5 -6
  314. data/vendor/libgit2/src/streams/socket.c +6 -2
  315. data/vendor/libgit2/src/streams/stransport.c +6 -3
  316. data/vendor/libgit2/src/streams/tls.c +5 -3
  317. data/vendor/libgit2/src/submodule.c +290 -212
  318. data/vendor/libgit2/src/submodule.h +10 -10
  319. data/vendor/libgit2/src/sysdir.c +70 -56
  320. data/vendor/libgit2/src/sysdir.h +15 -10
  321. data/vendor/libgit2/src/tag.c +72 -34
  322. data/vendor/libgit2/src/thread.c +140 -0
  323. data/vendor/libgit2/src/thread.h +479 -0
  324. data/vendor/libgit2/src/threadstate.c +84 -0
  325. data/vendor/libgit2/src/threadstate.h +24 -0
  326. data/vendor/libgit2/src/trace.c +3 -16
  327. data/vendor/libgit2/src/trace.h +17 -30
  328. data/vendor/libgit2/src/trailer.c +2 -2
  329. data/vendor/libgit2/src/transaction.c +20 -9
  330. data/vendor/libgit2/src/transport.c +13 -13
  331. data/vendor/libgit2/src/transports/auth.c +8 -10
  332. data/vendor/libgit2/src/transports/auth.h +2 -3
  333. data/vendor/libgit2/src/transports/auth_negotiate.c +23 -17
  334. data/vendor/libgit2/src/transports/auth_ntlm.c +20 -16
  335. data/vendor/libgit2/src/transports/auth_ntlm.h +0 -1
  336. data/vendor/libgit2/src/transports/credential.c +15 -7
  337. data/vendor/libgit2/src/transports/git.c +10 -14
  338. data/vendor/libgit2/src/transports/http.c +56 -34
  339. data/vendor/libgit2/src/transports/http.h +3 -3
  340. data/vendor/libgit2/src/transports/httpclient.c +106 -79
  341. data/vendor/libgit2/src/transports/httpclient.h +1 -1
  342. data/vendor/libgit2/src/transports/local.c +127 -119
  343. data/vendor/libgit2/src/transports/smart.c +61 -144
  344. data/vendor/libgit2/src/transports/smart.h +26 -32
  345. data/vendor/libgit2/src/transports/smart_pkt.c +33 -33
  346. data/vendor/libgit2/src/transports/smart_protocol.c +68 -44
  347. data/vendor/libgit2/src/transports/ssh.c +100 -131
  348. data/vendor/libgit2/src/transports/winhttp.c +86 -82
  349. data/vendor/libgit2/src/tree-cache.c +5 -5
  350. data/vendor/libgit2/src/tree-cache.h +2 -2
  351. data/vendor/libgit2/src/tree.c +150 -116
  352. data/vendor/libgit2/src/tree.h +1 -0
  353. data/vendor/libgit2/src/tsort.c +0 -2
  354. data/vendor/libgit2/src/unix/map.c +3 -3
  355. data/vendor/libgit2/src/unix/posix.h +1 -4
  356. data/vendor/libgit2/src/unix/pthread.h +2 -1
  357. data/vendor/libgit2/src/unix/realpath.c +0 -2
  358. data/vendor/libgit2/src/utf8.c +150 -0
  359. data/vendor/libgit2/src/utf8.h +52 -0
  360. data/vendor/libgit2/src/util.c +68 -144
  361. data/vendor/libgit2/src/util.h +36 -68
  362. data/vendor/libgit2/src/vector.c +23 -19
  363. data/vendor/libgit2/src/vector.h +5 -3
  364. data/vendor/libgit2/src/win32/findfile.c +172 -114
  365. data/vendor/libgit2/src/win32/findfile.h +7 -4
  366. data/vendor/libgit2/src/win32/map.c +1 -1
  367. data/vendor/libgit2/src/win32/msvc-compat.h +9 -1
  368. data/vendor/libgit2/src/win32/path_w32.c +162 -33
  369. data/vendor/libgit2/src/win32/path_w32.h +2 -1
  370. data/vendor/libgit2/src/win32/posix.h +6 -7
  371. data/vendor/libgit2/src/win32/posix_w32.c +26 -33
  372. data/vendor/libgit2/src/win32/precompiled.h +0 -1
  373. data/vendor/libgit2/src/win32/reparse.h +4 -4
  374. data/vendor/libgit2/src/win32/thread.c +24 -15
  375. data/vendor/libgit2/src/win32/thread.h +1 -1
  376. data/vendor/libgit2/src/win32/w32_buffer.c +5 -6
  377. data/vendor/libgit2/src/win32/w32_buffer.h +2 -3
  378. data/vendor/libgit2/src/win32/w32_common.h +18 -9
  379. data/vendor/libgit2/src/win32/{w32_crtdbg_stacktrace.c → w32_leakcheck.c} +269 -33
  380. data/vendor/libgit2/src/win32/w32_leakcheck.h +222 -0
  381. data/vendor/libgit2/src/win32/w32_util.h +6 -6
  382. data/vendor/libgit2/src/worktree.c +138 -105
  383. data/vendor/libgit2/src/worktree.h +1 -1
  384. data/vendor/libgit2/src/xdiff/git-xdiff.h +53 -0
  385. data/vendor/libgit2/src/xdiff/xdiff.h +15 -15
  386. data/vendor/libgit2/src/xdiff/xdiffi.c +134 -108
  387. data/vendor/libgit2/src/xdiff/xemit.c +23 -7
  388. data/vendor/libgit2/src/xdiff/xhistogram.c +87 -78
  389. data/vendor/libgit2/src/xdiff/xinclude.h +1 -12
  390. data/vendor/libgit2/src/xdiff/xmerge.c +104 -117
  391. data/vendor/libgit2/src/xdiff/xpatience.c +6 -17
  392. data/vendor/libgit2/src/xdiff/xprepare.c +15 -20
  393. data/vendor/libgit2/src/xdiff/xutils.c +18 -7
  394. data/vendor/libgit2/src/zstream.c +6 -6
  395. data/vendor/libgit2/src/zstream.h +4 -4
  396. metadata +60 -24
  397. data/vendor/libgit2/src/allocators/win32_crtdbg.c +0 -118
  398. data/vendor/libgit2/src/buf_text.c +0 -316
  399. data/vendor/libgit2/src/buf_text.h +0 -122
  400. data/vendor/libgit2/src/buffer.h +0 -222
  401. data/vendor/libgit2/src/global.c +0 -363
  402. data/vendor/libgit2/src/global.h +0 -41
  403. data/vendor/libgit2/src/thread-utils.c +0 -58
  404. data/vendor/libgit2/src/thread-utils.h +0 -369
  405. data/vendor/libgit2/src/win32/w32_crtdbg_stacktrace.h +0 -127
  406. data/vendor/libgit2/src/win32/w32_stack.c +0 -188
  407. data/vendor/libgit2/src/win32/w32_stack.h +0 -140
@@ -7,12 +7,8 @@
7
7
 
8
8
  #include "submodule.h"
9
9
 
10
- #include "git2/config.h"
11
- #include "git2/sys/config.h"
12
- #include "git2/types.h"
13
- #include "git2/index.h"
14
- #include "buffer.h"
15
- #include "buf_text.h"
10
+ #include "buf.h"
11
+ #include "branch.h"
16
12
  #include "vector.h"
17
13
  #include "posix.h"
18
14
  #include "config_backend.h"
@@ -20,10 +16,17 @@
20
16
  #include "repository.h"
21
17
  #include "tree.h"
22
18
  #include "iterator.h"
23
- #include "path.h"
19
+ #include "fs_path.h"
20
+ #include "str.h"
24
21
  #include "index.h"
25
22
  #include "worktree.h"
26
23
  #include "clone.h"
24
+ #include "path.h"
25
+
26
+ #include "git2/config.h"
27
+ #include "git2/sys/config.h"
28
+ #include "git2/types.h"
29
+ #include "git2/index.h"
27
30
 
28
31
  #define GIT_MODULES_FILE ".gitmodules"
29
32
 
@@ -58,14 +61,14 @@ enum {
58
61
  };
59
62
  enum {
60
63
  GITMODULES_EXISTING = 0,
61
- GITMODULES_CREATE = 1,
64
+ GITMODULES_CREATE = 1
62
65
  };
63
66
 
64
67
  static int submodule_alloc(git_submodule **out, git_repository *repo, const char *name);
65
68
  static git_config_backend *open_gitmodules(git_repository *repo, int gitmod);
66
69
  static int gitmodules_snapshot(git_config **snap, git_repository *repo);
67
- static int get_url_base(git_buf *url, git_repository *repo);
68
- static int lookup_head_remote_key(git_buf *remote_key, git_repository *repo);
70
+ static int get_url_base(git_str *url, git_repository *repo);
71
+ static int lookup_head_remote_key(git_str *remote_key, git_repository *repo);
69
72
  static int lookup_default_remote(git_remote **remote, git_repository *repo);
70
73
  static int submodule_load_each(const git_config_entry *entry, void *payload);
71
74
  static int submodule_read_config(git_submodule *sm, git_config *cfg);
@@ -80,11 +83,11 @@ static int submodule_cmp(const void *a, const void *b)
80
83
  return strcmp(((git_submodule *)a)->name, ((git_submodule *)b)->name);
81
84
  }
82
85
 
83
- static int submodule_config_key_trunc_puts(git_buf *key, const char *suffix)
86
+ static int submodule_config_key_trunc_puts(git_str *key, const char *suffix)
84
87
  {
85
- ssize_t idx = git_buf_rfind(key, '.');
86
- git_buf_truncate(key, (size_t)(idx + 1));
87
- return git_buf_puts(key, suffix);
88
+ ssize_t idx = git_str_rfind(key, '.');
89
+ git_str_truncate(key, (size_t)(idx + 1));
90
+ return git_str_puts(key, suffix);
88
91
  }
89
92
 
90
93
  /*
@@ -129,7 +132,7 @@ static int is_path_occupied(bool *occupied, git_repository *repo, const char *pa
129
132
  {
130
133
  int error = 0;
131
134
  git_index *index;
132
- git_buf dir = GIT_BUF_INIT;
135
+ git_str dir = GIT_STR_INIT;
133
136
  *occupied = false;
134
137
 
135
138
  if ((error = git_repository_index__weakptr(&index, repo)) < 0)
@@ -144,10 +147,10 @@ static int is_path_occupied(bool *occupied, git_repository *repo, const char *pa
144
147
  goto out;
145
148
  }
146
149
 
147
- if ((error = git_buf_sets(&dir, path)) < 0)
150
+ if ((error = git_str_sets(&dir, path)) < 0)
148
151
  goto out;
149
152
 
150
- if ((error = git_path_to_dir(&dir)) < 0)
153
+ if ((error = git_fs_path_to_dir(&dir)) < 0)
151
154
  goto out;
152
155
 
153
156
  if ((error = git_index_find_prefix(NULL, index, dir.ptr)) != GIT_ENOTFOUND) {
@@ -162,7 +165,7 @@ static int is_path_occupied(bool *occupied, git_repository *repo, const char *pa
162
165
  error = 0;
163
166
 
164
167
  out:
165
- git_buf_dispose(&dir);
168
+ git_str_dispose(&dir);
166
169
  return error;
167
170
  }
168
171
 
@@ -196,7 +199,7 @@ static int load_submodule_names(git_strmap **out, git_repository *repo, git_conf
196
199
  const char *key = "submodule\\..*\\.path";
197
200
  git_config_iterator *iter = NULL;
198
201
  git_config_entry *entry;
199
- git_buf buf = GIT_BUF_INIT;
202
+ git_str buf = GIT_STR_INIT;
200
203
  git_strmap *names;
201
204
  int isvalid, error;
202
205
 
@@ -220,8 +223,8 @@ static int load_submodule_names(git_strmap **out, git_repository *repo, git_conf
220
223
  goto out;
221
224
  }
222
225
 
223
- git_buf_clear(&buf);
224
- git_buf_put(&buf, fdot + 1, ldot - fdot - 1);
226
+ git_str_clear(&buf);
227
+ git_str_put(&buf, fdot + 1, ldot - fdot - 1);
225
228
  isvalid = git_submodule_name_is_valid(repo, buf.ptr, 0);
226
229
  if (isvalid < 0) {
227
230
  error = isvalid;
@@ -230,7 +233,7 @@ static int load_submodule_names(git_strmap **out, git_repository *repo, git_conf
230
233
  if (!isvalid)
231
234
  continue;
232
235
 
233
- if ((error = git_strmap_set(names, git__strdup(entry->value), git_buf_detach(&buf))) < 0) {
236
+ if ((error = git_strmap_set(names, git__strdup(entry->value), git_str_detach(&buf))) < 0) {
234
237
  git_error_set(GIT_ERROR_NOMEMORY, "error inserting submodule into hash table");
235
238
  error = -1;
236
239
  goto out;
@@ -244,29 +247,67 @@ static int load_submodule_names(git_strmap **out, git_repository *repo, git_conf
244
247
 
245
248
  out:
246
249
  free_submodule_names(names);
247
- git_buf_dispose(&buf);
250
+ git_str_dispose(&buf);
248
251
  git_config_iterator_free(iter);
249
252
  return error;
250
253
  }
251
254
 
255
+ int git_submodule_cache_init(git_strmap **out, git_repository *repo)
256
+ {
257
+ int error = 0;
258
+ git_strmap *cache = NULL;
259
+ GIT_ASSERT_ARG(out);
260
+ GIT_ASSERT_ARG(repo);
261
+ if ((error = git_strmap_new(&cache)) < 0)
262
+ return error;
263
+ if ((error = git_submodule__map(repo, cache)) < 0) {
264
+ git_submodule_cache_free(cache);
265
+ return error;
266
+ }
267
+ *out = cache;
268
+ return error;
269
+ }
270
+
271
+ int git_submodule_cache_free(git_strmap *cache)
272
+ {
273
+ git_submodule *sm = NULL;
274
+ if (cache == NULL)
275
+ return 0;
276
+ git_strmap_foreach_value(cache, sm, {
277
+ git_submodule_free(sm);
278
+ });
279
+ git_strmap_free(cache);
280
+ return 0;
281
+ }
282
+
252
283
  int git_submodule_lookup(
253
284
  git_submodule **out, /* NULL if user only wants to test existence */
254
285
  git_repository *repo,
255
286
  const char *name) /* trailing slash is allowed */
287
+ {
288
+ return git_submodule__lookup_with_cache(out, repo, name, repo->submodule_cache);
289
+ }
290
+
291
+ int git_submodule__lookup_with_cache(
292
+ git_submodule **out, /* NULL if user only wants to test existence */
293
+ git_repository *repo,
294
+ const char *name, /* trailing slash is allowed */
295
+ git_strmap *cache)
256
296
  {
257
297
  int error;
258
298
  unsigned int location;
259
299
  git_submodule *sm;
260
300
 
261
- assert(repo && name);
301
+ GIT_ASSERT_ARG(repo);
302
+ GIT_ASSERT_ARG(name);
262
303
 
263
304
  if (repo->is_bare) {
264
305
  git_error_set(GIT_ERROR_SUBMODULE, "cannot get submodules without a working tree");
265
306
  return -1;
266
307
  }
267
308
 
268
- if (repo->submodule_cache != NULL) {
269
- if ((sm = git_strmap_get(repo->submodule_cache, name)) != NULL) {
309
+ if (cache != NULL) {
310
+ if ((sm = git_strmap_get(cache, name)) != NULL) {
270
311
  if (out) {
271
312
  *out = sm;
272
313
  GIT_REFCOUNT_INC(*out);
@@ -292,10 +333,10 @@ int git_submodule_lookup(
292
333
  if (location == 0 || location == GIT_SUBMODULE_STATUS_IN_WD) {
293
334
  git_config_backend *mods;
294
335
  const char *pattern = "submodule\\..*\\.path";
295
- git_buf path = GIT_BUF_INIT;
336
+ git_str path = GIT_STR_INIT;
296
337
  fbp_data data = { NULL, NULL };
297
338
 
298
- git_buf_puts(&path, name);
339
+ git_str_puts(&path, name);
299
340
  while (path.ptr[path.size-1] == '/') {
300
341
  path.ptr[--path.size] = '\0';
301
342
  }
@@ -310,14 +351,14 @@ int git_submodule_lookup(
310
351
 
311
352
  if (error < 0) {
312
353
  git_submodule_free(sm);
313
- git_buf_dispose(&path);
354
+ git_str_dispose(&path);
314
355
  return error;
315
356
  }
316
357
 
317
358
  if (data.name) {
318
359
  git__free(sm->name);
319
360
  sm->name = data.name;
320
- sm->path = git_buf_detach(&path);
361
+ sm->path = git_str_detach(&path);
321
362
 
322
363
  /* Try to load again with the right name */
323
364
  if ((error = git_submodule_reload(sm, false)) < 0) {
@@ -326,7 +367,7 @@ int git_submodule_lookup(
326
367
  }
327
368
  }
328
369
 
329
- git_buf_dispose(&path);
370
+ git_str_dispose(&path);
330
371
  }
331
372
 
332
373
  if ((error = git_submodule_location(&location, sm)) < 0) {
@@ -341,15 +382,17 @@ int git_submodule_lookup(
341
382
 
342
383
  /* If it's not configured, we still check if there's a repo at the path */
343
384
  if (git_repository_workdir(repo)) {
344
- git_buf path = GIT_BUF_INIT;
345
- if (git_buf_join3(&path,
346
- '/', git_repository_workdir(repo), name, DOT_GIT) < 0)
385
+ git_str path = GIT_STR_INIT;
386
+ if (git_str_join3(&path, '/',
387
+ git_repository_workdir(repo),
388
+ name, DOT_GIT) < 0 ||
389
+ git_path_validate_str_length(NULL, &path) < 0)
347
390
  return -1;
348
391
 
349
- if (git_path_exists(path.ptr))
392
+ if (git_fs_path_exists(path.ptr))
350
393
  error = GIT_EEXISTS;
351
394
 
352
- git_buf_dispose(&path);
395
+ git_str_dispose(&path);
353
396
  }
354
397
 
355
398
  submodule_set_lookup_error(error, name);
@@ -366,22 +409,22 @@ int git_submodule_lookup(
366
409
 
367
410
  int git_submodule_name_is_valid(git_repository *repo, const char *name, int flags)
368
411
  {
369
- git_buf buf = GIT_BUF_INIT;
412
+ git_str buf = GIT_STR_INIT;
370
413
  int error, isvalid;
371
414
 
372
415
  if (flags == 0)
373
- flags = GIT_PATH_REJECT_FILESYSTEM_DEFAULTS;
416
+ flags = GIT_FS_PATH_REJECT_FILESYSTEM_DEFAULTS;
374
417
 
375
418
  /* Avoid allocating a new string if we can avoid it */
376
419
  if (strchr(name, '\\') != NULL) {
377
- if ((error = git_path_normalize_slashes(&buf, name)) < 0)
420
+ if ((error = git_fs_path_normalize_slashes(&buf, name)) < 0)
378
421
  return error;
379
422
  } else {
380
- git_buf_attach_notowned(&buf, name, strlen(name));
423
+ git_str_attach_notowned(&buf, name, strlen(name));
381
424
  }
382
425
 
383
- isvalid = git_path_isvalid(repo, buf.ptr, 0, flags);
384
- git_buf_dispose(&buf);
426
+ isvalid = git_path_is_valid(repo, buf.ptr, 0, flags);
427
+ git_str_dispose(&buf);
385
428
 
386
429
  return isvalid;
387
430
  }
@@ -515,12 +558,13 @@ int git_submodule__map(git_repository *repo, git_strmap *map)
515
558
  int error = 0;
516
559
  git_index *idx = NULL;
517
560
  git_tree *head = NULL;
518
- const char *wd = NULL;
519
- git_buf path = GIT_BUF_INIT;
561
+ git_str path = GIT_STR_INIT;
520
562
  git_submodule *sm;
521
563
  git_config *mods = NULL;
564
+ bool has_workdir;
522
565
 
523
- assert(repo && map);
566
+ GIT_ASSERT_ARG(repo);
567
+ GIT_ASSERT_ARG(map);
524
568
 
525
569
  /* get sources that we will need to check */
526
570
  if (git_repository_index(&idx, repo) < 0)
@@ -528,12 +572,14 @@ int git_submodule__map(git_repository *repo, git_strmap *map)
528
572
  if (git_repository_head_tree(&head, repo) < 0)
529
573
  git_error_clear();
530
574
 
531
- wd = git_repository_workdir(repo);
532
- if (wd && (error = git_buf_joinpath(&path, wd, GIT_MODULES_FILE)) < 0)
575
+ has_workdir = git_repository_workdir(repo) != NULL;
576
+
577
+ if (has_workdir &&
578
+ (error = git_repository_workdir_path(&path, repo, GIT_MODULES_FILE)) < 0)
533
579
  goto cleanup;
534
580
 
535
581
  /* add submodule information from .gitmodules */
536
- if (wd) {
582
+ if (has_workdir) {
537
583
  lfc_data data = { 0 };
538
584
  data.map = map;
539
585
  data.repo = repo;
@@ -560,7 +606,7 @@ int git_submodule__map(git_repository *repo, git_strmap *map)
560
606
  goto cleanup;
561
607
  }
562
608
  /* shallow scan submodules in work tree as needed */
563
- if (wd) {
609
+ if (has_workdir) {
564
610
  git_strmap_foreach_value(map, sm, {
565
611
  submodule_load_from_wd_lite(sm);
566
612
  });
@@ -571,7 +617,7 @@ cleanup:
571
617
  /* TODO: if we got an error, mark submodule config as invalid? */
572
618
  git_index_free(idx);
573
619
  git_tree_free(head);
574
- git_buf_dispose(&path);
620
+ git_str_dispose(&path);
575
621
  return error;
576
622
  }
577
623
 
@@ -640,11 +686,11 @@ static int submodule_repo_init(
640
686
  bool use_gitlink)
641
687
  {
642
688
  int error = 0;
643
- git_buf workdir = GIT_BUF_INIT, repodir = GIT_BUF_INIT;
689
+ git_str workdir = GIT_STR_INIT, repodir = GIT_STR_INIT;
644
690
  git_repository_init_options initopt = GIT_REPOSITORY_INIT_OPTIONS_INIT;
645
691
  git_repository *subrepo = NULL;
646
692
 
647
- error = git_buf_joinpath(&workdir, git_repository_workdir(parent_repo), path);
693
+ error = git_repository_workdir_path(&workdir, parent_repo, path);
648
694
  if (error < 0)
649
695
  goto cleanup;
650
696
 
@@ -659,10 +705,10 @@ static int submodule_repo_init(
659
705
  * Old style: sub-repo goes directly into repo/<name>/.git/
660
706
  */
661
707
  if (use_gitlink) {
662
- error = git_repository_item_path(&repodir, parent_repo, GIT_REPOSITORY_ITEM_MODULES);
708
+ error = git_repository__item_path(&repodir, parent_repo, GIT_REPOSITORY_ITEM_MODULES);
663
709
  if (error < 0)
664
710
  goto cleanup;
665
- error = git_buf_joinpath(&repodir, repodir.ptr, path);
711
+ error = git_str_joinpath(&repodir, repodir.ptr, path);
666
712
  if (error < 0)
667
713
  goto cleanup;
668
714
 
@@ -676,14 +722,57 @@ static int submodule_repo_init(
676
722
  error = git_repository_init_ext(&subrepo, workdir.ptr, &initopt);
677
723
 
678
724
  cleanup:
679
- git_buf_dispose(&workdir);
680
- git_buf_dispose(&repodir);
725
+ git_str_dispose(&workdir);
726
+ git_str_dispose(&repodir);
681
727
 
682
728
  *out = subrepo;
683
729
 
684
730
  return error;
685
731
  }
686
732
 
733
+ static int git_submodule__resolve_url(
734
+ git_str *out,
735
+ git_repository *repo,
736
+ const char *url)
737
+ {
738
+ int error = 0;
739
+ git_str normalized = GIT_STR_INIT;
740
+
741
+ GIT_ASSERT_ARG(out);
742
+ GIT_ASSERT_ARG(repo);
743
+ GIT_ASSERT_ARG(url);
744
+
745
+ /* We do this in all platforms in case someone on Windows created the .gitmodules */
746
+ if (strchr(url, '\\')) {
747
+ if ((error = git_fs_path_normalize_slashes(&normalized, url)) < 0)
748
+ return error;
749
+
750
+ url = normalized.ptr;
751
+ }
752
+
753
+
754
+ if (git_fs_path_is_relative(url)) {
755
+ if (!(error = get_url_base(out, repo)))
756
+ error = git_fs_path_apply_relative(out, url);
757
+ } else if (strchr(url, ':') != NULL || url[0] == '/') {
758
+ error = git_str_sets(out, url);
759
+ } else {
760
+ git_error_set(GIT_ERROR_SUBMODULE, "invalid format for submodule URL");
761
+ error = -1;
762
+ }
763
+
764
+ git_str_dispose(&normalized);
765
+ return error;
766
+ }
767
+
768
+ int git_submodule_resolve_url(
769
+ git_buf *out,
770
+ git_repository *repo,
771
+ const char *url)
772
+ {
773
+ GIT_BUF_WRAP_PRIVATE(out, git_submodule__resolve_url, repo, url);
774
+ }
775
+
687
776
  int git_submodule_add_setup(
688
777
  git_submodule **out,
689
778
  git_repository *repo,
@@ -694,11 +783,13 @@ int git_submodule_add_setup(
694
783
  int error = 0;
695
784
  git_config_backend *mods = NULL;
696
785
  git_submodule *sm = NULL;
697
- git_buf name = GIT_BUF_INIT, real_url = GIT_BUF_INIT;
786
+ git_str name = GIT_STR_INIT, real_url = GIT_STR_INIT;
698
787
  git_repository *subrepo = NULL;
699
788
  bool path_occupied;
700
789
 
701
- assert(repo && url && path);
790
+ GIT_ASSERT_ARG(repo);
791
+ GIT_ASSERT_ARG(url);
792
+ GIT_ASSERT_ARG(path);
702
793
 
703
794
  /* see if there is already an entry for this submodule */
704
795
 
@@ -715,7 +806,7 @@ int git_submodule_add_setup(
715
806
  if (git__prefixcmp(path, git_repository_workdir(repo)) == 0)
716
807
  path += strlen(git_repository_workdir(repo));
717
808
 
718
- if (git_path_root(path) >= 0) {
809
+ if (git_fs_path_root(path) >= 0) {
719
810
  git_error_set(GIT_ERROR_SUBMODULE, "submodule path must be a relative path");
720
811
  error = -1;
721
812
  goto cleanup;
@@ -737,7 +828,7 @@ int git_submodule_add_setup(
737
828
  return -1;
738
829
  }
739
830
 
740
- if ((error = git_buf_printf(&name, "submodule.%s.path", path)) < 0 ||
831
+ if ((error = git_str_printf(&name, "submodule.%s.path", path)) < 0 ||
741
832
  (error = git_config_backend_set_string(mods, name.ptr, path)) < 0)
742
833
  goto cleanup;
743
834
 
@@ -745,22 +836,22 @@ int git_submodule_add_setup(
745
836
  (error = git_config_backend_set_string(mods, name.ptr, url)) < 0)
746
837
  goto cleanup;
747
838
 
748
- git_buf_clear(&name);
839
+ git_str_clear(&name);
749
840
 
750
841
  /* init submodule repository and add origin remote as needed */
751
842
 
752
- error = git_buf_joinpath(&name, git_repository_workdir(repo), path);
843
+ error = git_repository_workdir_path(&name, repo, path);
753
844
  if (error < 0)
754
845
  goto cleanup;
755
846
 
756
847
  /* if the repo does not already exist, then init a new repo and add it.
757
848
  * Otherwise, just add the existing repo.
758
849
  */
759
- if (!(git_path_exists(name.ptr) &&
760
- git_path_contains(&name, DOT_GIT))) {
850
+ if (!(git_fs_path_exists(name.ptr) &&
851
+ git_fs_path_contains(&name, DOT_GIT))) {
761
852
 
762
853
  /* resolve the actual URL to use */
763
- if ((error = git_submodule_resolve_url(&real_url, repo, url)) < 0)
854
+ if ((error = git_submodule__resolve_url(&real_url, repo, url)) < 0)
764
855
  goto cleanup;
765
856
 
766
857
  if ((error = submodule_repo_init(&subrepo, repo, path, real_url.ptr, use_gitlink)) < 0)
@@ -782,8 +873,8 @@ cleanup:
782
873
 
783
874
  git_config_backend_free(mods);
784
875
  git_repository_free(subrepo);
785
- git_buf_dispose(&real_url);
786
- git_buf_dispose(&name);
876
+ git_str_dispose(&real_url);
877
+ git_str_dispose(&name);
787
878
 
788
879
  return error;
789
880
  }
@@ -797,12 +888,13 @@ int git_submodule_repo_init(
797
888
  git_repository *sub_repo = NULL;
798
889
  const char *configured_url;
799
890
  git_config *cfg = NULL;
800
- git_buf buf = GIT_BUF_INIT;
891
+ git_str buf = GIT_STR_INIT;
801
892
 
802
- assert(out && sm);
893
+ GIT_ASSERT_ARG(out);
894
+ GIT_ASSERT_ARG(sm);
803
895
 
804
896
  /* get the configured remote url of the submodule */
805
- if ((error = git_buf_printf(&buf, "submodule.%s.url", sm->name)) < 0 ||
897
+ if ((error = git_str_printf(&buf, "submodule.%s.url", sm->name)) < 0 ||
806
898
  (error = git_repository_config_snapshot(&cfg, sm->repo)) < 0 ||
807
899
  (error = git_config_get_string(&configured_url, cfg, buf.ptr)) < 0 ||
808
900
  (error = submodule_repo_init(&sub_repo, sm->repo, sm->path, configured_url, use_gitlink)) < 0)
@@ -812,7 +904,7 @@ int git_submodule_repo_init(
812
904
 
813
905
  done:
814
906
  git_config_free(cfg);
815
- git_buf_dispose(&buf);
907
+ git_str_dispose(&buf);
816
908
  return error;
817
909
  }
818
910
 
@@ -836,11 +928,11 @@ int git_submodule_clone(git_repository **out, git_submodule *submodule, const gi
836
928
  {
837
929
  int error;
838
930
  git_repository *clone;
839
- git_buf rel_path = GIT_BUF_INIT;
931
+ git_str rel_path = GIT_STR_INIT;
840
932
  git_submodule_update_options sub_opts = GIT_SUBMODULE_UPDATE_OPTIONS_INIT;
841
933
  git_clone_options opts = GIT_CLONE_OPTIONS_INIT;
842
934
 
843
- assert(submodule);
935
+ GIT_ASSERT_ARG(submodule);
844
936
 
845
937
  if (given_opts)
846
938
  memcpy(&sub_opts, given_opts, sizeof(sub_opts));
@@ -854,12 +946,11 @@ int git_submodule_clone(git_repository **out, git_submodule *submodule, const gi
854
946
  opts.remote_cb = clone_return_origin;
855
947
  opts.remote_cb_payload = submodule;
856
948
 
857
- git_buf_puts(&rel_path, git_repository_workdir(git_submodule_owner(submodule)));
858
- git_buf_joinpath(&rel_path, git_buf_cstr(&rel_path), git_submodule_path(submodule));
859
-
860
- GIT_ERROR_CHECK_ALLOC_BUF(&rel_path);
949
+ error = git_repository_workdir_path(&rel_path, git_submodule_owner(submodule), git_submodule_path(submodule));
950
+ if (error < 0)
951
+ goto cleanup;
861
952
 
862
- error = git_clone__submodule(&clone, git_submodule_url(submodule), git_buf_cstr(&rel_path), &opts);
953
+ error = git_clone__submodule(&clone, git_submodule_url(submodule), git_str_cstr(&rel_path), &opts);
863
954
  if (error < 0)
864
955
  goto cleanup;
865
956
 
@@ -869,7 +960,7 @@ int git_submodule_clone(git_repository **out, git_submodule *submodule, const gi
869
960
  *out = clone;
870
961
 
871
962
  cleanup:
872
- git_buf_dispose(&rel_path);
963
+ git_str_dispose(&rel_path);
873
964
 
874
965
  return error;
875
966
  }
@@ -879,7 +970,7 @@ int git_submodule_add_finalize(git_submodule *sm)
879
970
  int error;
880
971
  git_index *index;
881
972
 
882
- assert(sm);
973
+ GIT_ASSERT_ARG(sm);
883
974
 
884
975
  if ((error = git_repository_index__weakptr(&index, sm->repo)) < 0 ||
885
976
  (error = git_index_add_bypath(index, GIT_MODULES_FILE)) < 0)
@@ -893,20 +984,19 @@ int git_submodule_add_to_index(git_submodule *sm, int write_index)
893
984
  int error;
894
985
  git_repository *sm_repo = NULL;
895
986
  git_index *index;
896
- git_buf path = GIT_BUF_INIT;
987
+ git_str path = GIT_STR_INIT;
897
988
  git_commit *head;
898
989
  git_index_entry entry;
899
990
  struct stat st;
900
991
 
901
- assert(sm);
992
+ GIT_ASSERT_ARG(sm);
902
993
 
903
994
  /* force reload of wd OID by git_submodule_open */
904
995
  sm->flags = sm->flags & ~GIT_SUBMODULE_STATUS__WD_OID_VALID;
905
996
 
906
997
  if ((error = git_repository_index__weakptr(&index, sm->repo)) < 0 ||
907
- (error = git_buf_joinpath(
908
- &path, git_repository_workdir(sm->repo), sm->path)) < 0 ||
909
- (error = git_submodule_open(&sm_repo, sm)) < 0)
998
+ (error = git_repository_workdir_path(&path, sm->repo, sm->path)) < 0 ||
999
+ (error = git_submodule_open(&sm_repo, sm)) < 0)
910
1000
  goto cleanup;
911
1001
 
912
1002
  /* read stat information for submodule working directory */
@@ -954,7 +1044,7 @@ int git_submodule_add_to_index(git_submodule *sm, int write_index)
954
1044
 
955
1045
  cleanup:
956
1046
  git_repository_free(sm_repo);
957
- git_buf_dispose(&path);
1047
+ git_str_dispose(&path);
958
1048
  return error;
959
1049
  }
960
1050
 
@@ -969,63 +1059,31 @@ static const char *submodule_update_to_str(git_submodule_update_t update)
969
1059
 
970
1060
  git_repository *git_submodule_owner(git_submodule *submodule)
971
1061
  {
972
- assert(submodule);
1062
+ GIT_ASSERT_ARG_WITH_RETVAL(submodule, NULL);
973
1063
  return submodule->repo;
974
1064
  }
975
1065
 
976
1066
  const char *git_submodule_name(git_submodule *submodule)
977
1067
  {
978
- assert(submodule);
1068
+ GIT_ASSERT_ARG_WITH_RETVAL(submodule, NULL);
979
1069
  return submodule->name;
980
1070
  }
981
1071
 
982
1072
  const char *git_submodule_path(git_submodule *submodule)
983
1073
  {
984
- assert(submodule);
1074
+ GIT_ASSERT_ARG_WITH_RETVAL(submodule, NULL);
985
1075
  return submodule->path;
986
1076
  }
987
1077
 
988
1078
  const char *git_submodule_url(git_submodule *submodule)
989
1079
  {
990
- assert(submodule);
1080
+ GIT_ASSERT_ARG_WITH_RETVAL(submodule, NULL);
991
1081
  return submodule->url;
992
1082
  }
993
1083
 
994
- int git_submodule_resolve_url(git_buf *out, git_repository *repo, const char *url)
995
- {
996
- int error = 0;
997
- git_buf normalized = GIT_BUF_INIT;
998
-
999
- assert(out && repo && url);
1000
-
1001
- git_buf_sanitize(out);
1002
-
1003
- /* We do this in all platforms in case someone on Windows created the .gitmodules */
1004
- if (strchr(url, '\\')) {
1005
- if ((error = git_path_normalize_slashes(&normalized, url)) < 0)
1006
- return error;
1007
-
1008
- url = normalized.ptr;
1009
- }
1010
-
1011
-
1012
- if (git_path_is_relative(url)) {
1013
- if (!(error = get_url_base(out, repo)))
1014
- error = git_path_apply_relative(out, url);
1015
- } else if (strchr(url, ':') != NULL || url[0] == '/') {
1016
- error = git_buf_sets(out, url);
1017
- } else {
1018
- git_error_set(GIT_ERROR_SUBMODULE, "invalid format for submodule URL");
1019
- error = -1;
1020
- }
1021
-
1022
- git_buf_dispose(&normalized);
1023
- return error;
1024
- }
1025
-
1026
1084
  static int write_var(git_repository *repo, const char *name, const char *var, const char *val)
1027
1085
  {
1028
- git_buf key = GIT_BUF_INIT;
1086
+ git_str key = GIT_STR_INIT;
1029
1087
  git_config_backend *mods;
1030
1088
  int error;
1031
1089
 
@@ -1033,7 +1091,7 @@ static int write_var(git_repository *repo, const char *name, const char *var, co
1033
1091
  if (!mods)
1034
1092
  return -1;
1035
1093
 
1036
- if ((error = git_buf_printf(&key, "submodule.%s.%s", name, var)) < 0)
1094
+ if ((error = git_str_printf(&key, "submodule.%s.%s", name, var)) < 0)
1037
1095
  goto cleanup;
1038
1096
 
1039
1097
  if (val)
@@ -1041,7 +1099,7 @@ static int write_var(git_repository *repo, const char *name, const char *var, co
1041
1099
  else
1042
1100
  error = git_config_backend_delete(mods, key.ptr);
1043
1101
 
1044
- git_buf_dispose(&key);
1102
+ git_str_dispose(&key);
1045
1103
 
1046
1104
  cleanup:
1047
1105
  git_config_backend_free(mods);
@@ -1066,28 +1124,30 @@ static int write_mapped_var(git_repository *repo, const char *name, git_configma
1066
1124
 
1067
1125
  const char *git_submodule_branch(git_submodule *submodule)
1068
1126
  {
1069
- assert(submodule);
1127
+ GIT_ASSERT_ARG_WITH_RETVAL(submodule, NULL);
1070
1128
  return submodule->branch;
1071
1129
  }
1072
1130
 
1073
1131
  int git_submodule_set_branch(git_repository *repo, const char *name, const char *branch)
1074
1132
  {
1075
-
1076
- assert(repo && name);
1133
+ GIT_ASSERT_ARG(repo);
1134
+ GIT_ASSERT_ARG(name);
1077
1135
 
1078
1136
  return write_var(repo, name, "branch", branch);
1079
1137
  }
1080
1138
 
1081
1139
  int git_submodule_set_url(git_repository *repo, const char *name, const char *url)
1082
1140
  {
1083
- assert(repo && name && url);
1141
+ GIT_ASSERT_ARG(repo);
1142
+ GIT_ASSERT_ARG(name);
1143
+ GIT_ASSERT_ARG(url);
1084
1144
 
1085
1145
  return write_var(repo, name, "url", url);
1086
1146
  }
1087
1147
 
1088
1148
  const git_oid *git_submodule_index_id(git_submodule *submodule)
1089
1149
  {
1090
- assert(submodule);
1150
+ GIT_ASSERT_ARG_WITH_RETVAL(submodule, NULL);
1091
1151
 
1092
1152
  if (submodule->flags & GIT_SUBMODULE_STATUS__INDEX_OID_VALID)
1093
1153
  return &submodule->index_oid;
@@ -1097,7 +1157,7 @@ const git_oid *git_submodule_index_id(git_submodule *submodule)
1097
1157
 
1098
1158
  const git_oid *git_submodule_head_id(git_submodule *submodule)
1099
1159
  {
1100
- assert(submodule);
1160
+ GIT_ASSERT_ARG_WITH_RETVAL(submodule, NULL);
1101
1161
 
1102
1162
  if (submodule->flags & GIT_SUBMODULE_STATUS__HEAD_OID_VALID)
1103
1163
  return &submodule->head_oid;
@@ -1107,7 +1167,7 @@ const git_oid *git_submodule_head_id(git_submodule *submodule)
1107
1167
 
1108
1168
  const git_oid *git_submodule_wd_id(git_submodule *submodule)
1109
1169
  {
1110
- assert(submodule);
1170
+ GIT_ASSERT_ARG_WITH_RETVAL(submodule, NULL);
1111
1171
 
1112
1172
  /* load unless we think we have a valid oid */
1113
1173
  if (!(submodule->flags & GIT_SUBMODULE_STATUS__WD_OID_VALID)) {
@@ -1128,28 +1188,32 @@ const git_oid *git_submodule_wd_id(git_submodule *submodule)
1128
1188
 
1129
1189
  git_submodule_ignore_t git_submodule_ignore(git_submodule *submodule)
1130
1190
  {
1131
- assert(submodule);
1191
+ GIT_ASSERT_ARG_WITH_RETVAL(submodule, GIT_SUBMODULE_IGNORE_UNSPECIFIED);
1192
+
1132
1193
  return (submodule->ignore < GIT_SUBMODULE_IGNORE_NONE) ?
1133
1194
  GIT_SUBMODULE_IGNORE_NONE : submodule->ignore;
1134
1195
  }
1135
1196
 
1136
1197
  int git_submodule_set_ignore(git_repository *repo, const char *name, git_submodule_ignore_t ignore)
1137
1198
  {
1138
- assert(repo && name);
1199
+ GIT_ASSERT_ARG(repo);
1200
+ GIT_ASSERT_ARG(name);
1139
1201
 
1140
1202
  return write_mapped_var(repo, name, _sm_ignore_map, ARRAY_SIZE(_sm_ignore_map), "ignore", ignore);
1141
1203
  }
1142
1204
 
1143
1205
  git_submodule_update_t git_submodule_update_strategy(git_submodule *submodule)
1144
1206
  {
1145
- assert(submodule);
1207
+ GIT_ASSERT_ARG_WITH_RETVAL(submodule, GIT_SUBMODULE_UPDATE_NONE);
1208
+
1146
1209
  return (submodule->update < GIT_SUBMODULE_UPDATE_CHECKOUT) ?
1147
1210
  GIT_SUBMODULE_UPDATE_CHECKOUT : submodule->update;
1148
1211
  }
1149
1212
 
1150
1213
  int git_submodule_set_update(git_repository *repo, const char *name, git_submodule_update_t update)
1151
1214
  {
1152
- assert(repo && name);
1215
+ GIT_ASSERT_ARG(repo);
1216
+ GIT_ASSERT_ARG(name);
1153
1217
 
1154
1218
  return write_mapped_var(repo, name, _sm_update_map, ARRAY_SIZE(_sm_update_map), "update", update);
1155
1219
  }
@@ -1157,13 +1221,14 @@ int git_submodule_set_update(git_repository *repo, const char *name, git_submodu
1157
1221
  git_submodule_recurse_t git_submodule_fetch_recurse_submodules(
1158
1222
  git_submodule *submodule)
1159
1223
  {
1160
- assert(submodule);
1224
+ GIT_ASSERT_ARG_WITH_RETVAL(submodule, GIT_SUBMODULE_RECURSE_NO);
1161
1225
  return submodule->fetch_recurse;
1162
1226
  }
1163
1227
 
1164
1228
  int git_submodule_set_fetch_recurse_submodules(git_repository *repo, const char *name, git_submodule_recurse_t recurse)
1165
1229
  {
1166
- assert(repo && name);
1230
+ GIT_ASSERT_ARG(repo);
1231
+ GIT_ASSERT_ARG(name);
1167
1232
 
1168
1233
  return write_mapped_var(repo, name, _sm_recurse_map, ARRAY_SIZE(_sm_recurse_map), "fetchRecurseSubmodules", recurse);
1169
1234
  }
@@ -1174,7 +1239,7 @@ static int submodule_repo_create(
1174
1239
  const char *path)
1175
1240
  {
1176
1241
  int error = 0;
1177
- git_buf workdir = GIT_BUF_INIT, repodir = GIT_BUF_INIT;
1242
+ git_str workdir = GIT_STR_INIT, repodir = GIT_STR_INIT;
1178
1243
  git_repository_init_options initopt = GIT_REPOSITORY_INIT_OPTIONS_INIT;
1179
1244
  git_repository *subrepo = NULL;
1180
1245
 
@@ -1185,7 +1250,7 @@ static int submodule_repo_create(
1185
1250
  GIT_REPOSITORY_INIT_RELATIVE_GITLINK;
1186
1251
 
1187
1252
  /* Workdir: path to sub-repo working directory */
1188
- error = git_buf_joinpath(&workdir, git_repository_workdir(parent_repo), path);
1253
+ error = git_repository_workdir_path(&workdir, parent_repo, path);
1189
1254
  if (error < 0)
1190
1255
  goto cleanup;
1191
1256
 
@@ -1196,18 +1261,18 @@ static int submodule_repo_create(
1196
1261
  * <repo-dir>/modules/<name>/ with a gitlink in the
1197
1262
  * sub-repo workdir directory to that repository.
1198
1263
  */
1199
- error = git_repository_item_path(&repodir, parent_repo, GIT_REPOSITORY_ITEM_MODULES);
1264
+ error = git_repository__item_path(&repodir, parent_repo, GIT_REPOSITORY_ITEM_MODULES);
1200
1265
  if (error < 0)
1201
1266
  goto cleanup;
1202
- error = git_buf_joinpath(&repodir, repodir.ptr, path);
1267
+ error = git_str_joinpath(&repodir, repodir.ptr, path);
1203
1268
  if (error < 0)
1204
1269
  goto cleanup;
1205
1270
 
1206
1271
  error = git_repository_init_ext(&subrepo, repodir.ptr, &initopt);
1207
1272
 
1208
1273
  cleanup:
1209
- git_buf_dispose(&workdir);
1210
- git_buf_dispose(&repodir);
1274
+ git_str_dispose(&workdir);
1275
+ git_str_dispose(&repodir);
1211
1276
 
1212
1277
  *out = subrepo;
1213
1278
 
@@ -1256,11 +1321,11 @@ int git_submodule_update(git_submodule *sm, int init, git_submodule_update_optio
1256
1321
  git_repository *sub_repo = NULL;
1257
1322
  git_remote *remote = NULL;
1258
1323
  git_object *target_commit = NULL;
1259
- git_buf buf = GIT_BUF_INIT;
1324
+ git_str buf = GIT_STR_INIT;
1260
1325
  git_submodule_update_options update_options = GIT_SUBMODULE_UPDATE_OPTIONS_INIT;
1261
1326
  git_clone_options clone_options = GIT_CLONE_OPTIONS_INIT;
1262
1327
 
1263
- assert(sm);
1328
+ GIT_ASSERT_ARG(sm);
1264
1329
 
1265
1330
  if (_update_options)
1266
1331
  memcpy(&update_options, _update_options, sizeof(git_submodule_update_options));
@@ -1284,10 +1349,10 @@ int git_submodule_update(git_submodule *sm, int init, git_submodule_update_optio
1284
1349
  * info has been copied into .git/config
1285
1350
  */
1286
1351
  if ((error = git_repository_config_snapshot(&config, sm->repo)) < 0 ||
1287
- (error = git_buf_printf(&buf, "submodule.%s.url", git_submodule_name(sm))) < 0)
1352
+ (error = git_str_printf(&buf, "submodule.%s.url", git_submodule_name(sm))) < 0)
1288
1353
  goto done;
1289
1354
 
1290
- if ((error = git_config_get_string(&submodule_url, config, git_buf_cstr(&buf))) < 0) {
1355
+ if ((error = git_config_get_string(&submodule_url, config, git_str_cstr(&buf))) < 0) {
1291
1356
  /*
1292
1357
  * If the error is not "not found" or if it is "not found" and we are not
1293
1358
  * initializing the submodule, then return error.
@@ -1309,7 +1374,7 @@ int git_submodule_update(git_submodule *sm, int init, git_submodule_update_optio
1309
1374
  config = NULL;
1310
1375
 
1311
1376
  if ((error = git_repository_config_snapshot(&config, sm->repo)) < 0 ||
1312
- (error = git_config_get_string(&submodule_url, config, git_buf_cstr(&buf))) < 0)
1377
+ (error = git_config_get_string(&submodule_url, config, git_str_cstr(&buf))) < 0)
1313
1378
  goto done;
1314
1379
  }
1315
1380
 
@@ -1367,7 +1432,7 @@ int git_submodule_update(git_submodule *sm, int init, git_submodule_update_optio
1367
1432
  }
1368
1433
 
1369
1434
  done:
1370
- git_buf_dispose(&buf);
1435
+ git_str_dispose(&buf);
1371
1436
  git_config_free(config);
1372
1437
  git_object_free(target_commit);
1373
1438
  git_remote_free(remote);
@@ -1380,7 +1445,7 @@ int git_submodule_init(git_submodule *sm, int overwrite)
1380
1445
  {
1381
1446
  int error;
1382
1447
  const char *val;
1383
- git_buf key = GIT_BUF_INIT, effective_submodule_url = GIT_BUF_INIT;
1448
+ git_str key = GIT_STR_INIT, effective_submodule_url = GIT_STR_INIT;
1384
1449
  git_config *cfg = NULL;
1385
1450
 
1386
1451
  if (!sm->url) {
@@ -1394,8 +1459,8 @@ int git_submodule_init(git_submodule *sm, int overwrite)
1394
1459
 
1395
1460
  /* write "submodule.NAME.url" */
1396
1461
 
1397
- if ((error = git_submodule_resolve_url(&effective_submodule_url, sm->repo, sm->url)) < 0 ||
1398
- (error = git_buf_printf(&key, "submodule.%s.url", sm->name)) < 0 ||
1462
+ if ((error = git_submodule__resolve_url(&effective_submodule_url, sm->repo, sm->url)) < 0 ||
1463
+ (error = git_str_printf(&key, "submodule.%s.url", sm->name)) < 0 ||
1399
1464
  (error = git_config__update_entry(
1400
1465
  cfg, key.ptr, effective_submodule_url.ptr, overwrite != 0, false)) < 0)
1401
1466
  goto cleanup;
@@ -1405,7 +1470,7 @@ int git_submodule_init(git_submodule *sm, int overwrite)
1405
1470
  val = (sm->update == GIT_SUBMODULE_UPDATE_CHECKOUT) ?
1406
1471
  NULL : submodule_update_to_str(sm->update);
1407
1472
 
1408
- if ((error = git_buf_printf(&key, "submodule.%s.update", sm->name)) < 0 ||
1473
+ if ((error = git_str_printf(&key, "submodule.%s.update", sm->name)) < 0 ||
1409
1474
  (error = git_config__update_entry(
1410
1475
  cfg, key.ptr, val, overwrite != 0, false)) < 0)
1411
1476
  goto cleanup;
@@ -1414,15 +1479,15 @@ int git_submodule_init(git_submodule *sm, int overwrite)
1414
1479
 
1415
1480
  cleanup:
1416
1481
  git_config_free(cfg);
1417
- git_buf_dispose(&key);
1418
- git_buf_dispose(&effective_submodule_url);
1482
+ git_str_dispose(&key);
1483
+ git_str_dispose(&effective_submodule_url);
1419
1484
 
1420
1485
  return error;
1421
1486
  }
1422
1487
 
1423
1488
  int git_submodule_sync(git_submodule *sm)
1424
1489
  {
1425
- git_buf key = GIT_BUF_INIT, url = GIT_BUF_INIT, remote_name = GIT_BUF_INIT;
1490
+ git_str key = GIT_STR_INIT, url = GIT_STR_INIT, remote_name = GIT_STR_INIT;
1426
1491
  git_repository *smrepo = NULL;
1427
1492
  git_config *cfg = NULL;
1428
1493
  int error = 0;
@@ -1434,8 +1499,8 @@ int git_submodule_sync(git_submodule *sm)
1434
1499
 
1435
1500
  /* copy URL over to config only if it already exists */
1436
1501
  if ((error = git_repository_config__weakptr(&cfg, sm->repo)) < 0 ||
1437
- (error = git_buf_printf(&key, "submodule.%s.url", sm->name)) < 0 ||
1438
- (error = git_submodule_resolve_url(&url, sm->repo, sm->url)) < 0 ||
1502
+ (error = git_str_printf(&key, "submodule.%s.url", sm->name)) < 0 ||
1503
+ (error = git_submodule__resolve_url(&url, sm->repo, sm->url)) < 0 ||
1439
1504
  (error = git_config__update_entry(cfg, key.ptr, url.ptr, true, true)) < 0)
1440
1505
  goto out;
1441
1506
 
@@ -1448,9 +1513,9 @@ int git_submodule_sync(git_submodule *sm)
1448
1513
  goto out;
1449
1514
 
1450
1515
  if (lookup_head_remote_key(&remote_name, smrepo) == 0) {
1451
- if ((error = git_buf_join3(&key, '.', "remote", remote_name.ptr, "url")) < 0)
1516
+ if ((error = git_str_join3(&key, '.', "remote", remote_name.ptr, "url")) < 0)
1452
1517
  goto out;
1453
- } else if ((error = git_buf_sets(&key, "remote.origin.url")) < 0) {
1518
+ } else if ((error = git_str_sets(&key, "remote.origin.url")) < 0) {
1454
1519
  goto out;
1455
1520
  }
1456
1521
 
@@ -1459,9 +1524,9 @@ int git_submodule_sync(git_submodule *sm)
1459
1524
 
1460
1525
  out:
1461
1526
  git_repository_free(smrepo);
1462
- git_buf_dispose(&remote_name);
1463
- git_buf_dispose(&key);
1464
- git_buf_dispose(&url);
1527
+ git_str_dispose(&remote_name);
1528
+ git_str_dispose(&key);
1529
+ git_str_dispose(&url);
1465
1530
  return error;
1466
1531
  }
1467
1532
 
@@ -1469,11 +1534,12 @@ static int git_submodule__open(
1469
1534
  git_repository **subrepo, git_submodule *sm, bool bare)
1470
1535
  {
1471
1536
  int error;
1472
- git_buf path = GIT_BUF_INIT;
1537
+ git_str path = GIT_STR_INIT;
1473
1538
  unsigned int flags = GIT_REPOSITORY_OPEN_NO_SEARCH;
1474
1539
  const char *wd;
1475
1540
 
1476
- assert(sm && subrepo);
1541
+ GIT_ASSERT_ARG(sm);
1542
+ GIT_ASSERT_ARG(subrepo);
1477
1543
 
1478
1544
  if (git_repository__ensure_not_bare(
1479
1545
  sm->repo, "open submodule repository") < 0)
@@ -1481,8 +1547,7 @@ static int git_submodule__open(
1481
1547
 
1482
1548
  wd = git_repository_workdir(sm->repo);
1483
1549
 
1484
- if (git_buf_joinpath(&path, wd, sm->path) < 0 ||
1485
- git_buf_joinpath(&path, path.ptr, DOT_GIT) < 0)
1550
+ if (git_str_join3(&path, '/', wd, sm->path, DOT_GIT) < 0)
1486
1551
  return -1;
1487
1552
 
1488
1553
  sm->flags = sm->flags &
@@ -1504,17 +1569,17 @@ static int git_submodule__open(
1504
1569
  sm->flags |= GIT_SUBMODULE_STATUS__WD_OID_VALID;
1505
1570
  else
1506
1571
  git_error_clear();
1507
- } else if (git_path_exists(path.ptr)) {
1572
+ } else if (git_fs_path_exists(path.ptr)) {
1508
1573
  sm->flags |= GIT_SUBMODULE_STATUS__WD_SCANNED |
1509
1574
  GIT_SUBMODULE_STATUS_IN_WD;
1510
1575
  } else {
1511
- git_buf_rtruncate_at_char(&path, '/'); /* remove "/.git" */
1576
+ git_str_rtruncate_at_char(&path, '/'); /* remove "/.git" */
1512
1577
 
1513
- if (git_path_isdir(path.ptr))
1578
+ if (git_fs_path_isdir(path.ptr))
1514
1579
  sm->flags |= GIT_SUBMODULE_STATUS__WD_SCANNED;
1515
1580
  }
1516
1581
 
1517
- git_buf_dispose(&path);
1582
+ git_str_dispose(&path);
1518
1583
 
1519
1584
  return error;
1520
1585
  }
@@ -1609,7 +1674,7 @@ int git_submodule_reload(git_submodule *sm, int force)
1609
1674
 
1610
1675
  GIT_UNUSED(force);
1611
1676
 
1612
- assert(sm);
1677
+ GIT_ASSERT_ARG(sm);
1613
1678
 
1614
1679
  if ((error = git_submodule_name_is_valid(sm->repo, sm->name, 0)) <= 0)
1615
1680
  /* This should come with a warning, but we've no API for that */
@@ -1726,7 +1791,9 @@ int git_submodule_status(unsigned int *status, git_repository *repo, const char
1726
1791
  git_submodule *sm;
1727
1792
  int error;
1728
1793
 
1729
- assert(status && repo && name);
1794
+ GIT_ASSERT_ARG(status);
1795
+ GIT_ASSERT_ARG(repo);
1796
+ GIT_ASSERT_ARG(name);
1730
1797
 
1731
1798
  if ((error = git_submodule_lookup(&sm, repo, name)) < 0)
1732
1799
  return error;
@@ -1739,7 +1806,8 @@ int git_submodule_status(unsigned int *status, git_repository *repo, const char
1739
1806
 
1740
1807
  int git_submodule_location(unsigned int *location, git_submodule *sm)
1741
1808
  {
1742
- assert(location && sm);
1809
+ GIT_ASSERT_ARG(location);
1810
+ GIT_ASSERT_ARG(sm);
1743
1811
 
1744
1812
  return git_submodule__status(
1745
1813
  location, NULL, NULL, NULL, sm, GIT_SUBMODULE_IGNORE_ALL);
@@ -1798,6 +1866,17 @@ static void submodule_release(git_submodule *sm)
1798
1866
  git__free(sm);
1799
1867
  }
1800
1868
 
1869
+ int git_submodule_dup(git_submodule **out, git_submodule *source)
1870
+ {
1871
+ GIT_ASSERT_ARG(out);
1872
+ GIT_ASSERT_ARG(source);
1873
+
1874
+ GIT_REFCOUNT_INC(source);
1875
+
1876
+ *out = source;
1877
+ return 0;
1878
+ }
1879
+
1801
1880
  void git_submodule_free(git_submodule *sm)
1802
1881
  {
1803
1882
  if (!sm)
@@ -1854,13 +1933,13 @@ static int submodule_parse_recurse(git_submodule_recurse_t *out, const char *val
1854
1933
  return 0;
1855
1934
  }
1856
1935
 
1857
- static int get_value(const char **out, git_config *cfg, git_buf *buf, const char *name, const char *field)
1936
+ static int get_value(const char **out, git_config *cfg, git_str *buf, const char *name, const char *field)
1858
1937
  {
1859
1938
  int error;
1860
1939
 
1861
- git_buf_clear(buf);
1940
+ git_str_clear(buf);
1862
1941
 
1863
- if ((error = git_buf_printf(buf, "submodule.%s.%s", name, field)) < 0 ||
1942
+ if ((error = git_str_printf(buf, "submodule.%s.%s", name, field)) < 0 ||
1864
1943
  (error = git_config_get_string(out, cfg, buf->ptr)) < 0)
1865
1944
  return error;
1866
1945
 
@@ -1877,7 +1956,7 @@ static bool looks_like_command_line_option(const char *s)
1877
1956
 
1878
1957
  static int submodule_read_config(git_submodule *sm, git_config *cfg)
1879
1958
  {
1880
- git_buf key = GIT_BUF_INIT;
1959
+ git_str key = GIT_STR_INIT;
1881
1960
  const char *value;
1882
1961
  int error, in_config = 0;
1883
1962
 
@@ -1958,7 +2037,7 @@ static int submodule_read_config(git_submodule *sm, git_config *cfg)
1958
2037
  error = 0;
1959
2038
 
1960
2039
  cleanup:
1961
- git_buf_dispose(&key);
2040
+ git_str_dispose(&key);
1962
2041
  return error;
1963
2042
  }
1964
2043
 
@@ -1967,7 +2046,7 @@ static int submodule_load_each(const git_config_entry *entry, void *payload)
1967
2046
  lfc_data *data = payload;
1968
2047
  const char *namestart, *property;
1969
2048
  git_strmap *map = data->map;
1970
- git_buf name = GIT_BUF_INIT;
2049
+ git_str name = GIT_STR_INIT;
1971
2050
  git_submodule *sm;
1972
2051
  int error, isvalid;
1973
2052
 
@@ -1982,7 +2061,7 @@ static int submodule_load_each(const git_config_entry *entry, void *payload)
1982
2061
 
1983
2062
  property++;
1984
2063
 
1985
- if ((error = git_buf_set(&name, namestart, property - namestart -1)) < 0)
2064
+ if ((error = git_str_set(&name, namestart, property - namestart -1)) < 0)
1986
2065
  return error;
1987
2066
 
1988
2067
  isvalid = git_submodule_name_is_valid(data->repo, name.ptr, 0);
@@ -2016,24 +2095,24 @@ static int submodule_load_each(const git_config_entry *entry, void *payload)
2016
2095
  error = 0;
2017
2096
 
2018
2097
  done:
2019
- git_buf_dispose(&name);
2098
+ git_str_dispose(&name);
2020
2099
  return error;
2021
2100
  }
2022
2101
 
2023
2102
  static int submodule_load_from_wd_lite(git_submodule *sm)
2024
2103
  {
2025
- git_buf path = GIT_BUF_INIT;
2104
+ git_str path = GIT_STR_INIT;
2026
2105
 
2027
- if (git_buf_joinpath(&path, git_repository_workdir(sm->repo), sm->path) < 0)
2106
+ if (git_repository_workdir_path(&path, sm->repo, sm->path) < 0)
2028
2107
  return -1;
2029
2108
 
2030
- if (git_path_isdir(path.ptr))
2109
+ if (git_fs_path_isdir(path.ptr))
2031
2110
  sm->flags |= GIT_SUBMODULE_STATUS__WD_SCANNED;
2032
2111
 
2033
- if (git_path_contains(&path, DOT_GIT))
2112
+ if (git_fs_path_contains(&path, DOT_GIT))
2034
2113
  sm->flags |= GIT_SUBMODULE_STATUS_IN_WD;
2035
2114
 
2036
- git_buf_dispose(&path);
2115
+ git_str_dispose(&path);
2037
2116
  return 0;
2038
2117
  }
2039
2118
 
@@ -2044,20 +2123,19 @@ static int submodule_load_from_wd_lite(git_submodule *sm)
2044
2123
  */
2045
2124
  static int gitmodules_snapshot(git_config **snap, git_repository *repo)
2046
2125
  {
2047
- const char *workdir = git_repository_workdir(repo);
2048
2126
  git_config *mods = NULL;
2049
- git_buf path = GIT_BUF_INIT;
2127
+ git_str path = GIT_STR_INIT;
2050
2128
  int error;
2051
2129
 
2052
- if (!workdir)
2130
+ if (git_repository_workdir(repo) == NULL)
2053
2131
  return GIT_ENOTFOUND;
2054
2132
 
2055
- if ((error = git_buf_joinpath(&path, workdir, GIT_MODULES_FILE)) < 0)
2133
+ if ((error = git_repository_workdir_path(&path, repo, GIT_MODULES_FILE)) < 0)
2056
2134
  return error;
2057
2135
 
2058
2136
  if ((error = git_config_open_ondisk(&mods, path.ptr)) < 0)
2059
2137
  goto cleanup;
2060
- git_buf_dispose(&path);
2138
+ git_str_dispose(&path);
2061
2139
 
2062
2140
  if ((error = git_config_snapshot(snap, mods)) < 0)
2063
2141
  goto cleanup;
@@ -2067,7 +2145,7 @@ static int gitmodules_snapshot(git_config **snap, git_repository *repo)
2067
2145
  cleanup:
2068
2146
  if (mods)
2069
2147
  git_config_free(mods);
2070
- git_buf_dispose(&path);
2148
+ git_str_dispose(&path);
2071
2149
 
2072
2150
  return error;
2073
2151
  }
@@ -2076,15 +2154,14 @@ static git_config_backend *open_gitmodules(
2076
2154
  git_repository *repo,
2077
2155
  int okay_to_create)
2078
2156
  {
2079
- const char *workdir = git_repository_workdir(repo);
2080
- git_buf path = GIT_BUF_INIT;
2157
+ git_str path = GIT_STR_INIT;
2081
2158
  git_config_backend *mods = NULL;
2082
2159
 
2083
- if (workdir != NULL) {
2084
- if (git_buf_joinpath(&path, workdir, GIT_MODULES_FILE) != 0)
2160
+ if (git_repository_workdir(repo) != NULL) {
2161
+ if (git_repository_workdir_path(&path, repo, GIT_MODULES_FILE) != 0)
2085
2162
  return NULL;
2086
2163
 
2087
- if (okay_to_create || git_path_isfile(path.ptr)) {
2164
+ if (okay_to_create || git_fs_path_isfile(path.ptr)) {
2088
2165
  /* git_config_backend_from_file should only fail if OOM */
2089
2166
  if (git_config_backend_from_file(&mods, path.ptr) < 0)
2090
2167
  mods = NULL;
@@ -2096,17 +2173,17 @@ static git_config_backend *open_gitmodules(
2096
2173
  }
2097
2174
  }
2098
2175
 
2099
- git_buf_dispose(&path);
2176
+ git_str_dispose(&path);
2100
2177
 
2101
2178
  return mods;
2102
2179
  }
2103
2180
 
2104
2181
  /* Lookup name of remote of the local tracking branch HEAD points to */
2105
- static int lookup_head_remote_key(git_buf *remote_name, git_repository *repo)
2182
+ static int lookup_head_remote_key(git_str *remote_name, git_repository *repo)
2106
2183
  {
2107
2184
  int error;
2108
2185
  git_reference *head = NULL;
2109
- git_buf upstream_name = GIT_BUF_INIT;
2186
+ git_str upstream_name = GIT_STR_INIT;
2110
2187
 
2111
2188
  /* lookup and dereference HEAD */
2112
2189
  if ((error = git_repository_head(&head, repo)) < 0)
@@ -2125,18 +2202,18 @@ static int lookup_head_remote_key(git_buf *remote_name, git_repository *repo)
2125
2202
  }
2126
2203
 
2127
2204
  /* lookup remote tracking branch of HEAD */
2128
- if ((error = git_branch_upstream_name(
2205
+ if ((error = git_branch__upstream_name(
2129
2206
  &upstream_name,
2130
2207
  repo,
2131
2208
  git_reference_name(head))) < 0)
2132
2209
  goto done;
2133
2210
 
2134
2211
  /* lookup remote of remote tracking branch */
2135
- if ((error = git_branch_remote_name(remote_name, repo, upstream_name.ptr)) < 0)
2212
+ if ((error = git_branch__remote_name(remote_name, repo, upstream_name.ptr)) < 0)
2136
2213
  goto done;
2137
2214
 
2138
2215
  done:
2139
- git_buf_dispose(&upstream_name);
2216
+ git_str_dispose(&upstream_name);
2140
2217
  git_reference_free(head);
2141
2218
 
2142
2219
  return error;
@@ -2146,13 +2223,13 @@ done:
2146
2223
  static int lookup_head_remote(git_remote **remote, git_repository *repo)
2147
2224
  {
2148
2225
  int error;
2149
- git_buf remote_name = GIT_BUF_INIT;
2226
+ git_str remote_name = GIT_STR_INIT;
2150
2227
 
2151
2228
  /* lookup remote of remote tracking branch name */
2152
2229
  if (!(error = lookup_head_remote_key(&remote_name, repo)))
2153
2230
  error = git_remote_lookup(remote, repo, remote_name.ptr);
2154
2231
 
2155
- git_buf_dispose(&remote_name);
2232
+ git_str_dispose(&remote_name);
2156
2233
 
2157
2234
  return error;
2158
2235
  }
@@ -2175,14 +2252,14 @@ static int lookup_default_remote(git_remote **remote, git_repository *repo)
2175
2252
  return error;
2176
2253
  }
2177
2254
 
2178
- static int get_url_base(git_buf *url, git_repository *repo)
2255
+ static int get_url_base(git_str *url, git_repository *repo)
2179
2256
  {
2180
2257
  int error;
2181
2258
  git_worktree *wt = NULL;
2182
2259
  git_remote *remote = NULL;
2183
2260
 
2184
2261
  if ((error = lookup_default_remote(&remote, repo)) == 0) {
2185
- error = git_buf_sets(url, git_remote_url(remote));
2262
+ error = git_str_sets(url, git_remote_url(remote));
2186
2263
  goto out;
2187
2264
  } else if (error != GIT_ENOTFOUND)
2188
2265
  goto out;
@@ -2193,9 +2270,10 @@ static int get_url_base(git_buf *url, git_repository *repo)
2193
2270
  if (git_repository_is_worktree(repo)) {
2194
2271
  if ((error = git_worktree_open_from_repository(&wt, repo)) < 0)
2195
2272
  goto out;
2196
- error = git_buf_sets(url, wt->parent_path);
2197
- } else
2198
- error = git_buf_sets(url, git_repository_workdir(repo));
2273
+ error = git_str_sets(url, wt->parent_path);
2274
+ } else {
2275
+ error = git_str_sets(url, git_repository_workdir(repo));
2276
+ }
2199
2277
 
2200
2278
  out:
2201
2279
  git_remote_free(remote);