rugged 0.24.6.1 → 0.25.0b1

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 (69) hide show
  1. checksums.yaml +4 -4
  2. data/ext/rugged/rugged_repo.c +44 -36
  3. data/lib/rugged/version.rb +1 -1
  4. data/vendor/libgit2/CMakeLists.txt +10 -21
  5. data/vendor/libgit2/include/git2/checkout.h +0 -7
  6. data/vendor/libgit2/include/git2/commit.h +46 -0
  7. data/vendor/libgit2/include/git2/common.h +1 -16
  8. data/vendor/libgit2/include/git2/odb.h +47 -1
  9. data/vendor/libgit2/include/git2/version.h +2 -2
  10. data/vendor/libgit2/src/array.h +0 -40
  11. data/vendor/libgit2/src/blame.c +3 -8
  12. data/vendor/libgit2/src/blame_git.c +9 -20
  13. data/vendor/libgit2/src/checkout.c +5 -13
  14. data/vendor/libgit2/src/commit.c +132 -52
  15. data/vendor/libgit2/src/common.h +1 -1
  16. data/vendor/libgit2/src/config_cache.c +1 -2
  17. data/vendor/libgit2/src/config_file.c +20 -14
  18. data/vendor/libgit2/src/delta-apply.c +5 -36
  19. data/vendor/libgit2/src/delta-apply.h +0 -12
  20. data/vendor/libgit2/src/describe.c +1 -2
  21. data/vendor/libgit2/src/diff_tform.c +3 -5
  22. data/vendor/libgit2/src/filebuf.c +1 -6
  23. data/vendor/libgit2/src/global.c +8 -28
  24. data/vendor/libgit2/src/global.h +0 -1
  25. data/vendor/libgit2/src/ignore.c +19 -56
  26. data/vendor/libgit2/src/index.c +8 -27
  27. data/vendor/libgit2/src/indexer.c +7 -11
  28. data/vendor/libgit2/src/iterator.c +2 -2
  29. data/vendor/libgit2/src/merge.c +0 -1
  30. data/vendor/libgit2/src/mwindow.c +19 -8
  31. data/vendor/libgit2/src/mwindow.h +2 -1
  32. data/vendor/libgit2/src/object.c +6 -3
  33. data/vendor/libgit2/src/odb.c +188 -48
  34. data/vendor/libgit2/src/odb_loose.c +1 -1
  35. data/vendor/libgit2/src/odb_pack.c +3 -0
  36. data/vendor/libgit2/src/openssl_stream.c +27 -60
  37. data/vendor/libgit2/src/openssl_stream.h +0 -106
  38. data/vendor/libgit2/src/pack-objects.c +2 -4
  39. data/vendor/libgit2/src/pack.c +9 -5
  40. data/vendor/libgit2/src/posix.c +0 -7
  41. data/vendor/libgit2/src/posix.h +0 -1
  42. data/vendor/libgit2/src/push.c +6 -6
  43. data/vendor/libgit2/src/refdb_fs.c +0 -1
  44. data/vendor/libgit2/src/refs.c +0 -3
  45. data/vendor/libgit2/src/refspec.c +2 -4
  46. data/vendor/libgit2/src/remote.c +5 -15
  47. data/vendor/libgit2/src/repository.c +21 -29
  48. data/vendor/libgit2/src/settings.c +1 -23
  49. data/vendor/libgit2/src/stransport_stream.c +9 -15
  50. data/vendor/libgit2/src/submodule.c +2 -3
  51. data/vendor/libgit2/src/sysdir.c +47 -41
  52. data/vendor/libgit2/src/sysdir.h +5 -0
  53. data/vendor/libgit2/src/tag.c +2 -8
  54. data/vendor/libgit2/src/thread-utils.h +51 -5
  55. data/vendor/libgit2/src/transports/http.c +3 -3
  56. data/vendor/libgit2/src/transports/smart_pkt.c +4 -13
  57. data/vendor/libgit2/src/transports/smart_protocol.c +17 -61
  58. data/vendor/libgit2/src/tree.c +100 -83
  59. data/vendor/libgit2/src/tree.h +5 -4
  60. data/vendor/libgit2/src/unix/map.c +0 -5
  61. data/vendor/libgit2/src/util.c +3 -3
  62. data/vendor/libgit2/src/win32/map.c +5 -24
  63. data/vendor/libgit2/src/win32/precompiled.h +1 -1
  64. data/vendor/libgit2/src/win32/{thread.c → pthread.c} +80 -50
  65. data/vendor/libgit2/src/win32/pthread.h +92 -0
  66. data/vendor/libgit2/src/xdiff/xprepare.c +1 -2
  67. metadata +7 -8
  68. data/vendor/libgit2/src/unix/pthread.h +0 -54
  69. data/vendor/libgit2/src/win32/thread.h +0 -62
