rugged 1.1.0 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (288) 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 +18 -5
  16. data/vendor/libgit2/deps/ntlmclient/compat.h +0 -34
  17. data/vendor/libgit2/deps/ntlmclient/crypt.h +14 -9
  18. data/vendor/libgit2/deps/ntlmclient/crypt_commoncrypto.c +20 -20
  19. data/vendor/libgit2/deps/ntlmclient/crypt_commoncrypto.h +3 -3
  20. data/vendor/libgit2/deps/ntlmclient/crypt_mbedtls.c +37 -36
  21. data/vendor/libgit2/deps/ntlmclient/crypt_mbedtls.h +4 -3
  22. data/vendor/libgit2/deps/ntlmclient/crypt_openssl.c +178 -51
  23. data/vendor/libgit2/deps/ntlmclient/crypt_openssl.h +74 -5
  24. data/vendor/libgit2/deps/ntlmclient/ntlm.c +156 -124
  25. data/vendor/libgit2/deps/ntlmclient/ntlm.h +13 -9
  26. data/vendor/libgit2/deps/ntlmclient/ntlmclient.h +16 -3
  27. data/vendor/libgit2/deps/ntlmclient/unicode.h +10 -4
  28. data/vendor/libgit2/deps/ntlmclient/unicode_builtin.c +16 -27
  29. data/vendor/libgit2/deps/ntlmclient/unicode_builtin.h +20 -0
  30. data/vendor/libgit2/deps/ntlmclient/unicode_iconv.c +28 -52
  31. data/vendor/libgit2/deps/ntlmclient/unicode_iconv.h +22 -0
  32. data/vendor/libgit2/deps/ntlmclient/util.c +15 -1
  33. data/vendor/libgit2/deps/ntlmclient/util.h +2 -1
  34. data/vendor/libgit2/include/git2/apply.h +2 -0
  35. data/vendor/libgit2/include/git2/attr.h +89 -0
  36. data/vendor/libgit2/include/git2/blame.h +93 -42
  37. data/vendor/libgit2/include/git2/blob.h +31 -3
  38. data/vendor/libgit2/include/git2/branch.h +25 -0
  39. data/vendor/libgit2/include/git2/cert.h +42 -5
  40. data/vendor/libgit2/include/git2/checkout.h +28 -12
  41. data/vendor/libgit2/include/git2/commit.h +35 -19
  42. data/vendor/libgit2/include/git2/common.h +19 -4
  43. data/vendor/libgit2/include/git2/config.h +1 -1
  44. data/vendor/libgit2/include/git2/deprecated.h +206 -6
  45. data/vendor/libgit2/include/git2/diff.h +35 -20
  46. data/vendor/libgit2/include/git2/errors.h +6 -6
  47. data/vendor/libgit2/include/git2/filter.h +57 -17
  48. data/vendor/libgit2/include/git2/graph.h +20 -2
  49. data/vendor/libgit2/include/git2/index.h +3 -3
  50. data/vendor/libgit2/include/git2/indexer.h +2 -1
  51. data/vendor/libgit2/include/git2/odb.h +44 -20
  52. data/vendor/libgit2/include/git2/patch.h +8 -0
  53. data/vendor/libgit2/include/git2/rebase.h +25 -1
  54. data/vendor/libgit2/include/git2/refs.h +9 -5
  55. data/vendor/libgit2/include/git2/remote.h +59 -6
  56. data/vendor/libgit2/include/git2/repository.h +95 -52
  57. data/vendor/libgit2/include/git2/revparse.h +5 -5
  58. data/vendor/libgit2/include/git2/status.h +115 -59
  59. data/vendor/libgit2/include/git2/submodule.h +9 -0
  60. data/vendor/libgit2/include/git2/sys/commit_graph.h +174 -0
  61. data/vendor/libgit2/include/git2/sys/filter.h +49 -28
  62. data/vendor/libgit2/include/git2/sys/midx.h +74 -0
  63. data/vendor/libgit2/include/git2/sys/odb_backend.h +7 -0
  64. data/vendor/libgit2/include/git2/sys/transport.h +1 -0
  65. data/vendor/libgit2/include/git2/tag.h +12 -0
  66. data/vendor/libgit2/include/git2/transport.h +1 -1
  67. data/vendor/libgit2/include/git2/tree.h +2 -14
  68. data/vendor/libgit2/include/git2/types.h +9 -0
  69. data/vendor/libgit2/include/git2/version.h +3 -3
  70. data/vendor/libgit2/include/git2/worktree.h +1 -0
  71. data/vendor/libgit2/src/CMakeLists.txt +25 -4
  72. data/vendor/libgit2/src/alloc.c +21 -8
  73. data/vendor/libgit2/src/allocators/failalloc.c +92 -0
  74. data/vendor/libgit2/src/allocators/failalloc.h +23 -0
  75. data/vendor/libgit2/src/allocators/stdalloc.c +41 -10
  76. data/vendor/libgit2/src/allocators/win32_leakcheck.c +118 -0
  77. data/vendor/libgit2/src/allocators/{win32_crtdbg.h → win32_leakcheck.h} +3 -3
  78. data/vendor/libgit2/src/annotated_commit.c +21 -9
  79. data/vendor/libgit2/src/apply.c +16 -7
  80. data/vendor/libgit2/src/array.h +11 -11
  81. data/vendor/libgit2/src/attr.c +181 -74
  82. data/vendor/libgit2/src/attr_file.c +84 -39
  83. data/vendor/libgit2/src/attr_file.h +32 -11
  84. data/vendor/libgit2/src/attrcache.c +42 -37
  85. data/vendor/libgit2/src/attrcache.h +4 -5
  86. data/vendor/libgit2/src/blame.c +26 -15
  87. data/vendor/libgit2/src/blob.c +44 -24
  88. data/vendor/libgit2/src/branch.c +69 -17
  89. data/vendor/libgit2/src/buffer.c +334 -25
  90. data/vendor/libgit2/src/buffer.h +153 -2
  91. data/vendor/libgit2/src/cache.c +2 -2
  92. data/vendor/libgit2/src/cache.h +7 -7
  93. data/vendor/libgit2/src/cc-compat.h +10 -2
  94. data/vendor/libgit2/src/checkout.c +48 -26
  95. data/vendor/libgit2/src/cherrypick.c +6 -2
  96. data/vendor/libgit2/src/clone.c +26 -11
  97. data/vendor/libgit2/src/commit.c +41 -28
  98. data/vendor/libgit2/src/commit_graph.c +1209 -0
  99. data/vendor/libgit2/src/commit_graph.h +162 -0
  100. data/vendor/libgit2/src/commit_list.c +46 -0
  101. data/vendor/libgit2/src/commit_list.h +2 -0
  102. data/vendor/libgit2/src/common.h +25 -2
  103. data/vendor/libgit2/src/config.c +37 -15
  104. data/vendor/libgit2/src/config_cache.c +9 -4
  105. data/vendor/libgit2/src/config_file.c +16 -8
  106. data/vendor/libgit2/src/config_parse.c +4 -6
  107. data/vendor/libgit2/src/crlf.c +16 -6
  108. data/vendor/libgit2/src/date.c +4 -3
  109. data/vendor/libgit2/src/delta.c +1 -1
  110. data/vendor/libgit2/src/describe.c +6 -3
  111. data/vendor/libgit2/src/diff.c +11 -8
  112. data/vendor/libgit2/src/diff_driver.c +21 -17
  113. data/vendor/libgit2/src/diff_file.c +2 -6
  114. data/vendor/libgit2/src/diff_generate.c +46 -17
  115. data/vendor/libgit2/src/diff_print.c +19 -6
  116. data/vendor/libgit2/src/diff_stats.c +7 -5
  117. data/vendor/libgit2/src/diff_tform.c +11 -10
  118. data/vendor/libgit2/src/diff_xdiff.c +4 -2
  119. data/vendor/libgit2/src/diff_xdiff.h +1 -1
  120. data/vendor/libgit2/src/errors.c +24 -19
  121. data/vendor/libgit2/src/features.h.in +5 -1
  122. data/vendor/libgit2/src/fetch.c +5 -2
  123. data/vendor/libgit2/src/fetchhead.c +8 -4
  124. data/vendor/libgit2/src/filebuf.c +9 -7
  125. data/vendor/libgit2/src/filter.c +206 -110
  126. data/vendor/libgit2/src/filter.h +24 -5
  127. data/vendor/libgit2/src/futils.c +5 -5
  128. data/vendor/libgit2/src/futils.h +1 -1
  129. data/vendor/libgit2/src/graph.c +64 -9
  130. data/vendor/libgit2/src/hash/sha1/collisiondetect.c +3 -3
  131. data/vendor/libgit2/src/hash/sha1/common_crypto.c +3 -3
  132. data/vendor/libgit2/src/hash/sha1/generic.h +1 -1
  133. data/vendor/libgit2/src/hash/sha1/mbedtls.c +12 -12
  134. data/vendor/libgit2/src/hash/sha1/openssl.c +3 -3
  135. data/vendor/libgit2/src/hash/sha1/sha1dc/sha1.c +0 -2
  136. data/vendor/libgit2/src/hash/sha1/win32.c +15 -11
  137. data/vendor/libgit2/src/hash.c +16 -13
  138. data/vendor/libgit2/src/hash.h +1 -1
  139. data/vendor/libgit2/src/hashsig.c +23 -10
  140. data/vendor/libgit2/src/ident.c +13 -3
  141. data/vendor/libgit2/src/ignore.c +35 -19
  142. data/vendor/libgit2/src/index.c +112 -75
  143. data/vendor/libgit2/src/index.h +1 -1
  144. data/vendor/libgit2/src/indexer.c +50 -32
  145. data/vendor/libgit2/src/integer.h +79 -2
  146. data/vendor/libgit2/src/iterator.c +36 -24
  147. data/vendor/libgit2/src/iterator.h +1 -1
  148. data/vendor/libgit2/src/khash.h +2 -11
  149. data/vendor/libgit2/src/{settings.c → libgit2.c} +117 -50
  150. data/vendor/libgit2/src/libgit2.h +15 -0
  151. data/vendor/libgit2/src/mailmap.c +23 -10
  152. data/vendor/libgit2/src/map.h +3 -3
  153. data/vendor/libgit2/src/merge.c +75 -32
  154. data/vendor/libgit2/src/merge.h +2 -1
  155. data/vendor/libgit2/src/merge_driver.c +19 -13
  156. data/vendor/libgit2/src/merge_file.c +11 -3
  157. data/vendor/libgit2/src/message.c +3 -1
  158. data/vendor/libgit2/src/midx.c +471 -10
  159. data/vendor/libgit2/src/midx.h +28 -1
  160. data/vendor/libgit2/src/mwindow.c +106 -60
  161. data/vendor/libgit2/src/mwindow.h +3 -3
  162. data/vendor/libgit2/src/net.c +127 -3
  163. data/vendor/libgit2/src/net.h +16 -2
  164. data/vendor/libgit2/src/netops.c +6 -4
  165. data/vendor/libgit2/src/netops.h +2 -2
  166. data/vendor/libgit2/src/notes.c +10 -10
  167. data/vendor/libgit2/src/object.c +22 -14
  168. data/vendor/libgit2/src/odb.c +289 -51
  169. data/vendor/libgit2/src/odb.h +16 -2
  170. data/vendor/libgit2/src/odb_loose.c +28 -18
  171. data/vendor/libgit2/src/odb_mempack.c +1 -1
  172. data/vendor/libgit2/src/odb_pack.c +391 -114
  173. data/vendor/libgit2/src/oid.c +5 -4
  174. data/vendor/libgit2/src/pack-objects.c +54 -48
  175. data/vendor/libgit2/src/pack.c +339 -125
  176. data/vendor/libgit2/src/pack.h +25 -7
  177. data/vendor/libgit2/src/patch.c +14 -7
  178. data/vendor/libgit2/src/patch_generate.c +2 -2
  179. data/vendor/libgit2/src/patch_parse.c +2 -1
  180. data/vendor/libgit2/src/path.c +98 -53
  181. data/vendor/libgit2/src/path.h +79 -6
  182. data/vendor/libgit2/src/pathspec.c +8 -8
  183. data/vendor/libgit2/src/pool.c +13 -7
  184. data/vendor/libgit2/src/posix.c +43 -12
  185. data/vendor/libgit2/src/posix.h +9 -0
  186. data/vendor/libgit2/src/reader.c +10 -6
  187. data/vendor/libgit2/src/rebase.c +93 -49
  188. data/vendor/libgit2/src/refdb.c +30 -13
  189. data/vendor/libgit2/src/refdb_fs.c +125 -71
  190. data/vendor/libgit2/src/reflog.c +19 -14
  191. data/vendor/libgit2/src/refs.c +91 -43
  192. data/vendor/libgit2/src/refs.h +1 -1
  193. data/vendor/libgit2/src/refspec.c +80 -44
  194. data/vendor/libgit2/src/remote.c +281 -105
  195. data/vendor/libgit2/src/remote.h +2 -1
  196. data/vendor/libgit2/src/repository.c +191 -118
  197. data/vendor/libgit2/src/repository.h +13 -2
  198. data/vendor/libgit2/src/reset.c +7 -6
  199. data/vendor/libgit2/src/revert.c +6 -2
  200. data/vendor/libgit2/src/revparse.c +14 -9
  201. data/vendor/libgit2/src/revwalk.c +32 -15
  202. data/vendor/libgit2/src/runtime.c +162 -0
  203. data/vendor/libgit2/src/runtime.h +62 -0
  204. data/vendor/libgit2/src/settings.h +11 -0
  205. data/vendor/libgit2/src/signature.c +6 -5
  206. data/vendor/libgit2/src/sortedcache.h +10 -8
  207. data/vendor/libgit2/src/stash.c +3 -1
  208. data/vendor/libgit2/src/status.c +7 -4
  209. data/vendor/libgit2/src/strarray.c +2 -1
  210. data/vendor/libgit2/src/streams/mbedtls.c +14 -17
  211. data/vendor/libgit2/src/streams/mbedtls.h +1 -1
  212. data/vendor/libgit2/src/streams/openssl.c +101 -201
  213. data/vendor/libgit2/src/streams/openssl.h +9 -1
  214. data/vendor/libgit2/src/streams/openssl_dynamic.c +309 -0
  215. data/vendor/libgit2/src/streams/openssl_dynamic.h +348 -0
  216. data/vendor/libgit2/src/streams/openssl_legacy.c +203 -0
  217. data/vendor/libgit2/src/streams/openssl_legacy.h +63 -0
  218. data/vendor/libgit2/src/streams/registry.c +5 -6
  219. data/vendor/libgit2/src/streams/socket.c +6 -2
  220. data/vendor/libgit2/src/streams/stransport.c +6 -3
  221. data/vendor/libgit2/src/streams/tls.c +5 -3
  222. data/vendor/libgit2/src/submodule.c +128 -62
  223. data/vendor/libgit2/src/submodule.h +9 -9
  224. data/vendor/libgit2/src/sysdir.c +4 -6
  225. data/vendor/libgit2/src/tag.c +47 -11
  226. data/vendor/libgit2/src/thread.c +140 -0
  227. data/vendor/libgit2/src/thread.h +479 -0
  228. data/vendor/libgit2/src/threadstate.c +83 -0
  229. data/vendor/libgit2/src/threadstate.h +24 -0
  230. data/vendor/libgit2/src/trace.c +2 -2
  231. data/vendor/libgit2/src/trace.h +17 -13
  232. data/vendor/libgit2/src/transaction.c +19 -8
  233. data/vendor/libgit2/src/transport.c +3 -3
  234. data/vendor/libgit2/src/transports/auth.c +1 -1
  235. data/vendor/libgit2/src/transports/auth_negotiate.c +11 -4
  236. data/vendor/libgit2/src/transports/auth_ntlm.c +10 -6
  237. data/vendor/libgit2/src/transports/credential.c +15 -7
  238. data/vendor/libgit2/src/transports/git.c +1 -3
  239. data/vendor/libgit2/src/transports/http.c +19 -17
  240. data/vendor/libgit2/src/transports/http.h +1 -0
  241. data/vendor/libgit2/src/transports/httpclient.c +62 -30
  242. data/vendor/libgit2/src/transports/httpclient.h +1 -1
  243. data/vendor/libgit2/src/transports/local.c +3 -3
  244. data/vendor/libgit2/src/transports/smart.c +12 -7
  245. data/vendor/libgit2/src/transports/smart.h +1 -1
  246. data/vendor/libgit2/src/transports/smart_protocol.c +11 -5
  247. data/vendor/libgit2/src/transports/ssh.c +51 -17
  248. data/vendor/libgit2/src/transports/winhttp.c +138 -81
  249. data/vendor/libgit2/src/tree.c +100 -77
  250. data/vendor/libgit2/src/tree.h +1 -0
  251. data/vendor/libgit2/src/tsort.c +0 -2
  252. data/vendor/libgit2/src/unix/map.c +3 -1
  253. data/vendor/libgit2/src/unix/posix.h +3 -0
  254. data/vendor/libgit2/src/unix/pthread.h +2 -1
  255. data/vendor/libgit2/src/utf8.c +150 -0
  256. data/vendor/libgit2/src/utf8.h +52 -0
  257. data/vendor/libgit2/src/util.c +53 -129
  258. data/vendor/libgit2/src/util.h +33 -39
  259. data/vendor/libgit2/src/vector.c +23 -19
  260. data/vendor/libgit2/src/vector.h +4 -2
  261. data/vendor/libgit2/src/win32/findfile.c +4 -2
  262. data/vendor/libgit2/src/win32/map.c +1 -1
  263. data/vendor/libgit2/src/win32/msvc-compat.h +9 -1
  264. data/vendor/libgit2/src/win32/path_w32.c +22 -24
  265. data/vendor/libgit2/src/win32/path_w32.h +0 -1
  266. data/vendor/libgit2/src/win32/posix_w32.c +77 -1
  267. data/vendor/libgit2/src/win32/precompiled.h +0 -1
  268. data/vendor/libgit2/src/win32/reparse.h +4 -4
  269. data/vendor/libgit2/src/win32/thread.c +24 -15
  270. data/vendor/libgit2/src/win32/thread.h +1 -1
  271. data/vendor/libgit2/src/win32/w32_buffer.c +3 -3
  272. data/vendor/libgit2/src/win32/w32_common.h +18 -9
  273. data/vendor/libgit2/src/win32/{w32_crtdbg_stacktrace.c → w32_leakcheck.c} +269 -33
  274. data/vendor/libgit2/src/win32/w32_leakcheck.h +222 -0
  275. data/vendor/libgit2/src/win32/w32_util.h +6 -6
  276. data/vendor/libgit2/src/worktree.c +32 -14
  277. data/vendor/libgit2/src/zstream.c +1 -1
  278. metadata +32 -16
  279. data/vendor/libgit2/src/allocators/win32_crtdbg.c +0 -118
  280. data/vendor/libgit2/src/buf_text.c +0 -316
  281. data/vendor/libgit2/src/buf_text.h +0 -122
  282. data/vendor/libgit2/src/global.c +0 -363
  283. data/vendor/libgit2/src/global.h +0 -41
  284. data/vendor/libgit2/src/thread-utils.c +0 -58
  285. data/vendor/libgit2/src/thread-utils.h +0 -364
  286. data/vendor/libgit2/src/win32/w32_crtdbg_stacktrace.h +0 -127
  287. data/vendor/libgit2/src/win32/w32_stack.c +0 -188
  288. data/vendor/libgit2/src/win32/w32_stack.h +0 -140
