rugged 1.1.1 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
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
@@ -24,7 +24,8 @@ int git_refdb_new(git_refdb **out, git_repository *repo)
24
24
  {
25
25
  git_refdb *db;
26
26
 
27
- assert(out && repo);
27
+ GIT_ASSERT_ARG(out);
28
+ GIT_ASSERT_ARG(repo);
28
29
 
29
30
  db = git__calloc(1, sizeof(*db));
30
31
  GIT_ERROR_CHECK_ALLOC(db);
@@ -41,7 +42,8 @@ int git_refdb_open(git_refdb **out, git_repository *repo)
41
42
  git_refdb *db;
42
43
  git_refdb_backend *dir;
43
44
 
44
- assert(out && repo);
45
+ GIT_ASSERT_ARG(out);
46
+ GIT_ASSERT_ARG(repo);
45
47
 
46
48
  *out = NULL;
47
49
 
@@ -89,7 +91,7 @@ int git_refdb_set_backend(git_refdb *db, git_refdb_backend *backend)
89
91
 
90
92
  int git_refdb_compress(git_refdb *db)
91
93
  {
92
- assert(db);
94
+ GIT_ASSERT_ARG(db);
93
95
 
94
96
  if (db->backend->compress)
95
97
  return db->backend->compress(db->backend);
@@ -114,7 +116,9 @@ void git_refdb_free(git_refdb *db)
114
116
 
115
117
  int git_refdb_exists(int *exists, git_refdb *refdb, const char *ref_name)
116
118
  {
117
- assert(exists && refdb && refdb->backend);
119
+ GIT_ASSERT_ARG(exists);
120
+ GIT_ASSERT_ARG(refdb);
121
+ GIT_ASSERT_ARG(refdb->backend);
118
122
 
119
123
  return refdb->backend->exists(exists, refdb->backend, ref_name);
120
124
  }
@@ -124,7 +128,10 @@ int git_refdb_lookup(git_reference **out, git_refdb *db, const char *ref_name)
124
128
  git_reference *ref;
125
129
  int error;
126
130
 
127
- assert(db && db->backend && out && ref_name);
131
+ GIT_ASSERT_ARG(db);
132
+ GIT_ASSERT_ARG(db->backend);
133
+ GIT_ASSERT_ARG(out);
134
+ GIT_ASSERT_ARG(ref_name);
128
135
 
129
136
  error = db->backend->lookup(&ref, db->backend, ref_name);
130
137
  if (error < 0)
@@ -234,7 +241,8 @@ void git_refdb_iterator_free(git_reference_iterator *iter)
234
241
 
235
242
  int git_refdb_write(git_refdb *db, git_reference *ref, int force, const git_signature *who, const char *message, const git_oid *old_id, const char *old_target)
236
243
  {
237
- assert(db && db->backend);
244
+ GIT_ASSERT_ARG(db);
245
+ GIT_ASSERT_ARG(db->backend);
238
246
 
239
247
  GIT_REFCOUNT_INC(db);
240
248
  ref->db = db;
@@ -253,7 +261,9 @@ int git_refdb_rename(
253
261
  {
254
262
  int error;
255
263
 
256
- assert(db && db->backend);
264
+ GIT_ASSERT_ARG(db);
265
+ GIT_ASSERT_ARG(db->backend);
266
+
257
267
  error = db->backend->rename(out, db->backend, old_name, new_name, force, who, message);
258
268
  if (error < 0)
259
269
  return error;
@@ -268,7 +278,9 @@ int git_refdb_rename(
268
278
 
269
279
  int git_refdb_delete(struct git_refdb *db, const char *ref_name, const git_oid *old_id, const char *old_target)
270
280
  {
271
- assert(db && db->backend);
281
+ GIT_ASSERT_ARG(db);
282
+ GIT_ASSERT_ARG(db->backend);
283
+
272
284
  return db->backend->del(db->backend, ref_name, old_id, old_target);
273
285
  }
274
286
 
@@ -276,7 +288,8 @@ int git_refdb_reflog_read(git_reflog **out, git_refdb *db, const char *name)
276
288
  {
277
289
  int error;
278
290
 
279
- assert(db && db->backend);
291
+ GIT_ASSERT_ARG(db);
292
+ GIT_ASSERT_ARG(db->backend);
280
293
 
281
294
  if ((error = db->backend->reflog_read(out, db->backend, name)) < 0)
282
295
  return error;
@@ -368,14 +381,16 @@ out:
368
381
 
369
382
  int git_refdb_has_log(git_refdb *db, const char *refname)
370
383
  {
371
- assert(db && refname);
384
+ GIT_ASSERT_ARG(db);
385
+ GIT_ASSERT_ARG(refname);
372
386
 
373
387
  return db->backend->has_log(db->backend, refname);
374
388
  }
375
389
 
376
390
  int git_refdb_ensure_log(git_refdb *db, const char *refname)
377
391
  {
378
- assert(db && refname);
392
+ GIT_ASSERT_ARG(db);
393
+ GIT_ASSERT_ARG(refname);
379
394
 
380
395
  return db->backend->ensure_log(db->backend, refname);
381
396
  }
@@ -389,7 +404,9 @@ int git_refdb_init_backend(git_refdb_backend *backend, unsigned int version)
389
404
 
390
405
  int git_refdb_lock(void **payload, git_refdb *db, const char *refname)
391
406
  {
392
- assert(payload && db && refname);
407
+ GIT_ASSERT_ARG(payload);
408
+ GIT_ASSERT_ARG(db);
409
+ GIT_ASSERT_ARG(refname);
393
410
 
394
411
  if (!db->backend->lock) {
395
412
  git_error_set(GIT_ERROR_REFERENCE, "backend does not support locking");
@@ -401,7 +418,7 @@ int git_refdb_lock(void **payload, git_refdb *db, const char *refname)
401
418
 
402
419
  int git_refdb_unlock(git_refdb *db, void *payload, int success, int update_reflog, const git_reference *ref, const git_signature *sig, const char *message)
403
420
  {
404
- assert(db);
421
+ GIT_ASSERT_ARG(db);
405
422
 
406
423
  return db->backend->unlock(db->backend, payload, success, update_reflog, ref, sig, message);
407
424
  }
@@ -68,6 +68,35 @@ typedef struct refdb_fs_backend {
68
68
 
69
69
  static int refdb_reflog_fs__delete(git_refdb_backend *_backend, const char *name);
70
70
 
71
+ GIT_INLINE(int) loose_path(
72
+ git_buf *out,
73
+ const char *base,
74
+ const char *refname)
75
+ {
76
+ if (git_buf_joinpath(out, base, refname) < 0)
77
+ return -1;
78
+
79
+ return git_path_validate_filesystem_with_suffix(out->ptr, out->size,
80
+ CONST_STRLEN(".lock"));
81
+ }
82
+
83
+ GIT_INLINE(int) reflog_path(
84
+ git_buf *out,
85
+ git_repository *repo,
86
+ const char *refname)
87
+ {
88
+ const char *base;
89
+ int error;
90
+
91
+ base = (strcmp(refname, GIT_HEAD_FILE) == 0) ? repo->gitdir :
92
+ repo->commondir;
93
+
94
+ if ((error = git_buf_joinpath(out, base, GIT_REFLOG_DIR)) < 0)
95
+ return error;
96
+
97
+ return loose_path(out, out->ptr, refname);
98
+ }
99
+
71
100
  static int packref_cmp(const void *a_, const void *b_)
72
101
  {
73
102
  const struct packref *a = a_, *b = b_;
@@ -93,7 +122,7 @@ static int packed_reload(refdb_fs_backend *backend)
93
122
  */
94
123
  if (error <= 0) {
95
124
  if (error == GIT_ENOTFOUND) {
96
- git_sortedcache_clear(backend->refcache, true);
125
+ GIT_UNUSED(git_sortedcache_clear(backend->refcache, true));
97
126
  git_error_clear();
98
127
  error = 0;
99
128
  }
@@ -102,7 +131,7 @@ static int packed_reload(refdb_fs_backend *backend)
102
131
 
103
132
  /* At this point, refresh the packed refs from the loaded buffer. */
104
133
 
105
- git_sortedcache_clear(backend->refcache, false);
134
+ GIT_UNUSED(git_sortedcache_clear(backend->refcache, false));
106
135
 
107
136
  scan = (char *)packedrefs.ptr;
108
137
  eof = scan + packedrefs.size;
@@ -190,7 +219,7 @@ static int packed_reload(refdb_fs_backend *backend)
190
219
  parse_failed:
191
220
  git_error_set(GIT_ERROR_REFERENCE, "corrupted packed references file");
192
221
 
193
- git_sortedcache_clear(backend->refcache, false);
222
+ GIT_UNUSED(git_sortedcache_clear(backend->refcache, false));
194
223
  git_sortedcache_wunlock(backend->refcache);
195
224
  git_buf_dispose(&packedrefs);
196
225
 
@@ -223,9 +252,8 @@ static int loose_readbuffer(git_buf *buf, const char *base, const char *path)
223
252
  {
224
253
  int error;
225
254
 
226
- /* build full path to file */
227
- if ((error = git_buf_joinpath(buf, base, path)) < 0 ||
228
- (error = git_futils_readbuffer(buf, buf->ptr)) < 0)
255
+ if ((error = loose_path(buf, base, path)) < 0 ||
256
+ (error = git_futils_readbuffer(buf, buf->ptr)) < 0)
229
257
  git_buf_dispose(buf);
230
258
 
231
259
  return error;
@@ -332,11 +360,11 @@ static int refdb_fs_backend__exists(
332
360
  git_buf ref_path = GIT_BUF_INIT;
333
361
  int error;
334
362
 
335
- assert(backend);
363
+ GIT_ASSERT_ARG(backend);
336
364
 
337
365
  *exists = 0;
338
366
 
339
- if ((error = git_buf_joinpath(&ref_path, backend->gitpath, ref_name)) < 0)
367
+ if ((error = loose_path(&ref_path, backend->gitpath, ref_name)) < 0)
340
368
  goto out;
341
369
 
342
370
  if (git_path_isfile(ref_path.ptr)) {
@@ -473,7 +501,7 @@ static int refdb_fs_backend__lookup(
473
501
  refdb_fs_backend *backend = GIT_CONTAINER_OF(_backend, refdb_fs_backend, parent);
474
502
  int error;
475
503
 
476
- assert(backend);
504
+ GIT_ASSERT_ARG(backend);
477
505
 
478
506
  if (!(error = loose_lookup(out, backend, ref_name)))
479
507
  return 0;
@@ -550,7 +578,7 @@ static int iter_load_loose_paths(refdb_fs_backend *backend, refdb_fs_iter *iter)
550
578
  }
551
579
  }
552
580
 
553
- if ((error = git_buf_printf(&path, "%s/", backend->commonpath)) < 0 ||
581
+ if ((error = git_buf_puts(&path, backend->commonpath)) < 0 ||
554
582
  (error = git_buf_put(&path, ref_prefix, ref_prefix_len)) < 0) {
555
583
  git_buf_dispose(&path);
556
584
  return error;
@@ -679,7 +707,7 @@ static int refdb_fs_backend__iterator(
679
707
  refdb_fs_iter *iter = NULL;
680
708
  int error;
681
709
 
682
- assert(backend);
710
+ GIT_ASSERT_ARG(backend);
683
711
 
684
712
  iter = git__calloc(1, sizeof(refdb_fs_iter));
685
713
  GIT_ERROR_CHECK_ALLOC(iter);
@@ -785,9 +813,11 @@ static int loose_lock(git_filebuf *file, refdb_fs_backend *backend, const char *
785
813
  git_buf ref_path = GIT_BUF_INIT;
786
814
  const char *basedir;
787
815
 
788
- assert(file && backend && name);
816
+ GIT_ASSERT_ARG(file);
817
+ GIT_ASSERT_ARG(backend);
818
+ GIT_ASSERT_ARG(name);
789
819
 
790
- if (!git_path_isvalid(backend->repo, name, 0, GIT_PATH_REJECT_FILESYSTEM_DEFAULTS)) {
820
+ if (!git_path_validate(backend->repo, name, 0, GIT_PATH_REJECT_FILESYSTEM_DEFAULTS)) {
791
821
  git_error_set(GIT_ERROR_INVALID, "invalid reference name '%s'", name);
792
822
  return GIT_EINVALIDSPEC;
793
823
  }
@@ -803,8 +833,8 @@ static int loose_lock(git_filebuf *file, refdb_fs_backend *backend, const char *
803
833
  if ((error = git_futils_rmdir_r(name, basedir, GIT_RMDIR_SKIP_NONEMPTY)) < 0)
804
834
  return error;
805
835
 
806
- if (git_buf_joinpath(&ref_path, basedir, name) < 0)
807
- return -1;
836
+ if ((error = loose_path(&ref_path, basedir, name)) < 0)
837
+ return error;
808
838
 
809
839
  filebuf_flags = GIT_FILEBUF_CREATE_LEADING_DIRS;
810
840
  if (backend->fsync)
@@ -821,7 +851,8 @@ static int loose_lock(git_filebuf *file, refdb_fs_backend *backend, const char *
821
851
 
822
852
  static int loose_commit(git_filebuf *file, const git_reference *ref)
823
853
  {
824
- assert(file && ref);
854
+ GIT_ASSERT_ARG(file);
855
+ GIT_ASSERT_ARG(ref);
825
856
 
826
857
  if (ref->type == GIT_REFERENCE_DIRECT) {
827
858
  char oid[GIT_OID_HEXSZ + 1];
@@ -831,7 +862,7 @@ static int loose_commit(git_filebuf *file, const git_reference *ref)
831
862
  } else if (ref->type == GIT_REFERENCE_SYMBOLIC) {
832
863
  git_filebuf_printf(file, GIT_SYMREF "%s\n", ref->target.symbolic);
833
864
  } else {
834
- assert(0); /* don't let this happen */
865
+ GIT_ASSERT(0);
835
866
  }
836
867
 
837
868
  return git_filebuf_commit(file);
@@ -1068,7 +1099,7 @@ static int packed_write(refdb_fs_backend *backend)
1068
1099
 
1069
1100
  for (i = 0; i < git_sortedcache_entrycount(refcache); ++i) {
1070
1101
  struct packref *ref = git_sortedcache_entry(refcache, i);
1071
- assert(ref);
1102
+ GIT_ASSERT(ref);
1072
1103
 
1073
1104
  if ((error = packed_find_peel(backend, ref)) < 0)
1074
1105
  goto fail;
@@ -1142,8 +1173,11 @@ static int cmp_old_ref(int *cmp, git_refdb_backend *backend, const char *name,
1142
1173
  if (!old_id && !old_target)
1143
1174
  return 0;
1144
1175
 
1145
- if ((error = refdb_fs_backend__lookup(&old_ref, backend, name)) < 0)
1176
+ if ((error = refdb_fs_backend__lookup(&old_ref, backend, name)) < 0) {
1177
+ if (error == GIT_ENOTFOUND && old_id && git_oid_is_zero(old_id))
1178
+ return 0;
1146
1179
  goto out;
1180
+ }
1147
1181
 
1148
1182
  /* If the types don't match, there's no way the values do */
1149
1183
  if (old_id && old_ref->type != GIT_REFERENCE_DIRECT) {
@@ -1221,7 +1255,7 @@ static int refdb_fs_backend__write(
1221
1255
  git_filebuf file = GIT_FILEBUF_INIT;
1222
1256
  int error = 0;
1223
1257
 
1224
- assert(backend);
1258
+ GIT_ASSERT_ARG(backend);
1225
1259
 
1226
1260
  if ((error = reference_path_available(backend, ref->name, NULL, force)) < 0)
1227
1261
  return error;
@@ -1294,7 +1328,7 @@ on_error:
1294
1328
  return error;
1295
1329
  }
1296
1330
 
1297
- static void refdb_fs_backend__prune_refs(
1331
+ static int refdb_fs_backend__prune_refs(
1298
1332
  refdb_fs_backend *backend,
1299
1333
  const char *ref_name,
1300
1334
  const char *prefix)
@@ -1302,10 +1336,12 @@ static void refdb_fs_backend__prune_refs(
1302
1336
  git_buf relative_path = GIT_BUF_INIT;
1303
1337
  git_buf base_path = GIT_BUF_INIT;
1304
1338
  size_t commonlen;
1339
+ int error;
1305
1340
 
1306
- assert(backend && ref_name);
1341
+ GIT_ASSERT_ARG(backend);
1342
+ GIT_ASSERT_ARG(ref_name);
1307
1343
 
1308
- if (git_buf_sets(&relative_path, ref_name) < 0)
1344
+ if ((error = git_buf_sets(&relative_path, ref_name)) < 0)
1309
1345
  goto cleanup;
1310
1346
 
1311
1347
  git_path_squash_slashes(&relative_path);
@@ -1315,20 +1351,33 @@ static void refdb_fs_backend__prune_refs(
1315
1351
 
1316
1352
  git_buf_truncate(&relative_path, commonlen);
1317
1353
 
1318
- if (prefix) {
1319
- if (git_buf_join3(&base_path, '/', backend->commonpath, prefix, git_buf_cstr(&relative_path)) < 0)
1320
- goto cleanup;
1321
- } else {
1322
- if (git_buf_joinpath(&base_path, backend->commonpath, git_buf_cstr(&relative_path)) < 0)
1323
- goto cleanup;
1324
- }
1354
+ if (prefix)
1355
+ error = git_buf_join3(&base_path, '/',
1356
+ backend->commonpath, prefix,
1357
+ git_buf_cstr(&relative_path));
1358
+ else
1359
+ error = git_buf_joinpath(&base_path,
1360
+ backend->commonpath,
1361
+ git_buf_cstr(&relative_path));
1325
1362
 
1326
- git_futils_rmdir_r(ref_name + commonlen, git_buf_cstr(&base_path), GIT_RMDIR_EMPTY_PARENTS | GIT_RMDIR_SKIP_ROOT);
1363
+ if (!error)
1364
+ error = git_path_validate_filesystem(base_path.ptr, base_path.size);
1365
+
1366
+ if (error < 0)
1367
+ goto cleanup;
1368
+
1369
+ error = git_futils_rmdir_r(ref_name + commonlen,
1370
+ git_buf_cstr(&base_path),
1371
+ GIT_RMDIR_EMPTY_PARENTS | GIT_RMDIR_SKIP_ROOT);
1372
+
1373
+ if (error == GIT_ENOTFOUND)
1374
+ error = 0;
1327
1375
  }
1328
1376
 
1329
1377
  cleanup:
1330
1378
  git_buf_dispose(&relative_path);
1331
1379
  git_buf_dispose(&base_path);
1380
+ return error;
1332
1381
  }
1333
1382
 
1334
1383
  static int refdb_fs_backend__delete(
@@ -1340,7 +1389,8 @@ static int refdb_fs_backend__delete(
1340
1389
  git_filebuf file = GIT_FILEBUF_INIT;
1341
1390
  int error = 0;
1342
1391
 
1343
- assert(backend && ref_name);
1392
+ GIT_ASSERT_ARG(backend);
1393
+ GIT_ASSERT_ARG(ref_name);
1344
1394
 
1345
1395
  if ((error = loose_lock(&file, backend, ref_name)) < 0)
1346
1396
  return error;
@@ -1355,19 +1405,19 @@ static int refdb_fs_backend__delete(
1355
1405
 
1356
1406
  static int loose_delete(refdb_fs_backend *backend, const char *ref_name)
1357
1407
  {
1358
- git_buf loose_path = GIT_BUF_INIT;
1408
+ git_buf path = GIT_BUF_INIT;
1359
1409
  int error = 0;
1360
1410
 
1361
- if (git_buf_joinpath(&loose_path, backend->commonpath, ref_name) < 0)
1362
- return -1;
1411
+ if ((error = loose_path(&path, backend->commonpath, ref_name)) < 0)
1412
+ return error;
1363
1413
 
1364
- error = p_unlink(loose_path.ptr);
1414
+ error = p_unlink(path.ptr);
1365
1415
  if (error < 0 && errno == ENOENT)
1366
1416
  error = GIT_ENOTFOUND;
1367
1417
  else if (error != 0)
1368
1418
  error = -1;
1369
1419
 
1370
- git_buf_dispose(&loose_path);
1420
+ git_buf_dispose(&path);
1371
1421
 
1372
1422
  return error;
1373
1423
  }
@@ -1426,7 +1476,7 @@ static int refdb_fs_backend__delete_tail(
1426
1476
  cleanup:
1427
1477
  git_filebuf_cleanup(file);
1428
1478
  if (error == 0)
1429
- refdb_fs_backend__prune_refs(backend, ref_name, "");
1479
+ error = refdb_fs_backend__prune_refs(backend, ref_name, "");
1430
1480
  return error;
1431
1481
  }
1432
1482
 
@@ -1446,7 +1496,7 @@ static int refdb_fs_backend__rename(
1446
1496
  git_filebuf file = GIT_FILEBUF_INIT;
1447
1497
  int error;
1448
1498
 
1449
- assert(backend);
1499
+ GIT_ASSERT_ARG(backend);
1450
1500
 
1451
1501
  if ((error = reference_path_available(
1452
1502
  backend, new_name, old_name, force)) < 0 ||
@@ -1499,7 +1549,7 @@ static int refdb_fs_backend__compress(git_refdb_backend *_backend)
1499
1549
  int error;
1500
1550
  refdb_fs_backend *backend = GIT_CONTAINER_OF(_backend, refdb_fs_backend, parent);
1501
1551
 
1502
- assert(backend);
1552
+ GIT_ASSERT_ARG(backend);
1503
1553
 
1504
1554
  if ((error = packed_reload(backend)) < 0 || /* load the existing packfile */
1505
1555
  (error = packed_loadloose(backend)) < 0 || /* add all the loose refs */
@@ -1513,7 +1563,8 @@ static void refdb_fs_backend__free(git_refdb_backend *_backend)
1513
1563
  {
1514
1564
  refdb_fs_backend *backend = GIT_CONTAINER_OF(_backend, refdb_fs_backend, parent);
1515
1565
 
1516
- assert(backend);
1566
+ if (!backend)
1567
+ return;
1517
1568
 
1518
1569
  git_sortedcache_free(backend->refcache);
1519
1570
  git__free(backend->gitpath);
@@ -1558,8 +1609,9 @@ static char *setup_namespace(git_repository *repo, const char *in)
1558
1609
  GIT_MKDIR_PATH, NULL) < 0)
1559
1610
  goto done;
1560
1611
 
1561
- /* Return root of the namespaced gitpath, i.e. without the trailing '/refs' */
1612
+ /* Return root of the namespaced gitpath, i.e. without the trailing 'refs' */
1562
1613
  git_buf_rtruncate_at_char(&path, '/');
1614
+ git_buf_putc(&path, '/');
1563
1615
  out = git_buf_detach(&path);
1564
1616
 
1565
1617
  done:
@@ -1660,13 +1712,6 @@ static int create_new_reflog_file(const char *filepath)
1660
1712
  return p_close(fd);
1661
1713
  }
1662
1714
 
1663
- GIT_INLINE(int) retrieve_reflog_path(git_buf *path, git_repository *repo, const char *name)
1664
- {
1665
- if (strcmp(name, GIT_HEAD_FILE) == 0)
1666
- return git_buf_join3(path, '/', repo->gitdir, GIT_REFLOG_DIR, name);
1667
- return git_buf_join3(path, '/', repo->commondir, GIT_REFLOG_DIR, name);
1668
- }
1669
-
1670
1715
  static int refdb_reflog_fs__ensure_log(git_refdb_backend *_backend, const char *name)
1671
1716
  {
1672
1717
  refdb_fs_backend *backend;
@@ -1674,12 +1719,12 @@ static int refdb_reflog_fs__ensure_log(git_refdb_backend *_backend, const char *
1674
1719
  git_buf path = GIT_BUF_INIT;
1675
1720
  int error;
1676
1721
 
1677
- assert(_backend && name);
1722
+ GIT_ASSERT_ARG(_backend && name);
1678
1723
 
1679
1724
  backend = GIT_CONTAINER_OF(_backend, refdb_fs_backend, parent);
1680
1725
  repo = backend->repo;
1681
1726
 
1682
- if ((error = retrieve_reflog_path(&path, repo, name)) < 0)
1727
+ if ((error = reflog_path(&path, repo, name)) < 0)
1683
1728
  return error;
1684
1729
 
1685
1730
  error = create_new_reflog_file(git_buf_cstr(&path));
@@ -1693,7 +1738,7 @@ static int has_reflog(git_repository *repo, const char *name)
1693
1738
  int ret = 0;
1694
1739
  git_buf path = GIT_BUF_INIT;
1695
1740
 
1696
- if (retrieve_reflog_path(&path, repo, name) < 0)
1741
+ if (reflog_path(&path, repo, name) < 0)
1697
1742
  goto cleanup;
1698
1743
 
1699
1744
  ret = git_path_isfile(git_buf_cstr(&path));
@@ -1707,7 +1752,8 @@ static int refdb_reflog_fs__has_log(git_refdb_backend *_backend, const char *nam
1707
1752
  {
1708
1753
  refdb_fs_backend *backend;
1709
1754
 
1710
- assert(_backend && name);
1755
+ GIT_ASSERT_ARG(_backend);
1756
+ GIT_ASSERT_ARG(name);
1711
1757
 
1712
1758
  backend = GIT_CONTAINER_OF(_backend, refdb_fs_backend, parent);
1713
1759
 
@@ -1723,7 +1769,9 @@ static int refdb_reflog_fs__read(git_reflog **out, git_refdb_backend *_backend,
1723
1769
  git_repository *repo;
1724
1770
  refdb_fs_backend *backend;
1725
1771
 
1726
- assert(out && _backend && name);
1772
+ GIT_ASSERT_ARG(out);
1773
+ GIT_ASSERT_ARG(_backend);
1774
+ GIT_ASSERT_ARG(name);
1727
1775
 
1728
1776
  backend = GIT_CONTAINER_OF(_backend, refdb_fs_backend, parent);
1729
1777
  repo = backend->repo;
@@ -1731,7 +1779,7 @@ static int refdb_reflog_fs__read(git_reflog **out, git_refdb_backend *_backend,
1731
1779
  if (reflog_alloc(&log, name) < 0)
1732
1780
  return -1;
1733
1781
 
1734
- if (retrieve_reflog_path(&log_path, repo, name) < 0)
1782
+ if (reflog_path(&log_path, repo, name) < 0)
1735
1783
  goto cleanup;
1736
1784
 
1737
1785
  error = git_futils_readbuffer(&log_file, git_buf_cstr(&log_path));
@@ -1808,12 +1856,12 @@ static int lock_reflog(git_filebuf *file, refdb_fs_backend *backend, const char
1808
1856
 
1809
1857
  repo = backend->repo;
1810
1858
 
1811
- if (!git_path_isvalid(backend->repo, refname, 0, GIT_PATH_REJECT_FILESYSTEM_DEFAULTS)) {
1859
+ if (!git_path_validate(backend->repo, refname, 0, GIT_PATH_REJECT_FILESYSTEM_DEFAULTS)) {
1812
1860
  git_error_set(GIT_ERROR_INVALID, "invalid reference name '%s'", refname);
1813
1861
  return GIT_EINVALIDSPEC;
1814
1862
  }
1815
1863
 
1816
- if (retrieve_reflog_path(&log_path, repo, refname) < 0)
1864
+ if (reflog_path(&log_path, repo, refname) < 0)
1817
1865
  return -1;
1818
1866
 
1819
1867
  if (!git_path_isfile(git_buf_cstr(&log_path))) {
@@ -1840,7 +1888,8 @@ static int refdb_reflog_fs__write(git_refdb_backend *_backend, git_reflog *reflo
1840
1888
  git_buf log = GIT_BUF_INIT;
1841
1889
  git_filebuf fbuf = GIT_FILEBUF_INIT;
1842
1890
 
1843
- assert(_backend && reflog);
1891
+ GIT_ASSERT_ARG(_backend);
1892
+ GIT_ASSERT_ARG(reflog);
1844
1893
 
1845
1894
  backend = GIT_CONTAINER_OF(_backend, refdb_fs_backend, parent);
1846
1895
 
@@ -1913,7 +1962,7 @@ static int reflog_append(refdb_fs_backend *backend, const git_reference *ref, co
1913
1962
  if ((error = serialize_reflog_entry(&buf, &old_id, &new_id, who, message)) < 0)
1914
1963
  goto cleanup;
1915
1964
 
1916
- if ((error = retrieve_reflog_path(&path, repo, ref->name)) < 0)
1965
+ if ((error = reflog_path(&path, repo, ref->name)) < 0)
1917
1966
  goto cleanup;
1918
1967
 
1919
1968
  if (((error = git_futils_mkpath2file(git_buf_cstr(&path), 0777)) < 0) &&
@@ -1962,7 +2011,9 @@ static int refdb_reflog_fs__rename(git_refdb_backend *_backend, const char *old_
1962
2011
  git_repository *repo;
1963
2012
  refdb_fs_backend *backend;
1964
2013
 
1965
- assert(_backend && old_name && new_name);
2014
+ GIT_ASSERT_ARG(_backend);
2015
+ GIT_ASSERT_ARG(old_name);
2016
+ GIT_ASSERT_ARG(new_name);
1966
2017
 
1967
2018
  backend = GIT_CONTAINER_OF(_backend, refdb_fs_backend, parent);
1968
2019
  repo = backend->repo;
@@ -1974,11 +2025,11 @@ static int refdb_reflog_fs__rename(git_refdb_backend *_backend, const char *old_
1974
2025
  if (git_buf_joinpath(&temp_path, repo->gitdir, GIT_REFLOG_DIR) < 0)
1975
2026
  return -1;
1976
2027
 
1977
- if (git_buf_joinpath(&old_path, git_buf_cstr(&temp_path), old_name) < 0)
1978
- return -1;
2028
+ if ((error = loose_path(&old_path, git_buf_cstr(&temp_path), old_name)) < 0)
2029
+ return error;
1979
2030
 
1980
- if (git_buf_joinpath(&new_path, git_buf_cstr(&temp_path), git_buf_cstr(&normalized)) < 0)
1981
- return -1;
2031
+ if ((error = loose_path(&new_path, git_buf_cstr(&temp_path), git_buf_cstr(&normalized))) < 0)
2032
+ return error;
1982
2033
 
1983
2034
  if (!git_path_exists(git_buf_cstr(&old_path))) {
1984
2035
  error = GIT_ENOTFOUND;
@@ -1992,8 +2043,8 @@ static int refdb_reflog_fs__rename(git_refdb_backend *_backend, const char *old_
1992
2043
  * - a/b -> a/b/c
1993
2044
  * - a/b/c/d -> a/b/c
1994
2045
  */
1995
- if (git_buf_joinpath(&temp_path, git_buf_cstr(&temp_path), "temp_reflog") < 0)
1996
- return -1;
2046
+ if ((error = loose_path(&temp_path, git_buf_cstr(&temp_path), "temp_reflog")) < 0)
2047
+ return error;
1997
2048
 
1998
2049
  if ((fd = git_futils_mktmp(&temp_path, git_buf_cstr(&temp_path), GIT_REFLOG_FILE_MODE)) < 0) {
1999
2050
  error = -1;
@@ -2039,9 +2090,10 @@ static int refdb_reflog_fs__delete(git_refdb_backend *_backend, const char *name
2039
2090
  git_buf path = GIT_BUF_INIT;
2040
2091
  int error;
2041
2092
 
2042
- assert(_backend && name);
2093
+ GIT_ASSERT_ARG(_backend);
2094
+ GIT_ASSERT_ARG(name);
2043
2095
 
2044
- if ((error = retrieve_reflog_path(&path, backend->repo, name)) < 0)
2096
+ if ((error = reflog_path(&path, backend->repo, name)) < 0)
2045
2097
  goto out;
2046
2098
 
2047
2099
  if (!git_path_exists(path.ptr))
@@ -2050,7 +2102,7 @@ static int refdb_reflog_fs__delete(git_refdb_backend *_backend, const char *name
2050
2102
  if ((error = p_unlink(path.ptr)) < 0)
2051
2103
  goto out;
2052
2104
 
2053
- refdb_fs_backend__prune_refs(backend, name, GIT_REFLOG_DIR);
2105
+ error = refdb_fs_backend__prune_refs(backend, name, GIT_REFLOG_DIR);
2054
2106
 
2055
2107
  out:
2056
2108
  git_buf_dispose(&path);