@@ -1414,11 +1414,7 @@ static int update_tips_for_spec(
1414
1414
  /* In autotag mode, don't overwrite any locally-existing tags */
1415
1415
  error = git_reference_create(&ref, remote->repo, refname.ptr, &head->oid, !autotag,
1416
1416
  log_message);
1417
-
1418
- if (error == GIT_EEXISTS)
1419
- continue;
1420
-
1421
- if (error < 0)
1417
+ if (error < 0 && error != GIT_EEXISTS)
1422
1418
  goto on_error;
1423
1419
 
1424
1420
  git_reference_free(ref);
@@ -2228,21 +2224,15 @@ static int remove_branch_config_related_entries(
2228
2224
  if (git_buf_printf(&buf, "branch.%.*s.merge", (int)branch_len, branch) < 0)
2229
2225
  break;
2230
2226
 
2231
- if ((error = git_config_delete_entry(config, git_buf_cstr(&buf))) < 0) {
2232
- if (error != GIT_ENOTFOUND)
2233
- break;
2234
- giterr_clear();
2235
- }
2227
+ if ((error = git_config_delete_entry(config, git_buf_cstr(&buf))) < 0)
2228
+ break;
2236
2229
 
2237
2230
  git_buf_clear(&buf);
2238
2231
  if (git_buf_printf(&buf, "branch.%.*s.remote", (int)branch_len, branch) < 0)
2239
2232
  break;
2240
2233
 
2241
- if ((error = git_config_delete_entry(config, git_buf_cstr(&buf))) < 0) {
2242
- if (error != GIT_ENOTFOUND)
2243
- break;
2244
- giterr_clear();
2245
- }
2234
+ if ((error = git_config_delete_entry(config, git_buf_cstr(&buf))) < 0)
2235
+ break;
2246
2236
  }
2247
2237
 
2248
2238
  if (error == GIT_ITEROVER)
@@ -264,7 +264,7 @@ cleanup:
264
264
  * the stack could remove directories name limits, but at the cost of doing
265
265
  * repeated malloc/frees inside the loop below, so let's not do it now.
266
266
  */
267
- static size_t find_ceiling_dir_offset(
267
+ static int find_ceiling_dir_offset(
268
268
  const char *path,
269
269
  const char *ceiling_directories)
270
270
  {
@@ -278,7 +278,7 @@ static size_t find_ceiling_dir_offset(
278
278
  min_len = (size_t)(git_path_root(path) + 1);
279
279
 
280
280
  if (ceiling_directories == NULL || min_len == 0)
281
- return min_len;
281
+ return (int)min_len;
282
282
 
283
283
  for (sep = ceil = ceiling_directories; *sep; ceil = sep + 1) {
284
284
  for (sep = ceil; *sep && *sep != GIT_PATH_LIST_SEPARATOR; sep++);
@@ -305,7 +305,7 @@ static size_t find_ceiling_dir_offset(
305
305
  }
306
306
  }
307
307
 
308
- return (max_len <= min_len ? min_len : max_len);
308
+ return (int)(max_len <= min_len ? min_len : max_len);
309
309
  }
310
310
 
311
311
  /*
@@ -359,36 +359,21 @@ static int find_repo(
359
359
  git_buf path = GIT_BUF_INIT;
360
360
  struct stat st;
361
361
  dev_t initial_device = 0;
362
- int min_iterations;
363
- bool in_dot_git;
364
- size_t ceiling_offset = 0;
362
+ bool try_with_dot_git = ((flags & GIT_REPOSITORY_OPEN_BARE) != 0);
363
+ int ceiling_offset;
365
364
 
366
365
  git_buf_free(repo_path);
367
366
 
368
367
  if ((error = git_path_prettify(&path, start_path, NULL)) < 0)
369
368
  return error;
370
369
 
371
- /* in_dot_git toggles each loop:
372
- * /a/b/c/.git, /a/b/c, /a/b/.git, /a/b, /a/.git, /a
373
- * With GIT_REPOSITORY_OPEN_BARE, we assume we started with /a/b/c.git
374
- * and don't append .git the first time through.
375
- * min_iterations indicates the number of iterations left before going
376
- * further counts as a search. */
377
- if (flags & GIT_REPOSITORY_OPEN_BARE) {
378
- in_dot_git = true;
379
- min_iterations = 1;
380
- } else {
381
- in_dot_git = false;
382
- min_iterations = 2;
383
- }
370
+ ceiling_offset = find_ceiling_dir_offset(path.ptr, ceiling_dirs);
384
371
 
385
- while (!error && (min_iterations || !(path.ptr[ceiling_offset] == 0 ||
386
- (flags & GIT_REPOSITORY_OPEN_NO_SEARCH)))) {
387
- if (!in_dot_git)
388
- if ((error = git_buf_joinpath(&path, path.ptr, DOT_GIT)) < 0)
389
- break;
390
- in_dot_git = !in_dot_git;
372
+ if (!try_with_dot_git &&
373
+ (error = git_buf_joinpath(&path, path.ptr, DOT_GIT)) < 0)
374
+ return error;
391
375
 
376
+ while (!error && !git_buf_len(repo_path)) {
392
377
  if (p_stat(path.ptr, &st) == 0) {
393
378
  /* check that we have not crossed device boundaries */
394
379
  if (initial_device == 0)
@@ -429,10 +414,17 @@ static int find_repo(
429
414
  break;
430
415
  }
431
416
 
432
- /* Once we've checked the directory (and .git if applicable),
433
- * find the ceiling for a search. */
434
- if (min_iterations && (--min_iterations == 0))
435
- ceiling_offset = find_ceiling_dir_offset(path.ptr, ceiling_dirs);
417
+ if (try_with_dot_git) {
418
+ /* if we tried original dir with and without .git AND either hit
419
+ * directory ceiling or NO_SEARCH was requested, then be done.
420
+ */
421
+ if (path.ptr[ceiling_offset] == '\0' ||
422
+ (flags & GIT_REPOSITORY_OPEN_NO_SEARCH) != 0)
423
+ break;
424
+ /* otherwise look first for .git item */
425
+ error = git_buf_joinpath(&path, path.ptr, DOT_GIT);
426
+ }
427
+ try_with_dot_git = !try_with_dot_git;
436
428
  }
437
429
 
438
430
  if (!error && parent_path && !(flags & GIT_REPOSITORY_OPEN_BARE)) {
@@ -71,18 +71,12 @@ static int config_level_to_sysdir(int config_level)
71
71
  }
72
72
 
73
73
  extern char *git__user_agent;
74
- extern char *git__ssl_ciphers;
75
74
 
76
75
  const char *git_libgit2__user_agent()
77
76
  {
78
77
  return git__user_agent;
79
78
  }
80
79
 
81
- const char *git_libgit2__ssl_ciphers()
82
- {
83
- return git__ssl_ciphers;
84
- }
85
-
86
80
  int git_libgit2_opts(int key, ...)
87
81
  {
88
82
  int error = 0;
@@ -175,7 +169,7 @@ int git_libgit2_opts(int key, ...)
175
169
  }
176
170
  }
177
171
  #else
178
- giterr_set(GITERR_NET, "cannot set certificate locations: OpenSSL is not enabled");
172
+ giterr_set(GITERR_NET, "Cannot set certificate locations: OpenSSL is not enabled");
179
173
  error = -1;
180
174
  #endif
181
175
  break;
@@ -193,22 +187,6 @@ int git_libgit2_opts(int key, ...)
193
187
  git_object__strict_input_validation = (va_arg(ap, int) != 0);
194
188
  break;
195
189
 
196
- case GIT_OPT_SET_SSL_CIPHERS:
197
- #ifdef GIT_OPENSSL
198
- {
199
- git__free(git__ssl_ciphers);
200
- git__ssl_ciphers = git__strdup(va_arg(ap, const char *));
201
- if (!git__ssl_ciphers) {
202
- giterr_set_oom();
203
- error = -1;
204
- }
205
- }
206
- #else
207
- giterr_set(GITERR_NET, "cannot set custom ciphers: OpenSSL is not enabled");
208
- error = -1;
209
- #endif
210
- break;
211
-
212
190
  default:
213
191
  giterr_set(GITERR_INVALID, "invalid option key");
214
192
  error = -1;
@@ -16,7 +16,7 @@
16
16
  #include "socket_stream.h"
17
17
  #include "curl_stream.h"
18
18
 
19
- static int stransport_error(OSStatus ret)
19
+ int stransport_error(OSStatus ret)
20
20
  {
21
21
  CFStringRef message;
22
22
 
@@ -33,7 +33,6 @@ static int stransport_error(OSStatus ret)
33
33
  CFRelease(message);
34
34
  #else
35
35
  giterr_set(GITERR_NET, "SecureTransport error: OSStatus %d", (unsigned int)ret);
36
- GIT_UNUSED(message);
37
36
  #endif
38
37
 
39
38
  return -1;
@@ -47,7 +46,7 @@ typedef struct {
47
46
  git_cert_x509 cert_info;
48
47
  } stransport_stream;
49
48
 
50
- static int stransport_connect(git_stream *stream)
49
+ int stransport_connect(git_stream *stream)
51
50
  {
52
51
  stransport_stream *st = (stransport_stream *) stream;
53
52
  int error;
@@ -67,9 +66,6 @@ static int stransport_connect(git_stream *stream)
67
66
  if ((ret = SSLCopyPeerTrust(st->ctx, &trust)) != noErr)
68
67
  goto on_error;
69
68
 
70
- if (!trust)
71
- return GIT_ECERTIFICATE;
72
-
73
69
  if ((ret = SecTrustEvaluate(trust, &sec_res)) != noErr)
74
70
  goto on_error;
75
71
 
@@ -93,7 +89,7 @@ on_error:
93
89
  return stransport_error(ret);
94
90
  }
95
91
 
96
- static int stransport_certificate(git_cert **out, git_stream *stream)
92
+ int stransport_certificate(git_cert **out, git_stream *stream)
97
93
  {
98
94
  stransport_stream *st = (stransport_stream *) stream;
99
95
  SecTrustRef trust = NULL;
@@ -120,7 +116,7 @@ static int stransport_certificate(git_cert **out, git_stream *stream)
120
116
  return 0;
121
117
  }
122
118
 
123
- static int stransport_set_proxy(git_stream *stream, const char *proxy)
119
+ int stransport_set_proxy(git_stream *stream, const char *proxy)
124
120
  {
125
121
  stransport_stream *st = (stransport_stream *) stream;
126
122
 
@@ -150,7 +146,7 @@ static OSStatus write_cb(SSLConnectionRef conn, const void *data, size_t *len)
150
146
  return noErr;
151
147
  }
152
148
 
153
- static ssize_t stransport_write(git_stream *stream, const char *data, size_t len, int flags)
149
+ ssize_t stransport_write(git_stream *stream, const char *data, size_t len, int flags)
154
150
  {
155
151
  stransport_stream *st = (stransport_stream *) stream;
156
152
  size_t data_len, processed;
@@ -199,7 +195,7 @@ static OSStatus read_cb(SSLConnectionRef conn, void *data, size_t *len)
199
195
  return error;
200
196
  }
201
197
 
202
- static ssize_t stransport_read(git_stream *stream, void *data, size_t len)
198
+ ssize_t stransport_read(git_stream *stream, void *data, size_t len)
203
199
  {
204
200
  stransport_stream *st = (stransport_stream *) stream;
205
201
  size_t processed;
@@ -211,7 +207,7 @@ static ssize_t stransport_read(git_stream *stream, void *data, size_t len)
211
207
  return processed;
212
208
  }
213
209
 
214
- static int stransport_close(git_stream *stream)
210
+ int stransport_close(git_stream *stream)
215
211
  {
216
212
  stransport_stream *st = (stransport_stream *) stream;
217
213
  OSStatus ret;
@@ -223,7 +219,7 @@ static int stransport_close(git_stream *stream)
223
219
  return git_stream_close(st->io);
224
220
  }
225
221
 
226
- static void stransport_free(git_stream *stream)
222
+ void stransport_free(git_stream *stream)
227
223
  {
228
224
  stransport_stream *st = (stransport_stream *) stream;
229
225
 
@@ -259,7 +255,6 @@ int git_stransport_stream_new(git_stream **out, const char *host, const char *po
259
255
  st->ctx = SSLCreateContext(NULL, kSSLClientSide, kSSLStreamType);
260
256
  if (!st->ctx) {
261
257
  giterr_set(GITERR_NET, "failed to create SSL context");
262
- git__free(st);
263
258
  return -1;
264
259
  }
265
260
 
@@ -269,8 +264,7 @@ int git_stransport_stream_new(git_stream **out, const char *host, const char *po
269
264
  (ret = SSLSetProtocolVersionMin(st->ctx, kTLSProtocol1)) != noErr ||
270
265
  (ret = SSLSetProtocolVersionMax(st->ctx, kTLSProtocol12)) != noErr ||
271
266
  (ret = SSLSetPeerDomainName(st->ctx, host, strlen(host))) != noErr) {
272
- CFRelease(st->ctx);
273
- git__free(st);
267
+ git_stream_free((git_stream *)st);
274
268
  return stransport_error(ret);
275
269
  }
276
270
 
@@ -80,8 +80,7 @@ static kh_inline int str_equal_no_trailing_slash(const char *a, const char *b)
80
80
  if (blen > 0 && b[blen - 1] == '/')
81
81
  blen--;
82
82
 
83
- return (alen == 0 && blen == 0) ||
84
- (alen == blen && strncmp(a, b, alen) == 0);
83
+ return (alen == blen && strncmp(a, b, alen) == 0);
85
84
  }
86
85
 
87
86
  __KHASH_IMPL(
@@ -1417,7 +1416,7 @@ static int submodule_update_head(git_submodule *submodule)
1417
1416
  git_tree_entry_bypath(&te, head, submodule->path) < 0)
1418
1417
  giterr_clear();
1419
1418
  else
1420
- submodule_update_from_head_data(submodule, te->attr, git_tree_entry_id(te));
1419
+ submodule_update_from_head_data(submodule, te->attr, &te->oid);
1421
1420
 
1422
1421
  git_tree_entry_free(te);
1423
1422
  git_tree_free(head);
@@ -83,43 +83,45 @@ static int git_sysdir_guess_template_dirs(git_buf *out)
83
83
  #endif
84
84
  }
85
85
 
86
- struct git_sysdir__dir {
87
- git_buf buf;
88
- int (*guess)(git_buf *out);
89
- };
86
+ typedef int (*git_sysdir_guess_cb)(git_buf *out);
90
87
 
91
- static struct git_sysdir__dir git_sysdir__dirs[] = {
92
- { GIT_BUF_INIT, git_sysdir_guess_system_dirs },
93
- { GIT_BUF_INIT, git_sysdir_guess_global_dirs },
94
- { GIT_BUF_INIT, git_sysdir_guess_xdg_dirs },
95
- { GIT_BUF_INIT, git_sysdir_guess_programdata_dirs },
96
- { GIT_BUF_INIT, git_sysdir_guess_template_dirs },
97
- };
88
+ static git_buf git_sysdir__dirs[GIT_SYSDIR__MAX] =
89
+ { GIT_BUF_INIT, GIT_BUF_INIT, GIT_BUF_INIT, GIT_BUF_INIT, GIT_BUF_INIT };
98
90
 
99
- static void git_sysdir_global_shutdown(void)
100
- {
101
- size_t i;
91
+ static git_sysdir_guess_cb git_sysdir__dir_guess[GIT_SYSDIR__MAX] = {
92
+ git_sysdir_guess_system_dirs,
93
+ git_sysdir_guess_global_dirs,
94
+ git_sysdir_guess_xdg_dirs,
95
+ git_sysdir_guess_programdata_dirs,
96
+ git_sysdir_guess_template_dirs,
97
+ };
102
98
 
103
- for (i = 0; i < ARRAY_SIZE(git_sysdir__dirs); ++i)
104
- git_buf_free(&git_sysdir__dirs[i].buf);
105
- }
99
+ static int git_sysdir__dirs_shutdown_set = 0;
106
100
 
107
101
  int git_sysdir_global_init(void)
108
102
  {
109
- size_t i;
103
+ git_sysdir_t i;
104
+ const git_buf *path;
110
105
  int error = 0;
111
106
 
112
- for (i = 0; !error && i < ARRAY_SIZE(git_sysdir__dirs); i++)
113
- error = git_sysdir__dirs[i].guess(&git_sysdir__dirs[i].buf);
114
-
115
- git__on_shutdown(git_sysdir_global_shutdown);
107
+ for (i = 0; !error && i < GIT_SYSDIR__MAX; i++)
108
+ error = git_sysdir_get(&path, i);
116
109
 
117
110
  return error;
118
111
  }
119
112
 
113
+ void git_sysdir_global_shutdown(void)
114
+ {
115
+ int i;
116
+ for (i = 0; i < GIT_SYSDIR__MAX; ++i)
117
+ git_buf_free(&git_sysdir__dirs[i]);
118
+
119
+ git_sysdir__dirs_shutdown_set = 0;
120
+ }
121
+
120
122
  static int git_sysdir_check_selector(git_sysdir_t which)
121
123
  {
122
- if (which < ARRAY_SIZE(git_sysdir__dirs))
124
+ if (which < GIT_SYSDIR__MAX)
123
125
  return 0;
124
126
 
125
127
  giterr_set(GITERR_INVALID, "config directory selector out of range");
@@ -135,7 +137,18 @@ int git_sysdir_get(const git_buf **out, git_sysdir_t which)
135
137
 
136
138
  GITERR_CHECK_ERROR(git_sysdir_check_selector(which));
137
139
 
138
- *out = &git_sysdir__dirs[which].buf;
140
+ if (!git_buf_len(&git_sysdir__dirs[which])) {
141
+ /* prepare shutdown if we're going to need it */
142
+ if (!git_sysdir__dirs_shutdown_set) {
143
+ git__on_shutdown(git_sysdir_global_shutdown);
144
+ git_sysdir__dirs_shutdown_set = 1;
145
+ }
146
+
147
+ GITERR_CHECK_ERROR(
148
+ git_sysdir__dir_guess[which](&git_sysdir__dirs[which]));
149
+ }
150
+
151
+ *out = &git_sysdir__dirs[which];
139
152
  return 0;
140
153
  }
141
154
 
@@ -170,38 +183,31 @@ int git_sysdir_set(git_sysdir_t which, const char *search_path)
170
183
  if (search_path != NULL)
171
184
  expand_path = strstr(search_path, PATH_MAGIC);
172
185
 
173
- /* reset the default if this path has been cleared */
174
- if (!search_path || expand_path)
175
- git_sysdir__dirs[which].guess(&git_sysdir__dirs[which].buf);
186
+ /* init with default if not yet done and needed (ignoring error) */
187
+ if ((!search_path || expand_path) &&
188
+ !git_buf_len(&git_sysdir__dirs[which]))
189
+ git_sysdir__dir_guess[which](&git_sysdir__dirs[which]);
176
190
 
177
191
  /* if $PATH is not referenced, then just set the path */
178
- if (!expand_path) {
179
- if (search_path)
180
- git_buf_sets(&git_sysdir__dirs[which].buf, search_path);
181
-
182
- goto done;
183
- }
192
+ if (!expand_path)
193
+ return git_buf_sets(&git_sysdir__dirs[which], search_path);
184
194
 
185
195
  /* otherwise set to join(before $PATH, old value, after $PATH) */
186
196
  if (expand_path > search_path)
187
197
  git_buf_set(&merge, search_path, expand_path - search_path);
188
198
 
189
- if (git_buf_len(&git_sysdir__dirs[which].buf))
199
+ if (git_buf_len(&git_sysdir__dirs[which]))
190
200
  git_buf_join(&merge, GIT_PATH_LIST_SEPARATOR,
191
- merge.ptr, git_sysdir__dirs[which].buf.ptr);
201
+ merge.ptr, git_sysdir__dirs[which].ptr);
192
202
 
193
203
  expand_path += strlen(PATH_MAGIC);
194
204
  if (*expand_path)
195
205
  git_buf_join(&merge, GIT_PATH_LIST_SEPARATOR, merge.ptr, expand_path);
196
206
 
197
- git_buf_swap(&git_sysdir__dirs[which].buf, &merge);
207
+ git_buf_swap(&git_sysdir__dirs[which], &merge);
198
208
  git_buf_free(&merge);
199
209
 
200
- done:
201
- if (git_buf_oom(&git_sysdir__dirs[which].buf))
202
- return -1;
203
-
204
- return 0;
210
+ return git_buf_oom(&git_sysdir__dirs[which]) ? -1 : 0;
205
211
  }
206
212
 
207
213
  static int git_sysdir_find_in_dirlist(
@@ -103,4 +103,9 @@ extern int git_sysdir_get_str(char *out, size_t outlen, git_sysdir_t which);
103
103
  */
104
104
  extern int git_sysdir_set(git_sysdir_t which, const char *paths);
105
105
 
106
+ /**
107
+ * Free the configuration file search paths.
108
+ */
109
+ extern void git_sysdir_global_shutdown(void);
110
+
106
111
  #endif /* INCLUDE_sysdir_h__ */