rugged 1.0.1 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (146) hide show
  1. checksums.yaml +4 -4
  2. data/ext/rugged/rugged_commit.c +1 -1
  3. data/lib/rugged/commit.rb +16 -2
  4. data/lib/rugged/version.rb +1 -1
  5. data/vendor/libgit2/CMakeLists.txt +31 -69
  6. data/vendor/libgit2/cmake/{Modules/AddCFlagIfSupported.cmake → AddCFlagIfSupported.cmake} +0 -0
  7. data/vendor/libgit2/cmake/{Modules/EnableWarnings.cmake → EnableWarnings.cmake} +0 -0
  8. data/vendor/libgit2/cmake/{Modules/FindCoreFoundation.cmake → FindCoreFoundation.cmake} +0 -0
  9. data/vendor/libgit2/cmake/{Modules/FindGSSAPI.cmake → FindGSSAPI.cmake} +0 -0
  10. data/vendor/libgit2/cmake/{Modules/FindGSSFramework.cmake → FindGSSFramework.cmake} +0 -0
  11. data/vendor/libgit2/cmake/{Modules/FindHTTP_Parser.cmake → FindHTTP_Parser.cmake} +0 -0
  12. data/vendor/libgit2/cmake/{Modules/FindIconv.cmake → FindIconv.cmake} +0 -0
  13. data/vendor/libgit2/cmake/{Modules/FindPCRE.cmake → FindPCRE.cmake} +0 -0
  14. data/vendor/libgit2/cmake/{Modules/FindPCRE2.cmake → FindPCRE2.cmake} +0 -0
  15. data/vendor/libgit2/cmake/{Modules/FindPkgLibraries.cmake → FindPkgLibraries.cmake} +0 -0
  16. data/vendor/libgit2/cmake/{Modules/FindSecurity.cmake → FindSecurity.cmake} +0 -0
  17. data/vendor/libgit2/cmake/{Modules/FindStatNsec.cmake → FindStatNsec.cmake} +0 -0
  18. data/vendor/libgit2/cmake/{Modules/FindmbedTLS.cmake → FindmbedTLS.cmake} +0 -0
  19. data/vendor/libgit2/cmake/{Modules/IdeSplitSources.cmake → IdeSplitSources.cmake} +0 -0
  20. data/vendor/libgit2/cmake/{Modules/PkgBuildConfig.cmake → PkgBuildConfig.cmake} +0 -0
  21. data/vendor/libgit2/cmake/{Modules/SanitizeBool.cmake → SanitizeBool.cmake} +0 -0
  22. data/vendor/libgit2/cmake/{Modules/SelectGSSAPI.cmake → SelectGSSAPI.cmake} +18 -26
  23. data/vendor/libgit2/cmake/{Modules/SelectHTTPSBackend.cmake → SelectHTTPSBackend.cmake} +25 -32
  24. data/vendor/libgit2/cmake/{Modules/SelectHashes.cmake → SelectHashes.cmake} +20 -28
  25. data/vendor/libgit2/deps/http-parser/CMakeLists.txt +4 -3
  26. data/vendor/libgit2/deps/ntlmclient/CMakeLists.txt +6 -5
  27. data/vendor/libgit2/deps/ntlmclient/compat.h +8 -1
  28. data/vendor/libgit2/deps/ntlmclient/ntlm.c +8 -11
  29. data/vendor/libgit2/deps/pcre/LICENCE +93 -0
  30. data/vendor/libgit2/deps/pcre/pcre.h +2 -2
  31. data/vendor/libgit2/deps/pcre/pcre_compile.c +29 -17
  32. data/vendor/libgit2/deps/pcre/pcre_jit_compile.c +4 -4
  33. data/vendor/libgit2/deps/pcre/pcreposix.c +2 -3
  34. data/vendor/libgit2/deps/zlib/CMakeLists.txt +6 -5
  35. data/vendor/libgit2/deps/zlib/deflate.c +1 -0
  36. data/vendor/libgit2/include/git2/annotated_commit.h +1 -1
  37. data/vendor/libgit2/include/git2/blame.h +2 -0
  38. data/vendor/libgit2/include/git2/common.h +15 -3
  39. data/vendor/libgit2/include/git2/deprecated.h +42 -2
  40. data/vendor/libgit2/include/git2/errors.h +2 -1
  41. data/vendor/libgit2/include/git2/index.h +1 -2
  42. data/vendor/libgit2/include/git2/pack.h +1 -1
  43. data/vendor/libgit2/include/git2/strarray.h +6 -10
  44. data/vendor/libgit2/include/git2/version.h +4 -4
  45. data/vendor/libgit2/src/CMakeLists.txt +53 -41
  46. data/vendor/libgit2/src/apply.c +5 -1
  47. data/vendor/libgit2/src/assert_safe.h +58 -0
  48. data/vendor/libgit2/src/attr_file.c +8 -3
  49. data/vendor/libgit2/src/attrcache.c +2 -3
  50. data/vendor/libgit2/src/blame.c +2 -0
  51. data/vendor/libgit2/src/blame_git.c +6 -3
  52. data/vendor/libgit2/src/blob.c +2 -0
  53. data/vendor/libgit2/src/branch.c +19 -21
  54. data/vendor/libgit2/src/buffer.c +6 -3
  55. data/vendor/libgit2/src/cache.c +1 -22
  56. data/vendor/libgit2/src/checkout.c +49 -72
  57. data/vendor/libgit2/src/cherrypick.c +2 -0
  58. data/vendor/libgit2/src/clone.c +78 -18
  59. data/vendor/libgit2/src/common.h +1 -0
  60. data/vendor/libgit2/src/config.c +3 -7
  61. data/vendor/libgit2/src/config_entries.c +35 -27
  62. data/vendor/libgit2/src/config_parse.c +1 -1
  63. data/vendor/libgit2/src/config_snapshot.c +2 -1
  64. data/vendor/libgit2/src/describe.c +5 -1
  65. data/vendor/libgit2/src/diff.c +12 -11
  66. data/vendor/libgit2/src/diff_file.c +3 -1
  67. data/vendor/libgit2/src/diff_generate.c +10 -11
  68. data/vendor/libgit2/src/diff_parse.c +2 -3
  69. data/vendor/libgit2/src/diff_print.c +63 -60
  70. data/vendor/libgit2/src/diff_stats.c +12 -11
  71. data/vendor/libgit2/src/diff_tform.c +2 -3
  72. data/vendor/libgit2/src/errors.c +2 -0
  73. data/vendor/libgit2/src/fetch.c +2 -0
  74. data/vendor/libgit2/src/filter.c +3 -3
  75. data/vendor/libgit2/src/futils.c +3 -3
  76. data/vendor/libgit2/src/futils.h +3 -3
  77. data/vendor/libgit2/src/global.c +3 -1
  78. data/vendor/libgit2/src/idxmap.c +0 -22
  79. data/vendor/libgit2/src/index.c +12 -7
  80. data/vendor/libgit2/src/indexer.c +10 -4
  81. data/vendor/libgit2/src/iterator.c +4 -4
  82. data/vendor/libgit2/src/merge.c +13 -7
  83. data/vendor/libgit2/src/merge_file.c +4 -6
  84. data/vendor/libgit2/src/midx.c +418 -0
  85. data/vendor/libgit2/src/midx.h +83 -0
  86. data/vendor/libgit2/src/mwindow.c +124 -51
  87. data/vendor/libgit2/src/net.c +6 -1
  88. data/vendor/libgit2/src/object.c +2 -1
  89. data/vendor/libgit2/src/odb.c +9 -6
  90. data/vendor/libgit2/src/odb_loose.c +3 -3
  91. data/vendor/libgit2/src/odb_mempack.c +2 -0
  92. data/vendor/libgit2/src/oid.c +2 -0
  93. data/vendor/libgit2/src/pack-objects.c +29 -21
  94. data/vendor/libgit2/src/pack.c +47 -28
  95. data/vendor/libgit2/src/pack.h +19 -2
  96. data/vendor/libgit2/src/patch_generate.c +1 -3
  97. data/vendor/libgit2/src/patch_parse.c +4 -2
  98. data/vendor/libgit2/src/path.c +4 -4
  99. data/vendor/libgit2/src/pathspec.c +4 -3
  100. data/vendor/libgit2/src/pool.c +21 -15
  101. data/vendor/libgit2/src/pool.h +9 -1
  102. data/vendor/libgit2/src/proxy.c +2 -0
  103. data/vendor/libgit2/src/push.c +2 -0
  104. data/vendor/libgit2/src/rebase.c +2 -0
  105. data/vendor/libgit2/src/refdb.c +135 -0
  106. data/vendor/libgit2/src/refdb.h +69 -0
  107. data/vendor/libgit2/src/refdb_fs.c +19 -81
  108. data/vendor/libgit2/src/reflog.c +2 -6
  109. data/vendor/libgit2/src/refs.c +60 -188
  110. data/vendor/libgit2/src/refs.h +1 -19
  111. data/vendor/libgit2/src/regexp.c +2 -2
  112. data/vendor/libgit2/src/remote.c +32 -17
  113. data/vendor/libgit2/src/repository.c +168 -79
  114. data/vendor/libgit2/src/repository.h +10 -27
  115. data/vendor/libgit2/src/revert.c +2 -0
  116. data/vendor/libgit2/src/revparse.c +5 -4
  117. data/vendor/libgit2/src/revwalk.c +3 -5
  118. data/vendor/libgit2/src/settings.c +9 -0
  119. data/vendor/libgit2/src/sortedcache.c +2 -3
  120. data/vendor/libgit2/src/stash.c +2 -0
  121. data/vendor/libgit2/src/status.c +2 -0
  122. data/vendor/libgit2/src/strarray.c +63 -0
  123. data/vendor/libgit2/src/streams/openssl.c +12 -6
  124. data/vendor/libgit2/src/streams/registry.c +5 -3
  125. data/vendor/libgit2/src/submodule.c +6 -4
  126. data/vendor/libgit2/src/sysdir.c +4 -20
  127. data/vendor/libgit2/src/sysdir.h +0 -11
  128. data/vendor/libgit2/src/tag.c +2 -0
  129. data/vendor/libgit2/src/thread-utils.h +139 -21
  130. data/vendor/libgit2/src/transaction.c +2 -1
  131. data/vendor/libgit2/src/transports/credential.c +2 -0
  132. data/vendor/libgit2/src/transports/credential_helpers.c +2 -0
  133. data/vendor/libgit2/src/transports/httpclient.c +6 -8
  134. data/vendor/libgit2/src/transports/local.c +2 -2
  135. data/vendor/libgit2/src/transports/smart.c +2 -2
  136. data/vendor/libgit2/src/transports/winhttp.c +18 -7
  137. data/vendor/libgit2/src/unix/posix.h +13 -1
  138. data/vendor/libgit2/src/util.c +25 -58
  139. data/vendor/libgit2/src/util.h +2 -2
  140. data/vendor/libgit2/src/win32/git2.rc +18 -3
  141. data/vendor/libgit2/src/win32/path_w32.c +2 -2
  142. data/vendor/libgit2/src/worktree.c +4 -0
  143. metadata +27 -25
  144. data/vendor/libgit2/cmake/Modules/CheckPrototypeDefinition.c.in +0 -29
  145. data/vendor/libgit2/cmake/Modules/CheckPrototypeDefinition.cmake +0 -96
  146. data/vendor/libgit2/src/refdb_fs.h +0 -19