@@ -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;
@@ -254,7 +282,8 @@ static int loose_lookup_to_packfile(refdb_fs_backend *backend, const char *name)
254
282
  if ((error = loose_parse_oid(&oid, name, &ref_file)) < 0)
255
283
  goto done;
256
284
 
257
- git_sortedcache_wlock(backend->refcache);
285
+ if ((error = git_sortedcache_wlock(backend->refcache)) < 0)
286
+ goto done;
258
287
 
259
288
  if (!(error = git_sortedcache_upsert(
260
289
  (void **)&ref, backend->refcache, name))) {
@@ -331,11 +360,11 @@ static int refdb_fs_backend__exists(
331
360
  git_buf ref_path = GIT_BUF_INIT;
332
361
  int error;
333
362
 
334
- assert(backend);
363
+ GIT_ASSERT_ARG(backend);
335
364
 
336
365
  *exists = 0;
337
366
 
338
- if ((error = git_buf_joinpath(&ref_path, backend->gitpath, ref_name)) < 0)
367
+ if ((error = loose_path(&ref_path, backend->gitpath, ref_name)) < 0)
339
368
  goto out;
340
369
 
341
370
  if (git_path_isfile(ref_path.ptr)) {
@@ -472,7 +501,7 @@ static int refdb_fs_backend__lookup(
472
501
  refdb_fs_backend *backend = GIT_CONTAINER_OF(_backend, refdb_fs_backend, parent);
473
502
  int error;
474
503
 
475
- assert(backend);
504
+ GIT_ASSERT_ARG(backend);
476
505
 
477
506
  if (!(error = loose_lookup(out, backend, ref_name)))
478
507
  return 0;
@@ -549,7 +578,7 @@ static int iter_load_loose_paths(refdb_fs_backend *backend, refdb_fs_iter *iter)
549
578
  }
550
579
  }
551
580
 
552
- if ((error = git_buf_printf(&path, "%s/", backend->commonpath)) < 0 ||
581
+ if ((error = git_buf_puts(&path, backend->commonpath)) < 0 ||
553
582
  (error = git_buf_put(&path, ref_prefix, ref_prefix_len)) < 0) {
554
583
  git_buf_dispose(&path);
555
584
  return error;
@@ -678,7 +707,7 @@ static int refdb_fs_backend__iterator(
678
707
  refdb_fs_iter *iter = NULL;
679
708
  int error;
680
709
 
681
- assert(backend);
710
+ GIT_ASSERT_ARG(backend);
682
711
 
683
712
  iter = git__calloc(1, sizeof(refdb_fs_iter));
684
713
  GIT_ERROR_CHECK_ALLOC(iter);
@@ -760,7 +789,8 @@ static int reference_path_available(
760
789
  }
761
790
  }
762
791
 
763
- git_sortedcache_rlock(backend->refcache);
792
+ if ((error = git_sortedcache_rlock(backend->refcache)) < 0)
793
+ return error;
764
794
 
765
795
  for (i = 0; i < git_sortedcache_entrycount(backend->refcache); ++i) {
766
796
  struct packref *ref = git_sortedcache_entry(backend->refcache, i);
@@ -783,9 +813,11 @@ static int loose_lock(git_filebuf *file, refdb_fs_backend *backend, const char *
783
813
  git_buf ref_path = GIT_BUF_INIT;
784
814
  const char *basedir;
785
815
 
786
- assert(file && backend && name);
816
+ GIT_ASSERT_ARG(file);
817
+ GIT_ASSERT_ARG(backend);
818
+ GIT_ASSERT_ARG(name);
787
819
 
788
- 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)) {
789
821
  git_error_set(GIT_ERROR_INVALID, "invalid reference name '%s'", name);
790
822
  return GIT_EINVALIDSPEC;
791
823
  }
@@ -801,8 +833,8 @@ static int loose_lock(git_filebuf *file, refdb_fs_backend *backend, const char *
801
833
  if ((error = git_futils_rmdir_r(name, basedir, GIT_RMDIR_SKIP_NONEMPTY)) < 0)
802
834
  return error;
803
835
 
804
- if (git_buf_joinpath(&ref_path, basedir, name) < 0)
805
- return -1;
836
+ if ((error = loose_path(&ref_path, basedir, name)) < 0)
837
+ return error;
806
838
 
807
839
  filebuf_flags = GIT_FILEBUF_CREATE_LEADING_DIRS;
808
840
  if (backend->fsync)
@@ -819,7 +851,8 @@ static int loose_lock(git_filebuf *file, refdb_fs_backend *backend, const char *
819
851
 
820
852
  static int loose_commit(git_filebuf *file, const git_reference *ref)
821
853
  {
822
- assert(file && ref);
854
+ GIT_ASSERT_ARG(file);
855
+ GIT_ASSERT_ARG(ref);
823
856
 
824
857
  if (ref->type == GIT_REFERENCE_DIRECT) {
825
858
  char oid[GIT_OID_HEXSZ + 1];
@@ -829,7 +862,7 @@ static int loose_commit(git_filebuf *file, const git_reference *ref)
829
862
  } else if (ref->type == GIT_REFERENCE_SYMBOLIC) {
830
863
  git_filebuf_printf(file, GIT_SYMREF "%s\n", ref->target.symbolic);
831
864
  } else {
832
- assert(0); /* don't let this happen */
865
+ GIT_ASSERT(0);
833
866
  }
834
867
 
835
868
  return git_filebuf_commit(file);
@@ -1066,7 +1099,7 @@ static int packed_write(refdb_fs_backend *backend)
1066
1099
 
1067
1100
  for (i = 0; i < git_sortedcache_entrycount(refcache); ++i) {
1068
1101
  struct packref *ref = git_sortedcache_entry(refcache, i);
1069
- assert(ref);
1102
+ GIT_ASSERT(ref);
1070
1103
 
1071
1104
  if ((error = packed_find_peel(backend, ref)) < 0)
1072
1105
  goto fail;
@@ -1140,8 +1173,11 @@ static int cmp_old_ref(int *cmp, git_refdb_backend *backend, const char *name,
1140
1173
  if (!old_id && !old_target)
1141
1174
  return 0;
1142
1175
 
1143
- 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;
1144
1179
  goto out;
1180
+ }
1145
1181
 
1146
1182
  /* If the types don't match, there's no way the values do */
1147
1183
  if (old_id && old_ref->type != GIT_REFERENCE_DIRECT) {
@@ -1219,7 +1255,7 @@ static int refdb_fs_backend__write(
1219
1255
  git_filebuf file = GIT_FILEBUF_INIT;
1220
1256
  int error = 0;
1221
1257
 
1222
- assert(backend);
1258
+ GIT_ASSERT_ARG(backend);
1223
1259
 
1224
1260
  if ((error = reference_path_available(backend, ref->name, NULL, force)) < 0)
1225
1261
  return error;
@@ -1292,7 +1328,7 @@ on_error:
1292
1328
  return error;
1293
1329
  }
1294
1330
 
1295
- static void refdb_fs_backend__prune_refs(
1331
+ static int refdb_fs_backend__prune_refs(
1296
1332
  refdb_fs_backend *backend,
1297
1333
  const char *ref_name,
1298
1334
  const char *prefix)
@@ -1300,10 +1336,12 @@ static void refdb_fs_backend__prune_refs(
1300
1336
  git_buf relative_path = GIT_BUF_INIT;
1301
1337
  git_buf base_path = GIT_BUF_INIT;
1302
1338
  size_t commonlen;
1339
+ int error;
1303
1340
 
1304
- assert(backend && ref_name);
1341
+ GIT_ASSERT_ARG(backend);
1342
+ GIT_ASSERT_ARG(ref_name);
1305
1343
 
1306
- if (git_buf_sets(&relative_path, ref_name) < 0)
1344
+ if ((error = git_buf_sets(&relative_path, ref_name)) < 0)
1307
1345
  goto cleanup;
1308
1346
 
1309
1347
  git_path_squash_slashes(&relative_path);
@@ -1313,20 +1351,33 @@ static void refdb_fs_backend__prune_refs(
1313
1351
 
1314
1352
  git_buf_truncate(&relative_path, commonlen);
1315
1353
 
1316
- if (prefix) {
1317
- if (git_buf_join3(&base_path, '/', backend->commonpath, prefix, git_buf_cstr(&relative_path)) < 0)
1318
- goto cleanup;
1319
- } else {
1320
- if (git_buf_joinpath(&base_path, backend->commonpath, git_buf_cstr(&relative_path)) < 0)
1321
- goto cleanup;
1322
- }
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));
1362
+
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);
1323
1372
 
1324
- git_futils_rmdir_r(ref_name + commonlen, git_buf_cstr(&base_path), GIT_RMDIR_EMPTY_PARENTS | GIT_RMDIR_SKIP_ROOT);
1373
+ if (error == GIT_ENOTFOUND)
1374
+ error = 0;
1325
1375
  }
1326
1376
 
1327
1377
  cleanup:
1328
1378
  git_buf_dispose(&relative_path);
1329
1379
  git_buf_dispose(&base_path);
1380
+ return error;
1330
1381
  }
1331
1382
 
1332
1383
  static int refdb_fs_backend__delete(
@@ -1338,7 +1389,8 @@ static int refdb_fs_backend__delete(
1338
1389
  git_filebuf file = GIT_FILEBUF_INIT;
1339
1390
  int error = 0;
1340
1391
 
1341
- assert(backend && ref_name);
1392
+ GIT_ASSERT_ARG(backend);
1393
+ GIT_ASSERT_ARG(ref_name);
1342
1394
 
1343
1395
  if ((error = loose_lock(&file, backend, ref_name)) < 0)
1344
1396
  return error;
@@ -1353,19 +1405,19 @@ static int refdb_fs_backend__delete(
1353
1405
 
1354
1406
  static int loose_delete(refdb_fs_backend *backend, const char *ref_name)
1355
1407
  {
1356
- git_buf loose_path = GIT_BUF_INIT;
1408
+ git_buf path = GIT_BUF_INIT;
1357
1409
  int error = 0;
1358
1410
 
1359
- if (git_buf_joinpath(&loose_path, backend->commonpath, ref_name) < 0)
1360
- return -1;
1411
+ if ((error = loose_path(&path, backend->commonpath, ref_name)) < 0)
1412
+ return error;
1361
1413
 
1362
- error = p_unlink(loose_path.ptr);
1414
+ error = p_unlink(path.ptr);
1363
1415
  if (error < 0 && errno == ENOENT)
1364
1416
  error = GIT_ENOTFOUND;
1365
1417
  else if (error != 0)
1366
1418
  error = -1;
1367
1419
 
1368
- git_buf_dispose(&loose_path);
1420
+ git_buf_dispose(&path);
1369
1421
 
1370
1422
  return error;
1371
1423
  }
@@ -1424,7 +1476,7 @@ static int refdb_fs_backend__delete_tail(
1424
1476
  cleanup:
1425
1477
  git_filebuf_cleanup(file);
1426
1478
  if (error == 0)
1427
- refdb_fs_backend__prune_refs(backend, ref_name, "");
1479
+ error = refdb_fs_backend__prune_refs(backend, ref_name, "");
1428
1480
  return error;
1429
1481
  }
1430
1482
 
@@ -1444,7 +1496,7 @@ static int refdb_fs_backend__rename(
1444
1496
  git_filebuf file = GIT_FILEBUF_INIT;
1445
1497
  int error;
1446
1498
 
1447
- assert(backend);
1499
+ GIT_ASSERT_ARG(backend);
1448
1500
 
1449
1501
  if ((error = reference_path_available(
1450
1502
  backend, new_name, old_name, force)) < 0 ||
@@ -1497,7 +1549,7 @@ static int refdb_fs_backend__compress(git_refdb_backend *_backend)
1497
1549
  int error;
1498
1550
  refdb_fs_backend *backend = GIT_CONTAINER_OF(_backend, refdb_fs_backend, parent);
1499
1551
 
1500
- assert(backend);
1552
+ GIT_ASSERT_ARG(backend);
1501
1553
 
1502
1554
  if ((error = packed_reload(backend)) < 0 || /* load the existing packfile */
1503
1555
  (error = packed_loadloose(backend)) < 0 || /* add all the loose refs */
@@ -1511,7 +1563,8 @@ static void refdb_fs_backend__free(git_refdb_backend *_backend)
1511
1563
  {
1512
1564
  refdb_fs_backend *backend = GIT_CONTAINER_OF(_backend, refdb_fs_backend, parent);
1513
1565
 
1514
- assert(backend);
1566
+ if (!backend)
1567
+ return;
1515
1568
 
1516
1569
  git_sortedcache_free(backend->refcache);
1517
1570
  git__free(backend->gitpath);
@@ -1556,8 +1609,9 @@ static char *setup_namespace(git_repository *repo, const char *in)
1556
1609
  GIT_MKDIR_PATH, NULL) < 0)
1557
1610
  goto done;
1558
1611
 
1559
- /* 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' */
1560
1613
  git_buf_rtruncate_at_char(&path, '/');
1614
+ git_buf_putc(&path, '/');
1561
1615
  out = git_buf_detach(&path);
1562
1616
 
1563
1617
  done:
@@ -1658,13 +1712,6 @@ static int create_new_reflog_file(const char *filepath)
1658
1712
  return p_close(fd);
1659
1713
  }
1660
1714
 
1661
- GIT_INLINE(int) retrieve_reflog_path(git_buf *path, git_repository *repo, const char *name)
1662
- {
1663
- if (strcmp(name, GIT_HEAD_FILE) == 0)
1664
- return git_buf_join3(path, '/', repo->gitdir, GIT_REFLOG_DIR, name);
1665
- return git_buf_join3(path, '/', repo->commondir, GIT_REFLOG_DIR, name);
1666
- }
1667
-
1668
1715
  static int refdb_reflog_fs__ensure_log(git_refdb_backend *_backend, const char *name)
1669
1716
  {
1670
1717
  refdb_fs_backend *backend;
@@ -1672,12 +1719,12 @@ static int refdb_reflog_fs__ensure_log(git_refdb_backend *_backend, const char *
1672
1719
  git_buf path = GIT_BUF_INIT;
1673
1720
  int error;
1674
1721
 
1675
- assert(_backend && name);
1722
+ GIT_ASSERT_ARG(_backend && name);
1676
1723
 
1677
1724
  backend = GIT_CONTAINER_OF(_backend, refdb_fs_backend, parent);
1678
1725
  repo = backend->repo;
1679
1726
 
1680
- if ((error = retrieve_reflog_path(&path, repo, name)) < 0)
1727
+ if ((error = reflog_path(&path, repo, name)) < 0)
1681
1728
  return error;
1682
1729
 
1683
1730
  error = create_new_reflog_file(git_buf_cstr(&path));
@@ -1691,7 +1738,7 @@ static int has_reflog(git_repository *repo, const char *name)
1691
1738
  int ret = 0;
1692
1739
  git_buf path = GIT_BUF_INIT;
1693
1740
 
1694
- if (retrieve_reflog_path(&path, repo, name) < 0)
1741
+ if (reflog_path(&path, repo, name) < 0)
1695
1742
  goto cleanup;
1696
1743
 
1697
1744
  ret = git_path_isfile(git_buf_cstr(&path));
@@ -1705,7 +1752,8 @@ static int refdb_reflog_fs__has_log(git_refdb_backend *_backend, const char *nam
1705
1752
  {
1706
1753
  refdb_fs_backend *backend;
1707
1754
 
1708
- assert(_backend && name);
1755
+ GIT_ASSERT_ARG(_backend);
1756
+ GIT_ASSERT_ARG(name);
1709
1757
 
1710
1758
  backend = GIT_CONTAINER_OF(_backend, refdb_fs_backend, parent);
1711
1759
 
@@ -1721,7 +1769,9 @@ static int refdb_reflog_fs__read(git_reflog **out, git_refdb_backend *_backend,
1721
1769
  git_repository *repo;
1722
1770
  refdb_fs_backend *backend;
1723
1771
 
1724
- assert(out && _backend && name);
1772
+ GIT_ASSERT_ARG(out);
1773
+ GIT_ASSERT_ARG(_backend);
1774
+ GIT_ASSERT_ARG(name);
1725
1775
 
1726
1776
  backend = GIT_CONTAINER_OF(_backend, refdb_fs_backend, parent);
1727
1777
  repo = backend->repo;
@@ -1729,7 +1779,7 @@ static int refdb_reflog_fs__read(git_reflog **out, git_refdb_backend *_backend,
1729
1779
  if (reflog_alloc(&log, name) < 0)
1730
1780
  return -1;
1731
1781
 
1732
- if (retrieve_reflog_path(&log_path, repo, name) < 0)
1782
+ if (reflog_path(&log_path, repo, name) < 0)
1733
1783
  goto cleanup;
1734
1784
 
1735
1785
  error = git_futils_readbuffer(&log_file, git_buf_cstr(&log_path));
@@ -1806,12 +1856,12 @@ static int lock_reflog(git_filebuf *file, refdb_fs_backend *backend, const char
1806
1856
 
1807
1857
  repo = backend->repo;
1808
1858
 
1809
- 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)) {
1810
1860
  git_error_set(GIT_ERROR_INVALID, "invalid reference name '%s'", refname);
1811
1861
  return GIT_EINVALIDSPEC;
1812
1862
  }
1813
1863
 
1814
- if (retrieve_reflog_path(&log_path, repo, refname) < 0)
1864
+ if (reflog_path(&log_path, repo, refname) < 0)
1815
1865
  return -1;
1816
1866
 
1817
1867
  if (!git_path_isfile(git_buf_cstr(&log_path))) {
@@ -1838,7 +1888,8 @@ static int refdb_reflog_fs__write(git_refdb_backend *_backend, git_reflog *reflo
1838
1888
  git_buf log = GIT_BUF_INIT;
1839
1889
  git_filebuf fbuf = GIT_FILEBUF_INIT;
1840
1890
 
1841
- assert(_backend && reflog);
1891
+ GIT_ASSERT_ARG(_backend);
1892
+ GIT_ASSERT_ARG(reflog);
1842
1893
 
1843
1894
  backend = GIT_CONTAINER_OF(_backend, refdb_fs_backend, parent);
1844
1895
 
@@ -1911,7 +1962,7 @@ static int reflog_append(refdb_fs_backend *backend, const git_reference *ref, co
1911
1962
  if ((error = serialize_reflog_entry(&buf, &old_id, &new_id, who, message)) < 0)
1912
1963
  goto cleanup;
1913
1964
 
1914
- if ((error = retrieve_reflog_path(&path, repo, ref->name)) < 0)
1965
+ if ((error = reflog_path(&path, repo, ref->name)) < 0)
1915
1966
  goto cleanup;
1916
1967
 
1917
1968
  if (((error = git_futils_mkpath2file(git_buf_cstr(&path), 0777)) < 0) &&
@@ -1960,7 +2011,9 @@ static int refdb_reflog_fs__rename(git_refdb_backend *_backend, const char *old_
1960
2011
  git_repository *repo;
1961
2012
  refdb_fs_backend *backend;
1962
2013
 
1963
- assert(_backend && old_name && new_name);
2014
+ GIT_ASSERT_ARG(_backend);
2015
+ GIT_ASSERT_ARG(old_name);
2016
+ GIT_ASSERT_ARG(new_name);
1964
2017
 
1965
2018
  backend = GIT_CONTAINER_OF(_backend, refdb_fs_backend, parent);
1966
2019
  repo = backend->repo;
@@ -1972,11 +2025,11 @@ static int refdb_reflog_fs__rename(git_refdb_backend *_backend, const char *old_
1972
2025
  if (git_buf_joinpath(&temp_path, repo->gitdir, GIT_REFLOG_DIR) < 0)
1973
2026
  return -1;
1974
2027
 
1975
- if (git_buf_joinpath(&old_path, git_buf_cstr(&temp_path), old_name) < 0)
1976
- return -1;
2028
+ if ((error = loose_path(&old_path, git_buf_cstr(&temp_path), old_name)) < 0)
2029
+ return error;
1977
2030
 
1978
- if (git_buf_joinpath(&new_path, git_buf_cstr(&temp_path), git_buf_cstr(&normalized)) < 0)
1979
- return -1;
2031
+ if ((error = loose_path(&new_path, git_buf_cstr(&temp_path), git_buf_cstr(&normalized))) < 0)
2032
+ return error;
1980
2033
 
1981
2034
  if (!git_path_exists(git_buf_cstr(&old_path))) {
1982
2035
  error = GIT_ENOTFOUND;
@@ -1990,8 +2043,8 @@ static int refdb_reflog_fs__rename(git_refdb_backend *_backend, const char *old_
1990
2043
  * - a/b -> a/b/c
1991
2044
  * - a/b/c/d -> a/b/c
1992
2045
  */
1993
- if (git_buf_joinpath(&temp_path, git_buf_cstr(&temp_path), "temp_reflog") < 0)
1994
- return -1;
2046
+ if ((error = loose_path(&temp_path, git_buf_cstr(&temp_path), "temp_reflog")) < 0)
2047
+ return error;
1995
2048
 
1996
2049
  if ((fd = git_futils_mktmp(&temp_path, git_buf_cstr(&temp_path), GIT_REFLOG_FILE_MODE)) < 0) {
1997
2050
  error = -1;
@@ -2037,9 +2090,10 @@ static int refdb_reflog_fs__delete(git_refdb_backend *_backend, const char *name
2037
2090
  git_buf path = GIT_BUF_INIT;
2038
2091
  int error;
2039
2092
 
2040
- assert(_backend && name);
2093
+ GIT_ASSERT_ARG(_backend);
2094
+ GIT_ASSERT_ARG(name);
2041
2095
 
2042
- if ((error = retrieve_reflog_path(&path, backend->repo, name)) < 0)
2096
+ if ((error = reflog_path(&path, backend->repo, name)) < 0)
2043
2097
  goto out;
2044
2098
 
2045
2099
  if (!git_path_exists(path.ptr))
@@ -2048,7 +2102,7 @@ static int refdb_reflog_fs__delete(git_refdb_backend *_backend, const char *name
2048
2102
  if ((error = p_unlink(path.ptr)) < 0)
2049
2103
  goto out;
2050
2104
 
2051
- refdb_fs_backend__prune_refs(backend, name, GIT_REFLOG_DIR);
2105
+ error = refdb_fs_backend__prune_refs(backend, name, GIT_REFLOG_DIR);
2052
2106
 
2053
2107
  out:
2054
2108
  git_buf_dispose(&path);
@@ -50,7 +50,9 @@ int git_reflog_read(git_reflog **reflog, git_repository *repo, const char *name
50
50
  git_refdb *refdb;
51
51
  int error;
52
52
 
53
- assert(reflog && repo && name);
53
+ GIT_ASSERT_ARG(reflog);
54
+ GIT_ASSERT_ARG(repo);
55
+ GIT_ASSERT_ARG(name);
54
56
 
55
57
  if ((error = git_repository_refdb__weakptr(&refdb, repo)) < 0)
56
58
  return error;
@@ -62,7 +64,8 @@ int git_reflog_write(git_reflog *reflog)
62
64
  {
63
65
  git_refdb *db;
64
66
 
65
- assert(reflog && reflog->db);
67
+ GIT_ASSERT_ARG(reflog);
68
+ GIT_ASSERT_ARG(reflog->db);
66
69
 
67
70
  db = reflog->db;
68
71
  return db->backend->reflog_write(db->backend, reflog);
@@ -73,7 +76,9 @@ int git_reflog_append(git_reflog *reflog, const git_oid *new_oid, const git_sign
73
76
  const git_reflog_entry *previous;
74
77
  git_reflog_entry *entry;
75
78
 
76
- assert(reflog && new_oid && committer);
79
+ GIT_ASSERT_ARG(reflog);
80
+ GIT_ASSERT_ARG(new_oid);
81
+ GIT_ASSERT_ARG(committer);
77
82
 
78
83
  entry = git__calloc(1, sizeof(git_reflog_entry));
79
84
  GIT_ERROR_CHECK_ALLOC(entry);
@@ -139,13 +144,13 @@ int git_reflog_delete(git_repository *repo, const char *name)
139
144
 
140
145
  size_t git_reflog_entrycount(git_reflog *reflog)
141
146
  {
142
- assert(reflog);
147
+ GIT_ASSERT_ARG_WITH_RETVAL(reflog, 0);
143
148
  return reflog->entries.length;
144
149
  }
145
150
 
146
- const git_reflog_entry * git_reflog_entry_byindex(const git_reflog *reflog, size_t idx)
151
+ const git_reflog_entry *git_reflog_entry_byindex(const git_reflog *reflog, size_t idx)
147
152
  {
148
- assert(reflog);
153
+ GIT_ASSERT_ARG_WITH_RETVAL(reflog, NULL);
149
154
 
150
155
  if (idx >= reflog->entries.length)
151
156
  return NULL;
@@ -154,27 +159,27 @@ const git_reflog_entry * git_reflog_entry_byindex(const git_reflog *reflog, size
154
159
  &reflog->entries, reflog_inverse_index(idx, reflog->entries.length));
155
160
  }
156
161
 
157
- const git_oid * git_reflog_entry_id_old(const git_reflog_entry *entry)
162
+ const git_oid *git_reflog_entry_id_old(const git_reflog_entry *entry)
158
163
  {
159
- assert(entry);
164
+ GIT_ASSERT_ARG_WITH_RETVAL(entry, NULL);
160
165
  return &entry->oid_old;
161
166
  }
162
167
 
163
- const git_oid * git_reflog_entry_id_new(const git_reflog_entry *entry)
168
+ const git_oid *git_reflog_entry_id_new(const git_reflog_entry *entry)
164
169
  {
165
- assert(entry);
170
+ GIT_ASSERT_ARG_WITH_RETVAL(entry, NULL);
166
171
  return &entry->oid_cur;
167
172
  }
168
173
 
169
- const git_signature * git_reflog_entry_committer(const git_reflog_entry *entry)
174
+ const git_signature *git_reflog_entry_committer(const git_reflog_entry *entry)
170
175
  {
171
- assert(entry);
176
+ GIT_ASSERT_ARG_WITH_RETVAL(entry, NULL);
172
177
  return entry->committer;
173
178
  }
174
179
 
175
- const char * git_reflog_entry_message(const git_reflog_entry *entry)
180
+ const char *git_reflog_entry_message(const git_reflog_entry *entry)
176
181
  {
177
- assert(entry);
182
+ GIT_ASSERT_ARG_WITH_RETVAL(entry, NULL);
178
183
  return entry->msg;
179
184
  }
180
185