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
@@ -15,6 +15,7 @@
15
15
 
16
16
  #include "refspec.h"
17
17
  #include "vector.h"
18
+ #include "net.h"
18
19
 
19
20
  #define GIT_REMOTE_ORIGIN "origin"
20
21
 
@@ -46,7 +47,7 @@ typedef struct git_remote_connection_opts {
46
47
  int git_remote__connect(git_remote *remote, git_direction direction, const git_remote_callbacks *callbacks, const git_remote_connection_opts *conn);
47
48
 
48
49
  int git_remote__urlfordirection(git_buf *url_out, struct git_remote *remote, int direction, const git_remote_callbacks *callbacks);
49
- int git_remote__get_http_proxy(git_remote *remote, bool use_ssl, char **proxy_url);
50
+ int git_remote__http_proxy(char **out, git_remote *remote, git_net_url *url);
50
51
 
51
52
  git_refspec *git_remote__matching_refspec(git_remote *remote, const char *refname);
52
53
  git_refspec *git_remote__matching_dst_refspec(git_remote *remote, const char *refname);
@@ -93,7 +93,7 @@ static void set_odb(git_repository *repo, git_odb *odb)
93
93
  GIT_REFCOUNT_INC(odb);
94
94
  }
95
95
 
96
- if ((odb = git__swap(repo->_odb, odb)) != NULL) {
96
+ if ((odb = git_atomic_swap(repo->_odb, odb)) != NULL) {
97
97
  GIT_REFCOUNT_OWN(odb, NULL);
98
98
  git_odb_free(odb);
99
99
  }
@@ -106,7 +106,7 @@ static void set_refdb(git_repository *repo, git_refdb *refdb)
106
106
  GIT_REFCOUNT_INC(refdb);
107
107
  }
108
108
 
109
- if ((refdb = git__swap(repo->_refdb, refdb)) != NULL) {
109
+ if ((refdb = git_atomic_swap(repo->_refdb, refdb)) != NULL) {
110
110
  GIT_REFCOUNT_OWN(refdb, NULL);
111
111
  git_refdb_free(refdb);
112
112
  }
@@ -119,7 +119,7 @@ static void set_config(git_repository *repo, git_config *config)
119
119
  GIT_REFCOUNT_INC(config);
120
120
  }
121
121
 
122
- if ((config = git__swap(repo->_config, config)) != NULL) {
122
+ if ((config = git_atomic_swap(repo->_config, config)) != NULL) {
123
123
  GIT_REFCOUNT_OWN(config, NULL);
124
124
  git_config_free(config);
125
125
  }
@@ -134,7 +134,7 @@ static void set_index(git_repository *repo, git_index *index)
134
134
  GIT_REFCOUNT_INC(index);
135
135
  }
136
136
 