@@ -231,7 +231,9 @@ int git_revert_options_init(git_revert_options *opts, unsigned int version)
231
231
  return 0;
232
232
  }
233
233
 
234
+ #ifndef GIT_DEPRECATE_HARD
234
235
  int git_revert_init_options(git_revert_options *opts, unsigned int version)
235
236
  {
236
237
  return git_revert_options_init(opts, version);
237
238
  }
239
+ #endif
@@ -537,7 +537,8 @@ static int extract_curly_braces_content(git_buf *buf, const char *spec, size_t *
537
537
  if (spec[*pos] == '\0')
538
538
  return GIT_EINVALIDSPEC;
539
539
 
540
- git_buf_putc(buf, spec[(*pos)++]);
540
+ if (git_buf_putc(buf, spec[(*pos)++]) < 0)
541
+ return -1;
541
542
  }
542
543
 
543
544
  (*pos)++;
@@ -585,7 +586,7 @@ static int extract_how_many(int *n, const char *spec, size_t *pos)
585
586
  *pos = end_ptr - spec;
586
587
  }
587
588
 
588
- } while (spec[(*pos)] == kind && kind == '~');
589
+ } while (spec[(*pos)] == kind && kind == '~');
589
590
 
590
591
  *n = accumulated;
591
592
 