137
- if ((index = git__swap(repo->_index, index)) != NULL) {
137
+ if ((index = git_atomic_swap(repo->_index, index)) != NULL) {
138
138
  GIT_REFCOUNT_OWN(index, NULL);
139
139
  git_index_free(index);
140
140
  }
@@ -142,7 +142,7 @@ static void set_index(git_repository *repo, git_index *index)
142
142
 
143
143
  int git_repository__cleanup(git_repository *repo)
144
144
  {
145
- assert(repo);
145
+ GIT_ASSERT_ARG(repo);
146
146
 
147
147
  git_repository_submodule_cache_clear(repo);
148
148
  git_cache_clear(&repo->objects);
@@ -186,6 +186,63 @@ void git_repository_free(git_repository *repo)
186
186
  git__free(repo);
187
187
  }
188
188
 
189
+ /* Check if we have a separate commondir (e.g. we have a worktree) */
190
+ static int lookup_commondir(bool *separate, git_buf *commondir, git_buf *repository_path)
191
+ {
192
+ git_buf common_link = GIT_BUF_INIT;
193
+ int error;
194
+
195
+ /*
196
+ * If there's no commondir file, the repository path is the
197
+ * common path, but it needs a trailing slash.
198
+ */
199
+ if (!git_path_contains_file(repository_path, GIT_COMMONDIR_FILE)) {
200
+ if ((error = git_buf_set(commondir, repository_path->ptr, repository_path->size)) == 0)
201
+ error = git_path_to_dir(commondir);
202
+
203
+ *separate = false;
204
+ goto done;
205
+ }
206
+
207
+ *separate = true;
208
+
209
+ if ((error = git_buf_joinpath(&common_link, repository_path->ptr, GIT_COMMONDIR_FILE)) < 0 ||
210
+ (error = git_futils_readbuffer(&common_link, common_link.ptr)) < 0)
211
+ goto done;
212
+
213
+ git_buf_rtrim(&common_link);
214
+ if (git_path_is_relative(common_link.ptr)) {
215
+ if ((error = git_buf_joinpath(commondir, repository_path->ptr, common_link.ptr)) < 0)
216
+ goto done;
217
+ } else {
218
+ git_buf_swap(commondir, &common_link);
219
+ }
220
+
221
+ git_buf_dispose(&common_link);
222
+
223
+ /* Make sure the commondir path always has a trailing slash */
224
+ error = git_path_prettify_dir(commondir, commondir->ptr, NULL);
225
+
226
+ done:
227
+ return error;
228
+ }
229
+
230
+ GIT_INLINE(int) validate_repo_path(git_buf *path)
231
+ {
232
+ /*
233
+ * The longest static path in a repository (or commondir) is the
234
+ * packed refs file. (Loose refs may be longer since they
235
+ * include the reference name, but will be validated when the
236
+ * path is constructed.)
237
+ */
238
+ static size_t suffix_len =
239
+ CONST_STRLEN("objects/pack/pack-.pack.lock") +
240
+ GIT_OID_HEXSZ;
241
+
242
+ return git_path_validate_filesystem_with_suffix(
243
+ path->ptr, path->size, suffix_len);
244
+ }
245
+
189
246
  /*
190
247
  * Git repository open methods
191
248
  *
@@ -193,48 +250,30 @@ void git_repository_free(git_repository *repo)
193
250
  */
194
251
  static int is_valid_repository_path(bool *out, git_buf *repository_path, git_buf *common_path)
195
252
  {
253
+ bool separate_commondir = false;
196
254
  int error;
197
255
 
198
256
  *out = false;
199
257
 
200
- /* Check if we have a separate commondir (e.g. we have a
201
- * worktree) */
202
- if (git_path_contains_file(repository_path, GIT_COMMONDIR_FILE)) {
203
- git_buf common_link = GIT_BUF_INIT;
204
-
205
- if ((error = git_buf_joinpath(&common_link, repository_path->ptr, GIT_COMMONDIR_FILE)) < 0 ||
206
- (error = git_futils_readbuffer(&common_link, common_link.ptr)) < 0)
207
- return error;
208
-
209
- git_buf_rtrim(&common_link);
210
- if (git_path_is_relative(common_link.ptr)) {
211
- if ((error = git_buf_joinpath(common_path, repository_path->ptr, common_link.ptr)) < 0)
212
- return error;
213
- } else {
214
- git_buf_swap(common_path, &common_link);
215
- }
216
-
217
- git_buf_dispose(&common_link);
218
- }
219
- else {
220
- if ((error = git_buf_set(common_path, repository_path->ptr, repository_path->size)) < 0)
221
- return error;
222
- }
223
-
224
- /* Make sure the commondir path always has a trailing * slash */
225
- if (git_buf_rfind(common_path, '/') != (ssize_t)common_path->size - 1)
226
- if ((error = git_buf_putc(common_path, '/')) < 0)
227
- return error;
258
+ if ((error = lookup_commondir(&separate_commondir, common_path, repository_path)) < 0)
259
+ return error;
228
260
 
229
261
  /* Ensure HEAD file exists */
230
262
  if (git_path_contains_file(repository_path, GIT_HEAD_FILE) == false)
231
263
  return 0;
264
+
232
265
  /* Check files in common dir */
233
266
  if (git_path_contains_dir(common_path, GIT_OBJECTS_DIR) == false)
234
267
  return 0;
235
268
  if (git_path_contains_dir(common_path, GIT_REFS_DIR) == false)
236
269
  return 0;
237
270
 
271
+ /* Ensure the repo (and commondir) are valid paths */
272
+ if ((error = validate_repo_path(common_path)) < 0 ||
273
+ (separate_commondir &&
274
+ (error = validate_repo_path(repository_path)) < 0))
275
+ return error;
276
+
238
277
  *out = true;
239
278
  return 0;
240
279
  }
@@ -368,7 +407,7 @@ static size_t find_ceiling_dir_offset(
368
407
  const char *ceil, *sep;
369
408
  size_t len, max_len = 0, min_len;
370
409
 
371
- assert(path);
410
+ GIT_ASSERT_ARG(path);
372
411
 
373
412
  min_len = (size_t)(git_path_root(path) + 1);
374
413
 
@@ -414,7 +453,8 @@ static int read_gitfile(git_buf *path_out, const char *file_path)
414
453
  git_buf file = GIT_BUF_INIT;
415
454
  size_t prefix_len = strlen(GIT_FILE_CONTENT_PREFIX);
416
455
 
417
- assert(path_out && file_path);
456
+ GIT_ASSERT_ARG(path_out);
457
+ GIT_ASSERT_ARG(file_path);
418
458
 
419
459
  if (git_futils_readbuffer(&file, file_path) < 0)
420
460
  return -1;
@@ -901,7 +941,8 @@ int git_repository_open_from_worktree(git_repository **repo_out, git_worktree *w
901
941
  size_t len;
902
942
  int err;
903
943
 
904
- assert(repo_out && wt);
944
+ GIT_ASSERT_ARG(repo_out);
945
+ GIT_ASSERT_ARG(wt);
905
946
 
906
947
  *repo_out = NULL;
907
948
  len = strlen(wt->gitlink_path);
@@ -945,10 +986,12 @@ int git_repository_discover(
945
986
  const char *ceiling_dirs)
946
987
  {
947
988
  uint32_t flags = across_fs ? GIT_REPOSITORY_OPEN_CROSS_FS : 0;
989
+ int error;
948
990
 
949
- assert(start_path);
991
+ GIT_ASSERT_ARG(start_path);
950
992
 
951
- git_buf_sanitize(out);
993
+ if ((error = git_buf_sanitize(out)) < 0)
994
+ return error;
952
995
 
953
996
  return find_repo(out, NULL, NULL, NULL, start_path, flags, ceiling_dirs);
954
997
  }
@@ -965,7 +1008,7 @@ static int load_config(
965
1008
  git_buf config_path = GIT_BUF_INIT;
966
1009
  git_config *cfg = NULL;
967
1010
 
968
- assert(out);
1011
+ GIT_ASSERT_ARG(out);
969
1012
 
970
1013
  if ((error = git_config_new(&cfg)) < 0)
971
1014
  return error;
@@ -1050,8 +1093,7 @@ int git_repository_config__weakptr(git_config **out, git_repository *repo)
1050
1093
  if (!error) {
1051
1094
  GIT_REFCOUNT_OWN(config, repo);
1052
1095
 
1053
- config = git__compare_and_swap(&repo->_config, NULL, config);
1054
- if (config != NULL) {
1096
+ if (git_atomic_compare_and_swap(&repo->_config, NULL, config) != NULL) {
1055
1097
  GIT_REFCOUNT_OWN(config, NULL);
1056
1098
  git_config_free(config);
1057
1099
  }
@@ -1089,7 +1131,9 @@ int git_repository_config_snapshot(git_config **out, git_repository *repo)
1089
1131
 
1090
1132
  int git_repository_set_config(git_repository *repo, git_config *config)
1091
1133
  {
1092
- assert(repo && config);
1134
+ GIT_ASSERT_ARG(repo);
1135
+ GIT_ASSERT_ARG(config);
1136
+
1093
1137
  set_config(repo, config);
1094
1138
  return 0;
1095
1139
  }
@@ -1098,9 +1142,11 @@ int git_repository_odb__weakptr(git_odb **out, git_repository *repo)
1098
1142
  {
1099
1143
  int error = 0;
1100
1144
 
1101
- assert(repo && out);
1145
+ GIT_ASSERT_ARG(repo);
1146
+ GIT_ASSERT_ARG(out);
1102
1147
 
1103
- if (repo->_odb == NULL) {
1148
+ *out = git_atomic_load(repo->_odb);
1149
+ if (*out == NULL) {
1104
1150
  git_buf odb_path = GIT_BUF_INIT;
1105
1151
  git_odb *odb;
1106
1152
 
@@ -1117,16 +1163,15 @@ int git_repository_odb__weakptr(git_odb **out, git_repository *repo)
1117
1163
  return error;
1118
1164
  }
1119
1165
 
1120
- odb = git__compare_and_swap(&repo->_odb, NULL, odb);
1121
- if (odb != NULL) {
1166
+ if (git_atomic_compare_and_swap(&repo->_odb, NULL, odb) != NULL) {
1122
1167
  GIT_REFCOUNT_OWN(odb, NULL);
1123
1168
  git_odb_free(odb);
1124
1169
  }
1125
1170
 
1126
1171
  git_buf_dispose(&odb_path);
1172
+ *out = git_atomic_load(repo->_odb);
1127
1173
  }
1128
1174
 
1129
- *out = repo->_odb;
1130
1175
  return error;
1131
1176
  }
1132
1177
 
@@ -1141,7 +1186,9 @@ int git_repository_odb(git_odb **out, git_repository *repo)
1141
1186
 
1142
1187
  int git_repository_set_odb(git_repository *repo, git_odb *odb)
1143
1188
  {
1144
- assert(repo && odb);
1189
+ GIT_ASSERT_ARG(repo);
1190
+ GIT_ASSERT_ARG(odb);
1191
+
1145
1192
  set_odb(repo, odb);
1146
1193
  return 0;
1147
1194
  }
@@ -1150,7 +1197,8 @@ int git_repository_refdb__weakptr(git_refdb **out, git_repository *repo)
1150
1197
  {
1151
1198
  int error = 0;
1152
1199
 
1153
- assert(out && repo);
1200
+ GIT_ASSERT_ARG(out);
1201
+ GIT_ASSERT_ARG(repo);
1154
1202
 
1155
1203
  if (repo->_refdb == NULL) {
1156
1204
  git_refdb *refdb;
@@ -1159,8 +1207,7 @@ int git_repository_refdb__weakptr(git_refdb **out, git_repository *repo)
1159
1207
  if (!error) {
1160
1208
  GIT_REFCOUNT_OWN(refdb, repo);
1161
1209
 
1162
- refdb = git__compare_and_swap(&repo->_refdb, NULL, refdb);
1163
- if (refdb != NULL) {
1210
+ if (git_atomic_compare_and_swap(&repo->_refdb, NULL, refdb) != NULL) {
1164
1211
  GIT_REFCOUNT_OWN(refdb, NULL);
1165
1212
  git_refdb_free(refdb);
1166
1213
  }
@@ -1182,7 +1229,9 @@ int git_repository_refdb(git_refdb **out, git_repository *repo)
1182
1229
 
1183
1230
  int git_repository_set_refdb(git_repository *repo, git_refdb *refdb)
1184
1231
  {
1185
- assert(repo && refdb);
1232
+ GIT_ASSERT_ARG(repo);
1233
+ GIT_ASSERT_ARG(refdb);
1234
+
1186
1235
  set_refdb(repo, refdb);
1187
1236
  return 0;
1188
1237
  }
@@ -1191,7 +1240,8 @@ int git_repository_index__weakptr(git_index **out, git_repository *repo)
1191
1240
  {
1192
1241
  int error = 0;
1193
1242
 
1194
- assert(out && repo);
1243
+ GIT_ASSERT_ARG(out);
1244
+ GIT_ASSERT_ARG(repo);
1195
1245
 
1196
1246
  if (repo->_index == NULL) {
1197
1247
  git_buf index_path = GIT_BUF_INIT;
@@ -1204,8 +1254,7 @@ int git_repository_index__weakptr(git_index **out, git_repository *repo)
1204
1254
  if (!error) {
1205
1255
  GIT_REFCOUNT_OWN(index, repo);
1206
1256
 
1207
- index = git__compare_and_swap(&repo->_index, NULL, index);
1208
- if (index != NULL) {
1257
+ if (git_atomic_compare_and_swap(&repo->_index, NULL, index) != NULL) {
1209
1258
  GIT_REFCOUNT_OWN(index, NULL);
1210
1259
  git_index_free(index);
1211
1260
  }
@@ -1232,7 +1281,7 @@ int git_repository_index(git_index **out, git_repository *repo)
1232
1281
 
1233
1282
  int git_repository_set_index(git_repository *repo, git_index *index)
1234
1283
  {
1235
- assert(repo);
1284
+ GIT_ASSERT_ARG(repo);
1236
1285
  set_index(repo, index);
1237
1286
  return 0;
1238
1287
  }
@@ -2131,7 +2180,9 @@ int git_repository_init_ext(
2131
2180
  bool is_valid;
2132
2181
  int error;
2133
2182
 
2134
- assert(out && given_repo && opts);
2183
+ GIT_ASSERT_ARG(out);
2184
+ GIT_ASSERT_ARG(given_repo);
2185
+ GIT_ASSERT_ARG(opts);
2135
2186
 
2136
2187
  GIT_ERROR_CHECK_VERSION(opts, GIT_REPOSITORY_INIT_OPTIONS_VERSION, "git_repository_init_options");
2137
2188
 
@@ -2207,7 +2258,8 @@ int git_repository_head_detached_for_worktree(git_repository *repo, const char *
2207
2258
  git_reference *ref = NULL;
2208
2259
  int error;
2209
2260
 
2210
- assert(repo && name);
2261
+ GIT_ASSERT_ARG(repo);
2262
+ GIT_ASSERT_ARG(name);
2211
2263
 
2212
2264
  if ((error = git_repository_head_for_worktree(&ref, repo, name)) < 0)
2213
2265
  goto out;
@@ -2224,7 +2276,7 @@ int git_repository_head(git_reference **head_out, git_repository *repo)
2224
2276
  git_reference *head;
2225
2277
  int error;
2226
2278
 
2227
- assert(head_out);
2279
+ GIT_ASSERT_ARG(head_out);
2228
2280
 
2229
2281
  if ((error = git_reference_lookup(&head, repo, GIT_HEAD_FILE)) < 0)
2230
2282
  return error;
@@ -2247,7 +2299,9 @@ int git_repository_head_for_worktree(git_reference **out, git_repository *repo,
2247
2299
  git_reference *head = NULL;
2248
2300
  int error;
2249
2301
 
2250
- assert(out && repo && name);
2302
+ GIT_ASSERT_ARG(out);
2303
+ GIT_ASSERT_ARG(repo);
2304
+ GIT_ASSERT_ARG(name);
2251
2305
 
2252
2306
  *out = NULL;
2253
2307
 
@@ -2281,6 +2335,12 @@ int git_repository_foreach_worktree(git_repository *repo,
2281
2335
  int error;
2282
2336
  size_t i;
2283
2337
 
2338
+ /* apply operation to repository supplied when commondir is empty, implying there's
2339
+ * no linked worktrees to iterate, which can occur when using custom odb/refdb
2340
+ */
2341
+ if (!repo->commondir)
2342
+ return cb(repo, payload);
2343
+
2284
2344
  if ((error = git_repository_open(&worktree_repo, repo->commondir)) < 0 ||
2285
2345
  (error = cb(worktree_repo, payload) != 0))
2286
2346
  goto out;
@@ -2358,7 +2418,7 @@ int git_repository_initialbranch(git_buf *out, git_repository *repo)
2358
2418
  git_config *config;
2359
2419
  git_config_entry *entry = NULL;
2360
2420
  const char *branch;
2361
- int error;
2421
+ int valid, error;
2362
2422
 
2363
2423
  if ((error = git_repository_config__weakptr(&config, repo)) < 0)
2364
2424
  return error;
@@ -2375,10 +2435,11 @@ int git_repository_initialbranch(git_buf *out, git_repository *repo)
2375
2435
  }
2376
2436
 
2377
2437
  if ((error = git_buf_puts(out, GIT_REFS_HEADS_DIR)) < 0 ||
2378
- (error = git_buf_puts(out, branch)) < 0)
2438
+ (error = git_buf_puts(out, branch)) < 0 ||
2439
+ (error = git_reference_name_is_valid(&valid, out->ptr)) < 0)
2379
2440
  goto done;
2380
2441
 
2381
- if (!git_reference_is_valid_name(out->ptr)) {
2442
+ if (!valid) {
2382
2443
  git_error_set(GIT_ERROR_INVALID, "the value of init.defaultBranch is not a valid branch name");
2383
2444
  error = -1;
2384
2445
  }
@@ -2459,13 +2520,13 @@ int git_repository_item_path(git_buf *out, const git_repository *repo, git_repos
2459
2520
 
2460
2521
  const char *git_repository_path(const git_repository *repo)
2461
2522
  {
2462
- assert(repo);
2523
+ GIT_ASSERT_ARG_WITH_RETVAL(repo, NULL);
2463
2524
  return repo->gitdir;
2464
2525
  }
2465
2526
 
2466
2527
  const char *git_repository_workdir(const git_repository *repo)
2467
2528
  {
2468
- assert(repo);
2529
+ GIT_ASSERT_ARG_WITH_RETVAL(repo, NULL);
2469
2530
 
2470
2531
  if (repo->is_bare)
2471
2532
  return NULL;
@@ -2473,9 +2534,25 @@ const char *git_repository_workdir(const git_repository *repo)
2473
2534
  return repo->workdir;
2474
2535
  }
2475
2536
 
2537
+ int git_repository_workdir_path(
2538
+ git_buf *out, git_repository *repo, const char *path)
2539
+ {
2540
+ int error;
2541
+
2542
+ if (!repo->workdir) {
2543
+ git_error_set(GIT_ERROR_REPOSITORY, "repository has no working directory");
2544
+ return GIT_EBAREREPO;
2545
+ }
2546
+
2547
+ if (!(error = git_buf_joinpath(out, repo->workdir, path)))
2548
+ error = git_path_validate_workdir_buf(repo, out);
2549
+
2550
+ return error;
2551
+ }
2552
+
2476
2553
  const char *git_repository_commondir(const git_repository *repo)
2477
2554
  {
2478
- assert(repo);
2555
+ GIT_ASSERT_ARG_WITH_RETVAL(repo, NULL);
2479
2556
  return repo->commondir;
2480
2557
  }
2481
2558
 
@@ -2485,7 +2562,8 @@ int git_repository_set_workdir(
2485
2562
  int error = 0;
2486
2563
  git_buf path = GIT_BUF_INIT;
2487
2564
 
2488
- assert(repo && workdir);
2565
+ GIT_ASSERT_ARG(repo);
2566
+ GIT_ASSERT_ARG(workdir);
2489
2567
 
2490
2568
  if (git_path_prettify_dir(&path, workdir, NULL) < 0)
2491
2569
  return -1;
@@ -2525,13 +2603,13 @@ int git_repository_set_workdir(
2525
2603
 
2526
2604
  int git_repository_is_bare(const git_repository *repo)
2527
2605
  {
2528
- assert(repo);
2606
+ GIT_ASSERT_ARG(repo);
2529
2607
  return repo->is_bare;
2530
2608
  }
2531
2609
 
2532
2610
  int git_repository_is_worktree(const git_repository *repo)
2533
2611
  {
2534
- assert(repo);
2612
+ GIT_ASSERT_ARG(repo);
2535
2613
  return repo->is_worktree;
2536
2614
  }
2537
2615
 
@@ -2540,7 +2618,7 @@ int git_repository_set_bare(git_repository *repo)
2540
2618
  int error;
2541
2619
  git_config *config;
2542
2620
 
2543
- assert(repo);
2621
+ GIT_ASSERT_ARG(repo);
2544
2622
 
2545
2623
  if (repo->is_bare)
2546
2624
  return 0;
@@ -2608,7 +2686,8 @@ int git_repository_message(git_buf *out, git_repository *repo)
2608
2686
  struct stat st;
2609
2687
  int error;
2610
2688
 
2611
- git_buf_sanitize(out);
2689
+ if ((error = git_buf_sanitize(out)) < 0)
2690
+ return error;
2612
2691
 
2613
2692
  if (git_buf_joinpath(&path, repo->gitdir, GIT_MERGE_MSG_FILE) < 0)
2614
2693
  return -1;
@@ -2653,16 +2732,19 @@ int git_repository_hashfile(
2653
2732
  uint64_t len;
2654
2733
  git_buf full_path = GIT_BUF_INIT;
2655
2734
 
2656
- assert(out && path && repo); /* as_path can be NULL */
2735
+ /* as_path can be NULL */
2736
+ GIT_ASSERT_ARG(out);
2737
+ GIT_ASSERT_ARG(path);
2738
+ GIT_ASSERT_ARG(repo);
2657
2739
 
2658
2740
  /* At some point, it would be nice if repo could be NULL to just
2659
2741
  * apply filter rules defined in system and global files, but for
2660
2742
  * now that is not possible because git_filters_load() needs it.
2661
2743
  */
2662
2744
 
2663
- error = git_path_join_unrooted(
2664
- &full_path, path, git_repository_workdir(repo), NULL);
2665
- if (error < 0)
2745
+ if ((error = git_path_join_unrooted(
2746
+ &full_path, path, git_repository_workdir(repo), NULL)) < 0 ||
2747
+ (error = git_path_validate_workdir_buf(repo, &full_path)) < 0)
2666
2748
  return error;
2667
2749
 
2668
2750
  if (!as_path)
@@ -2738,7 +2820,8 @@ static int detach(git_repository *repo, const git_oid *id, const char *new)
2738
2820
  git_object *object = NULL, *peeled = NULL;
2739
2821
  git_reference *new_head = NULL, *current = NULL;
2740
2822
 
2741
- assert(repo && id);
2823
+ GIT_ASSERT_ARG(repo);
2824
+ GIT_ASSERT_ARG(id);
2742
2825
 
2743
2826
  if ((error = git_reference_lookup(&current, repo, GIT_HEAD_FILE)) < 0)
2744
2827
  return error;
@@ -2774,7 +2857,8 @@ int git_repository_set_head(
2774
2857
  git_buf log_message = GIT_BUF_INIT;
2775
2858
  int error;
2776
2859
 
2777
- assert(repo && refname);
2860
+ GIT_ASSERT_ARG(repo);
2861
+ GIT_ASSERT_ARG(refname);
2778
2862
 
2779
2863
  if ((error = git_reference_lookup(&current, repo, GIT_HEAD_FILE)) < 0)
2780
2864
  return error;
@@ -2826,7 +2910,8 @@ int git_repository_set_head_detached_from_annotated(
2826
2910
  git_repository *repo,
2827
2911
  const git_annotated_commit *commitish)
2828
2912
  {
2829
- assert(repo && commitish);
2913
+ GIT_ASSERT_ARG(repo);
2914
+ GIT_ASSERT_ARG(commitish);
2830
2915
 
2831
2916
  return detach(repo, git_annotated_commit_id(commitish), commitish->description);
2832
2917
  }
@@ -2838,7 +2923,7 @@ int git_repository_detach_head(git_repository* repo)
2838
2923
  git_buf log_message = GIT_BUF_INIT;
2839
2924
  int error;
2840
2925
 
2841
- assert(repo);
2926
+ GIT_ASSERT_ARG(repo);
2842
2927
 
2843
2928
  if ((error = git_reference_lookup(&current, repo, GIT_HEAD_FILE)) < 0)
2844
2929
  return error;
@@ -2873,7 +2958,7 @@ int git_repository_state(git_repository *repo)
2873
2958
  git_buf repo_path = GIT_BUF_INIT;
2874
2959
  int state = GIT_REPOSITORY_STATE_NONE;
2875
2960
 
2876
- assert(repo);
2961
+ GIT_ASSERT_ARG(repo);
2877
2962
 
2878
2963
  if (git_buf_puts(&repo_path, repo->gitdir) < 0)
2879
2964
  return -1;
@@ -2950,7 +3035,7 @@ static const char *state_files[] = {
2950
3035
 
2951
3036
  int git_repository_state_cleanup(git_repository *repo)
2952
3037
  {
2953
- assert(repo);
3038
+ GIT_ASSERT_ARG(repo);
2954
3039
 
2955
3040
  return git_repository__cleanup_files(repo, state_files, ARRAY_SIZE(state_files));
2956
3041
  }
@@ -3016,8 +3101,8 @@ int git_repository_set_ident(git_repository *repo, const char *name, const char
3016
3101
  GIT_ERROR_CHECK_ALLOC(tmp_email);
3017
3102
  }
3018
3103
 
3019
- tmp_name = git__swap(repo->ident_name, tmp_name);
3020
- tmp_email = git__swap(repo->ident_email, tmp_email);
3104
+ tmp_name = git_atomic_swap(repo->ident_name, tmp_name);
3105
+ tmp_email = git_atomic_swap(repo->ident_email, tmp_email);
3021
3106
 
3022
3107
  git__free(tmp_name);
3023
3108
  git__free(tmp_email);
@@ -3027,28 +3112,16 @@ int git_repository_set_ident(git_repository *repo, const char *name, const char
3027
3112
 
3028
3113
  int git_repository_submodule_cache_all(git_repository *repo)
3029
3114
  {
3030
- int error;
3031
-
3032
- assert(repo);
3033
-
3034
- if ((error = git_strmap_new(&repo->submodule_cache)))
3035
- return error;
3036
-
3037
- error = git_submodule__map(repo, repo->submodule_cache);
3038
- return error;
3115
+ GIT_ASSERT_ARG(repo);
3116
+ return git_submodule_cache_init(&repo->submodule_cache, repo);
3039
3117
  }
3040
3118
 
3041
3119
  int git_repository_submodule_cache_clear(git_repository *repo)
3042
3120
  {
3043
- git_submodule *sm;
3044
- assert(repo);
3045
- if (repo->submodule_cache == NULL) {
3046
- return 0;
3047
- }
3048
- git_strmap_foreach_value(repo->submodule_cache, sm, {
3049
- git_submodule_free(sm);
3050
- });
3051
- git_strmap_free(repo->submodule_cache);
3052
- repo->submodule_cache = 0;
3053
- return 0;
3121
+ int error = 0;
3122
+ GIT_ASSERT_ARG(repo);
3123
+
3124
+ error = git_submodule_cache_free(repo->submodule_cache);
3125
+ repo->submodule_cache = NULL;
3126
+ return error;
3054
3127
  }