@@ -659,7 +660,7 @@ static int ensure_left_hand_identifier_is_not_known_yet(git_object *object, git_
659
660
  return GIT_EINVALIDSPEC;
660
661
  }
661
662
 
662
- int revparse__ext(
663
+ static int revparse(
663
664
  git_object **object_out,
664
665
  git_reference **reference_out,
665
666
  size_t *identifier_len_out,
@@ -835,7 +836,7 @@ int git_revparse_ext(
835
836
  git_object *obj = NULL;
836
837
  git_reference *ref = NULL;
837
838
 
838
- if ((error = revparse__ext(&obj, &ref, &identifier_len, repo, spec)) < 0)
839
+ if ((error = revparse(&obj, &ref, &identifier_len, repo, spec)) < 0)
839
840
  goto cleanup;
840
841
 
841
842
  *object_out = obj;
@@ -659,13 +659,11 @@ int git_revwalk_new(git_revwalk **revwalk_out, git_repository *repo)
659
659
  git_revwalk *walk = git__calloc(1, sizeof(git_revwalk));
660
660
  GIT_ERROR_CHECK_ALLOC(walk);
661
661
 
662
- if (git_oidmap_new(&walk->commits) < 0)
662
+ if (git_oidmap_new(&walk->commits) < 0 ||
663
+ git_pqueue_init(&walk->iterator_time, 0, 8, git_commit_list_time_cmp) < 0 ||
664
+ git_pool_init(&walk->commit_pool, COMMIT_ALLOC) < 0)
663
665
  return -1;
664
666
 
665
- if (git_pqueue_init(&walk->iterator_time, 0, 8, git_commit_list_time_cmp) < 0)
666
- return -1;
667
-
668
- git_pool_init(&walk->commit_pool, COMMIT_ALLOC);
669
667
  walk->get_next = &revwalk_next_unsorted;
670
668
  walk->enqueue = &revwalk_enqueue_unsorted;
671
669
 
@@ -59,6 +59,7 @@ int git_libgit2_features(void)
59
59
  /* Declarations for tuneable settings */
60
60
  extern size_t git_mwindow__window_size;
61
61
  extern size_t git_mwindow__mapped_limit;
62
+ extern size_t git_mwindow__file_limit;
62
63
  extern size_t git_indexer__max_objects;
63
64
  extern bool git_disable_pack_keep_file_checks;
64
65
 
@@ -124,6 +125,14 @@ int git_libgit2_opts(int key, ...)
124
125
  *(va_arg(ap, size_t *)) = git_mwindow__mapped_limit;
125
126
  break;
126
127
 
128
+ case GIT_OPT_SET_MWINDOW_FILE_LIMIT:
129
+ git_mwindow__file_limit = va_arg(ap, size_t);
130
+ break;
131
+
132
+ case GIT_OPT_GET_MWINDOW_FILE_LIMIT:
133
+ *(va_arg(ap, size_t *)) = git_mwindow__file_limit;
134
+ break;
135
+
127
136
  case GIT_OPT_GET_SEARCH_PATH:
128
137
  if ((error = config_level_to_sysdir(va_arg(ap, int))) >= 0) {
129
138
  git_buf *out = va_arg(ap, git_buf *);
@@ -25,9 +25,8 @@ int git_sortedcache_new(
25
25
  sc = git__calloc(1, alloclen);
26
26
  GIT_ERROR_CHECK_ALLOC(sc);
27
27
 
28
- git_pool_init(&sc->pool, 1);
29
-
30
- if (git_vector_init(&sc->items, 4, item_cmp) < 0 ||
28
+ if (git_pool_init(&sc->pool, 1) < 0 ||
29
+ git_vector_init(&sc->items, 4, item_cmp) < 0 ||
31
30
  git_strmap_new(&sc->map) < 0)
32
31
  goto fail;
33
32
 
@@ -776,10 +776,12 @@ int git_stash_apply_options_init(git_stash_apply_options *opts, unsigned int ver
776
776
  return 0;
777
777
  }
778
778
 
779
+ #ifndef GIT_DEPRECATE_HARD
779
780
  int git_stash_apply_init_options(git_stash_apply_options *opts, unsigned int version)
780
781
  {
781
782
  return git_stash_apply_options_init(opts, version);
782
783
  }
784
+ #endif
783
785
 
784
786
  #define NOTIFY_PROGRESS(opts, progress_type) \
785
787
  do { \
@@ -548,10 +548,12 @@ int git_status_options_init(git_status_options *opts, unsigned int version)
548
548
  return 0;
549
549
  }
550
550
 
551
+ #ifndef GIT_DEPRECATE_HARD
551
552
  int git_status_init_options(git_status_options *opts, unsigned int version)
552
553
  {
553
554
  return git_status_options_init(opts, version);
554
555
  }
556
+ #endif
555
557
 
556
558
  int git_status_list_get_perfdata(
557
559
  git_diff_perfdata *out, const git_status_list *status)
@@ -0,0 +1,63 @@
1
+ /*
2
+ * Copyright (C) the libgit2 contributors. All rights reserved.
3
+ *
4
+ * This file is part of libgit2, distributed under the GNU GPL v2 with
5
+ * a Linking Exception. For full terms see the included COPYING file.
6
+ */
7
+
8
+ #include "util.h"
9
+
10
+ #include "common.h"
11
+
12
+ int git_strarray_copy(git_strarray *tgt, const git_strarray *src)
13
+ {
14
+ size_t i;
15
+
16
+ assert(tgt && src);
17
+
18
+ memset(tgt, 0, sizeof(*tgt));
19
+
20
+ if (!src->count)
21
+ return 0;
22
+
23
+ tgt->strings = git__calloc(src->count, sizeof(char *));
24
+ GIT_ERROR_CHECK_ALLOC(tgt->strings);
25
+
26
+ for (i = 0; i < src->count; ++i) {
27
+ if (!src->strings[i])
28
+ continue;
29
+
30
+ tgt->strings[tgt->count] = git__strdup(src->strings[i]);
31
+ if (!tgt->strings[tgt->count]) {
32
+ git_strarray_dispose(tgt);
33
+ memset(tgt, 0, sizeof(*tgt));
34
+ return -1;
35
+ }
36
+
37
+ tgt->count++;
38
+ }
39
+
40
+ return 0;
41
+ }
42
+
43
+ void git_strarray_dispose(git_strarray *array)
44
+ {
45
+ size_t i;
46
+
47
+ if (array == NULL)
48
+ return;
49
+
50
+ for (i = 0; i < array->count; ++i)
51
+ git__free(array->strings[i]);
52
+
53
+ git__free(array->strings);
54
+
55
+ memset(array, 0, sizeof(*array));
56
+ }
57
+
58
+ #ifndef GIT_DEPRECATE_HARD
59
+ void git_strarray_free(git_strarray *array)
60
+ {
61
+ git_strarray_dispose(array);
62
+ }
63
+ #endif
@@ -655,15 +655,16 @@ static int openssl_connect(git_stream *stream)
655
655
  static int openssl_certificate(git_cert **out, git_stream *stream)
656
656
  {
657
657
  openssl_stream *st = (openssl_stream *) stream;
658
- int len;
659
658
  X509 *cert = SSL_get_peer_certificate(st->ssl);
660
- unsigned char *guard, *encoded_cert;
659
+ unsigned char *guard, *encoded_cert = NULL;
660
+ int error, len;
661
661
 
662
662
  /* Retrieve the length of the certificate first */
663
663
  len = i2d_X509(cert, NULL);
664
664
  if (len < 0) {
665
665
  git_error_set(GIT_ERROR_NET, "failed to retrieve certificate information");
666
- return -1;
666
+ error = -1;
667
+ goto out;
667
668
  }
668
669
 
669
670
  encoded_cert = git__malloc(len);
@@ -673,18 +674,23 @@ static int openssl_certificate(git_cert **out, git_stream *stream)
673
674
 
674
675
  len = i2d_X509(cert, &guard);
675
676
  if (len < 0) {
676
- git__free(encoded_cert);
677
677
  git_error_set(GIT_ERROR_NET, "failed to retrieve certificate information");
678
- return -1;
678
+ error = -1;
679
+ goto out;
679
680
  }
680
681
 
681
682
  st->cert_info.parent.cert_type = GIT_CERT_X509;
682
683
  st->cert_info.data = encoded_cert;
683
684
  st->cert_info.len = len;
685
+ encoded_cert = NULL;
684
686
 
685
687
  *out = &st->cert_info.parent;
688
+ error = 0;
686
689
 
687
- return 0;
690
+ out:
691
+ git__free(encoded_cert);
692
+ X509_free(cert);
693
+ return error;
688
694
  }
689
695
 
690
696
  static int openssl_set_proxy(git_stream *stream, const git_proxy_options *proxy_opts)
@@ -5,9 +5,10 @@
5
5
  * a Linking Exception. For full terms see the included COPYING file.
6
6
  */
7
7
 
8
- #include "git2/errors.h"
9
-
10
8
  #include "common.h"
9
+
10
+ #include "streams/registry.h"
11
+
11
12
  #include "global.h"
12
13
  #include "streams/tls.h"
13
14
  #include "streams/mbedtls.h"
@@ -100,7 +101,7 @@ int git_stream_register(git_stream_t type, git_stream_registration *registration
100
101
  return 0;
101
102
  }
102
103
 
103
-
104
+ #ifndef GIT_DEPRECATE_HARD
104
105
  int git_stream_register_tls(
105
106
  int GIT_CALLBACK(ctor)(git_stream **out, const char *host, const char *port))
106
107
  {
@@ -116,3 +117,4 @@ int git_stream_register_tls(
116
117
  return git_stream_register(GIT_STREAM_TLS, NULL);
117
118
  }
118
119
  }
120
+ #endif
@@ -958,7 +958,7 @@ cleanup:
958
958
  return error;
959
959
  }
960
960
 
961
- const char *git_submodule_update_to_str(git_submodule_update_t update)
961
+ static const char *submodule_update_to_str(git_submodule_update_t update)
962
962
  {
963
963
  int i;
964
964
  for (i = 0; i < (int)ARRAY_SIZE(_sm_update_map); ++i)
@@ -1240,10 +1240,12 @@ int git_submodule_update_options_init(git_submodule_update_options *opts, unsign
1240
1240
  return 0;
1241
1241
  }
1242
1242
 
1243
+ #ifndef GIT_DEPRECATE_HARD
1243
1244
  int git_submodule_update_init_options(git_submodule_update_options *opts, unsigned int version)
1244
1245
  {
1245
1246
  return git_submodule_update_options_init(opts, version);
1246
1247
  }
1248
+ #endif
1247
1249
 
1248
1250
  int git_submodule_update(git_submodule *sm, int init, git_submodule_update_options *_update_options)
1249
1251
  {
@@ -1401,7 +1403,7 @@ int git_submodule_init(git_submodule *sm, int overwrite)
1401
1403
  /* write "submodule.NAME.update" if not default */
1402
1404
 
1403
1405
  val = (sm->update == GIT_SUBMODULE_UPDATE_CHECKOUT) ?
1404
- NULL : git_submodule_update_to_str(sm->update);
1406
+ NULL : submodule_update_to_str(sm->update);
1405
1407
 
1406
1408
  if ((error = git_buf_printf(&key, "submodule.%s.update", sm->name)) < 0 ||
1407
1409
  (error = git_config__update_entry(
@@ -1838,7 +1840,7 @@ int git_submodule_parse_update(git_submodule_update_t *out, const char *value)
1838
1840
  return 0;
1839
1841
  }
1840
1842
 
1841
- int git_submodule_parse_recurse(git_submodule_recurse_t *out, const char *value)
1843
+ static int submodule_parse_recurse(git_submodule_recurse_t *out, const char *value)
1842
1844
  {
1843
1845
  int val;
1844
1846
 
@@ -1934,7 +1936,7 @@ static int submodule_read_config(git_submodule *sm, git_config *cfg)
1934
1936
 
1935
1937
  if ((error = get_value(&value, cfg, &key, sm->name, "fetchRecurseSubmodules")) == 0) {
1936
1938
  in_config = 1;
1937
- if ((error = git_submodule_parse_recurse(&sm->fetch_recurse, value)) < 0)
1939
+ if ((error = submodule_parse_recurse(&sm->fetch_recurse, value)) < 0)
1938
1940
  goto cleanup;
1939
1941
  sm->fetch_recurse_default = sm->fetch_recurse;
1940
1942
  } else if (error != GIT_ENOTFOUND) {
@@ -216,25 +216,6 @@ int git_sysdir_get(const git_buf **out, git_sysdir_t which)
216
216
  return 0;
217
217
  }
218
218
 
219
- int git_sysdir_get_str(
220
- char *out,
221
- size_t outlen,
222
- git_sysdir_t which)
223
- {
224
- const git_buf *path = NULL;
225
-
226
- GIT_ERROR_CHECK_ERROR(git_sysdir_check_selector(which));
227
- GIT_ERROR_CHECK_ERROR(git_sysdir_get(&path, which));
228
-
229
- if (!out || path->size >= outlen) {
230
- git_error_set(GIT_ERROR_NOMEMORY, "buffer is too short for the path");
231
- return GIT_EBUFS;
232
- }
233
-
234
- git_buf_copy_cstr(out, outlen, path);
235
- return 0;
236
- }
237
-
238
219
  #define PATH_MAGIC "$PATH"
239
220
 
240
221
  int git_sysdir_set(git_sysdir_t which, const char *search_path)
@@ -317,8 +298,11 @@ static int git_sysdir_find_in_dirlist(
317
298
  }
318
299
 
319
300
  done:
301
+ if (name)
302
+ git_error_set(GIT_ERROR_OS, "the %s file '%s' doesn't exist", label, name);
303
+ else
304
+ git_error_set(GIT_ERROR_OS, "the %s directory doesn't exist", label);
320
305
  git_buf_dispose(path);
321
- git_error_set(GIT_ERROR_OS, "the %s file '%s' doesn't exist", label, name);
322
306
  return GIT_ENOTFOUND;
323
307
  }
324
308
 
@@ -93,17 +93,6 @@ extern int git_sysdir_global_init(void);
93
93
  */
94
94
  extern int git_sysdir_get(const git_buf **out, git_sysdir_t which);
95
95
 
96
- /**
97
- * Get search path into a preallocated buffer
98
- *
99
- * @param out String buffer to write into
100
- * @param outlen Size of string buffer
101
- * @param which Which search path to return
102
- * @return 0 on success, GIT_EBUFS if out is too small, <0 on other failure
103
- */
104
-
105
- extern int git_sysdir_get_str(char *out, size_t outlen, git_sysdir_t which);
106
-
107
96
  /**
108
97
  * Set search paths for global/system/xdg files
109
98
  *
@@ -524,7 +524,9 @@ int git_tag_peel(git_object **tag_target, const git_tag *tag)
524
524
 
525
525
  /* Deprecated Functions */
526
526
 
527
+ #ifndef GIT_DEPRECATE_HARD
527
528
  int git_tag_create_frombuffer(git_oid *oid, git_repository *repo, const char *buffer, int allow_ref_overwrite)
528
529
  {
529
530
  return git_tag_create_from_buffer(oid, repo, buffer, allow_ref_overwrite);
530
531
  }
532
+ #endif
@@ -7,12 +7,30 @@
7
7
  #ifndef INCLUDE_thread_utils_h__
8
8
  #define INCLUDE_thread_utils_h__
9
9
 
10
- #if defined(__GNUC__) && defined(GIT_THREADS)
10
+ #if defined(GIT_THREADS)
11
+
12
+ #if defined(__clang__)
13
+
14
+ # if (__clang_major__ < 3 || (__clang_major__ == 3 && __clang_minor__ < 1))
15
+ # error Atomic primitives do not exist on this version of clang; configure libgit2 with -DTHREADSAFE=OFF
16
+ # else
17
+ # define GIT_BUILTIN_ATOMIC
18
+ # endif
19
+
20
+ #elif defined(__GNUC__)
21
+
11
22
  # if (__GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 1))
12
23
  # error Atomic primitives do not exist on this version of gcc; configure libgit2 with -DTHREADSAFE=OFF
24
+ # elif (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 7))
25
+ # define GIT_BUILTIN_ATOMIC
26
+ # else
27
+ # define GIT_BUILTIN_SYNC
13
28
  # endif
29
+
14
30
  #endif
15
31
 
32
+ #endif /* GIT_THREADS */
33
+
16
34
  /* Common operations even if threading has been disabled */
17
35
  typedef struct {
18
36
  #if defined(GIT_WIN32)
@@ -26,21 +44,25 @@ typedef struct {
26
44
 
27
45
  typedef struct {
28
46
  #if defined(GIT_WIN32)
29
- __int64 val;
47
+ volatile __int64 val;
30
48
  #else
31
- int64_t val;
49
+ volatile int64_t val;
32
50
  #endif
33
51
  } git_atomic64;
34
52
 
35
53
  typedef git_atomic64 git_atomic_ssize;
36
54
 
55
+ #define git_atomic_ssize_set git_atomic64_set
37
56
  #define git_atomic_ssize_add git_atomic64_add
57
+ #define git_atomic_ssize_get git_atomic64_get
38
58
 
39
59
  #else
40
60
 
41
61
  typedef git_atomic git_atomic_ssize;
42
62
 
63
+ #define git_atomic_ssize_set git_atomic_set
43
64
  #define git_atomic_ssize_add git_atomic_add
65
+ #define git_atomic_ssize_get git_atomic_get
44
66
 
45
67
  #endif
46
68
 
@@ -56,7 +78,9 @@ GIT_INLINE(void) git_atomic_set(git_atomic *a, int val)
56
78
  {
57
79
  #if defined(GIT_WIN32)
58
80
  InterlockedExchange(&a->val, (LONG)val);
59
- #elif defined(__GNUC__)
81
+ #elif defined(GIT_BUILTIN_ATOMIC)
82
+ __atomic_store_n(&a->val, val, __ATOMIC_SEQ_CST);
83
+ #elif defined(GIT_BUILTIN_SYNC)
60
84
  __sync_lock_test_and_set(&a->val, val);
61
85
  #else
62
86
  # error "Unsupported architecture for atomic operations"
@@ -67,7 +91,9 @@ GIT_INLINE(int) git_atomic_inc(git_atomic *a)
67
91
  {
68
92
  #if defined(GIT_WIN32)
69
93
  return InterlockedIncrement(&a->val);
70
- #elif defined(__GNUC__)
94
+ #elif defined(GIT_BUILTIN_ATOMIC)
95
+ return __atomic_add_fetch(&a->val, 1, __ATOMIC_SEQ_CST);
96
+ #elif defined(GIT_BUILTIN_SYNC)
71
97
  return __sync_add_and_fetch(&a->val, 1);
72
98
  #else
73
99
  # error "Unsupported architecture for atomic operations"
@@ -78,7 +104,9 @@ GIT_INLINE(int) git_atomic_add(git_atomic *a, int32_t addend)
78
104
  {
79
105
  #if defined(GIT_WIN32)
80
106
  return InterlockedExchangeAdd(&a->val, addend);
81
- #elif defined(__GNUC__)
107
+ #elif defined(GIT_BUILTIN_ATOMIC)
108
+ return __atomic_add_fetch(&a->val, addend, __ATOMIC_SEQ_CST);
109
+ #elif defined(GIT_BUILTIN_SYNC)
82
110
  return __sync_add_and_fetch(&a->val, addend);
83
111
  #else
84
112
  # error "Unsupported architecture for atomic operations"
@@ -89,25 +117,45 @@ GIT_INLINE(int) git_atomic_dec(git_atomic *a)
89
117
  {
90
118
  #if defined(GIT_WIN32)
91
119
  return InterlockedDecrement(&a->val);
92
- #elif defined(__GNUC__)
120
+ #elif defined(GIT_BUILTIN_ATOMIC)
121
+ return __atomic_sub_fetch(&a->val, 1, __ATOMIC_SEQ_CST);
122
+ #elif defined(GIT_BUILTIN_SYNC)
93
123
  return __sync_sub_and_fetch(&a->val, 1);
94
124
  #else
95
125
  # error "Unsupported architecture for atomic operations"
96
126
  #endif
97
127
  }
98
128
 
129
+ GIT_INLINE(int) git_atomic_get(git_atomic *a)
130
+ {
131
+ #if defined(GIT_WIN32)
132
+ return (int)InterlockedCompareExchange(&a->val, 0, 0);
133
+ #elif defined(GIT_BUILTIN_ATOMIC)
134
+ return __atomic_load_n(&a->val, __ATOMIC_SEQ_CST);
135
+ #elif defined(GIT_BUILTIN_SYNC)
136
+ return __sync_val_compare_and_swap(&a->val, 0, 0);
137
+ #else
138
+ # error "Unsupported architecture for atomic operations"
139
+ #endif
140
+ }
141
+
99
142
  GIT_INLINE(void *) git___compare_and_swap(
100
143
  void * volatile *ptr, void *oldval, void *newval)
101
144
  {
102
- volatile void *foundval;
103
145
  #if defined(GIT_WIN32)
146
+ volatile void *foundval;
104
147
  foundval = InterlockedCompareExchangePointer((volatile PVOID *)ptr, newval, oldval);
105
- #elif defined(__GNUC__)
148
+ return (foundval == oldval) ? oldval : newval;
149
+ #elif defined(GIT_BUILTIN_ATOMIC)
150
+ bool success = __atomic_compare_exchange(ptr, &oldval, &newval, false, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST);
151
+ return success ? oldval : newval;
152
+ #elif defined(GIT_BUILTIN_SYNC)
153
+ volatile void *foundval;
106
154
  foundval = __sync_val_compare_and_swap(ptr, oldval, newval);
155
+ return (foundval == oldval) ? oldval : newval;
107
156
  #else
108
157
  # error "Unsupported architecture for atomic operations"
109
158
  #endif
110
- return (foundval == oldval) ? oldval : newval;
111
159
  }
112
160
 
113
161
  GIT_INLINE(volatile void *) git___swap(
@@ -115,8 +163,30 @@ GIT_INLINE(volatile void *) git___swap(
115
163
  {
116
164
  #if defined(GIT_WIN32)
117
165
  return InterlockedExchangePointer(ptr, newval);
118
- #else
166
+ #elif defined(GIT_BUILTIN_ATOMIC)
167
+ void * volatile foundval;
168
+ __atomic_exchange(ptr, &newval, &foundval, __ATOMIC_SEQ_CST);
169
+ return foundval;
170
+ #elif defined(GIT_BUILTIN_SYNC)
119
171
  return __sync_lock_test_and_set(ptr, newval);
172
+ #else
173
+ # error "Unsupported architecture for atomic operations"
174
+ #endif
175
+ }
176
+
177
+ GIT_INLINE(volatile void *) git___load(void * volatile *ptr)
178
+ {
179
+ #if defined(GIT_WIN32)
180
+ void *newval = NULL, *oldval = NULL;
181
+ volatile void *foundval = NULL;
182
+ foundval = InterlockedCompareExchangePointer((volatile PVOID *)ptr, newval, oldval);
183
+ return foundval;
184
+ #elif defined(GIT_BUILTIN_ATOMIC)
185
+ return (volatile void *)__atomic_load_n(ptr, __ATOMIC_SEQ_CST);
186
+ #elif defined(GIT_BUILTIN_SYNC)
187
+ return (volatile void *)__sync_val_compare_and_swap(ptr, 0, 0);
188
+ #else
189
+ # error "Unsupported architecture for atomic operations"
120
190
  #endif
121
191
  }
122
192
 
@@ -126,13 +196,41 @@ GIT_INLINE(int64_t) git_atomic64_add(git_atomic64 *a, int64_t addend)
126
196
  {
127
197
  #if defined(GIT_WIN32)
128
198
  return InterlockedExchangeAdd64(&a->val, addend);
129
- #elif defined(__GNUC__)
199
+ #elif defined(GIT_BUILTIN_ATOMIC)
200
+ return __atomic_add_fetch(&a->val, addend, __ATOMIC_SEQ_CST);
201
+ #elif defined(GIT_BUILTIN_SYNC)
130
202
  return __sync_add_and_fetch(&a->val, addend);
131
203
  #else
132
204
  # error "Unsupported architecture for atomic operations"
133
205
  #endif
134
206
  }
135
207
 
208
+ GIT_INLINE(void) git_atomic64_set(git_atomic64 *a, int64_t val)
209
+ {
210
+ #if defined(GIT_WIN32)
211
+ InterlockedExchange64(&a->val, val);
212
+ #elif defined(GIT_BUILTIN_ATOMIC)
213
+ __atomic_store_n(&a->val, val, __ATOMIC_SEQ_CST);
214
+ #elif defined(GIT_BUILTIN_SYNC)
215
+ __sync_lock_test_and_set(&a->val, val);
216
+ #else
217
+ # error "Unsupported architecture for atomic operations"
218
+ #endif
219
+ }
220
+
221
+ GIT_INLINE(int64_t) git_atomic64_get(git_atomic64 *a)
222
+ {
223
+ #if defined(GIT_WIN32)
224
+ return (int64_t)InterlockedCompareExchange64(&a->val, 0, 0);
225
+ #elif defined(GIT_BUILTIN_ATOMIC)
226
+ return __atomic_load_n(&a->val, __ATOMIC_SEQ_CST);
227
+ #elif defined(GIT_BUILTIN_SYNC)
228
+ return __sync_val_compare_and_swap(&a->val, 0, 0);
229
+ #else
230
+ # error "Unsupported architecture for atomic operations"
231
+ #endif
232
+ }
233
+
136
234
  #endif
137
235
 
138
236
  #else
@@ -190,6 +288,11 @@ GIT_INLINE(int) git_atomic_dec(git_atomic *a)
190
288
  return --a->val;
191
289
  }
192
290
 
291
+ GIT_INLINE(int) git_atomic_get(git_atomic *a)
292
+ {
293
+ return (int)a->val;
294
+ }
295
+
193
296
  GIT_INLINE(void *) git___compare_and_swap(
194
297
  void * volatile *ptr, void *oldval, void *newval)
195
298
  {
@@ -216,15 +319,20 @@ GIT_INLINE(int64_t) git_atomic64_add(git_atomic64 *a, int64_t addend)
216
319
  return a->val;
217
320
  }
218
321
 
219
- #endif
220
-
221
- #endif
322
+ GIT_INLINE(void) git_atomic64_set(git_atomic64 *a, int64_t val)
323
+ {
324
+ a->val = val;
325
+ }
222
326
 
223
- GIT_INLINE(int) git_atomic_get(git_atomic *a)
327
+ GIT_INLINE(int64_t) git_atomic64_get(git_atomic64 *a)
224
328
  {
225
- return (int)a->val;
329
+ return (int64_t)a->val;
226
330
  }
227
331
 
332
+ #endif
333
+
334
+ #endif
335
+
228
336
  /* Atomically replace oldval with newval
229
337
  * @return oldval if it was replaced or newval if it was not
230
338
  */
@@ -233,14 +341,24 @@ GIT_INLINE(int) git_atomic_get(git_atomic *a)
233
341
 
234
342
  #define git__swap(ptr, val) (void *)git___swap((void * volatile *)&ptr, val)
235
343
 
344
+ #define git__load(ptr) (void *)git___load((void * volatile *)&ptr)
345
+
236
346
  extern int git_online_cpus(void);
237
347
 
238
- #if defined(GIT_THREADS) && defined(_MSC_VER)
239
- # define GIT_MEMORY_BARRIER MemoryBarrier()
240
- #elif defined(GIT_THREADS)
241
- # define GIT_MEMORY_BARRIER __sync_synchronize()
348
+ #if defined(GIT_THREADS)
349
+
350
+ # if defined(GIT_WIN32)
351
+ # define GIT_MEMORY_BARRIER MemoryBarrier()
352
+ # elif defined(GIT_BUILTIN_ATOMIC)
353
+ # define GIT_MEMORY_BARRIER __atomic_thread_fence(__ATOMIC_SEQ_CST)
354
+ # elif defined(GIT_BUILTIN_SYNC)
355
+ # define GIT_MEMORY_BARRIER __sync_synchronize()
356
+ # endif
357
+
242
358
  #else
359
+
243
360
  # define GIT_MEMORY_BARRIER /* noop */
361
+
244
362
  #endif
245
363
 
246
364
  #endif