rugged 0.23.2 → 0.23.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (58) hide show
  1. checksums.yaml +4 -4
  2. data/lib/rugged/version.rb +1 -1
  3. data/vendor/libgit2/CMakeLists.txt +12 -3
  4. data/vendor/libgit2/COPYING +46 -0
  5. data/vendor/libgit2/include/git2/config.h +4 -2
  6. data/vendor/libgit2/include/git2/cred_helpers.h +1 -1
  7. data/vendor/libgit2/include/git2/diff.h +0 -19
  8. data/vendor/libgit2/include/git2/errors.h +12 -0
  9. data/vendor/libgit2/include/git2/sys/filter.h +1 -4
  10. data/vendor/libgit2/include/git2/sys/refdb_backend.h +2 -3
  11. data/vendor/libgit2/include/git2/transport.h +21 -14
  12. data/vendor/libgit2/include/git2/version.h +2 -2
  13. data/vendor/libgit2/src/blame.c +1 -1
  14. data/vendor/libgit2/src/blame_git.c +27 -7
  15. data/vendor/libgit2/src/blame_git.h +1 -1
  16. data/vendor/libgit2/src/branch.c +12 -1
  17. data/vendor/libgit2/src/checkout.c +2 -1
  18. data/vendor/libgit2/src/clone.c +2 -2
  19. data/vendor/libgit2/src/common.h +13 -13
  20. data/vendor/libgit2/src/curl_stream.c +8 -7
  21. data/vendor/libgit2/src/diff.c +0 -25
  22. data/vendor/libgit2/src/diff_driver.c +6 -7
  23. data/vendor/libgit2/src/diff_patch.c +4 -0
  24. data/vendor/libgit2/src/diff_xdiff.c +7 -0
  25. data/vendor/libgit2/src/diff_xdiff.h +5 -0
  26. data/vendor/libgit2/src/errors.c +40 -75
  27. data/vendor/libgit2/src/filter.c +2 -5
  28. data/vendor/libgit2/src/global.c +9 -25
  29. data/vendor/libgit2/src/global.h +0 -1
  30. data/vendor/libgit2/src/index.c +3 -3
  31. data/vendor/libgit2/src/iterator.c +2 -2
  32. data/vendor/libgit2/src/merge.c +0 -56
  33. data/vendor/libgit2/src/merge_file.c +76 -22
  34. data/vendor/libgit2/src/openssl_stream.c +2 -3
  35. data/vendor/libgit2/src/path.c +0 -16
  36. data/vendor/libgit2/src/path.h +0 -5
  37. data/vendor/libgit2/src/refdb_fs.c +0 -7
  38. data/vendor/libgit2/src/remote.c +9 -18
  39. data/vendor/libgit2/src/stransport_stream.c +1 -1
  40. data/vendor/libgit2/src/submodule.c +7 -3
  41. data/vendor/libgit2/src/sysdir.c +8 -22
  42. data/vendor/libgit2/src/transports/http.c +9 -1
  43. data/vendor/libgit2/src/transports/smart_protocol.c +1 -1
  44. data/vendor/libgit2/src/transports/ssh.c +2 -2
  45. data/vendor/libgit2/src/transports/winhttp.c +1 -1
  46. data/vendor/libgit2/src/util.c +0 -48
  47. data/vendor/libgit2/src/util.h +5 -13
  48. data/vendor/libgit2/src/win32/posix_w32.c +0 -2
  49. data/vendor/libgit2/src/xdiff/xdiff.h +5 -3
  50. data/vendor/libgit2/src/xdiff/xdiffi.c +8 -4
  51. data/vendor/libgit2/src/xdiff/xhistogram.c +4 -2
  52. data/vendor/libgit2/src/xdiff/xmerge.c +98 -44
  53. metadata +76 -81
  54. data/vendor/libgit2/src/merge_file.h +0 -14
  55. data/vendor/libgit2/src/win32/w32_crtdbg_stacktrace.c +0 -343
  56. data/vendor/libgit2/src/win32/w32_crtdbg_stacktrace.h +0 -93
  57. data/vendor/libgit2/src/win32/w32_stack.c +0 -192
  58. data/vendor/libgit2/src/win32/w32_stack.h +0 -138
@@ -46,10 +46,6 @@
46
46
  # ifdef GIT_THREADS
47
47
  # include "win32/pthread.h"
48
48
  # endif
49
- # if defined(GIT_MSVC_CRTDBG)
50
- # include "win32/w32_stack.h"
51
- # include "win32/w32_crtdbg_stacktrace.h"
52
- # endif
53
49
 
54
50
  #else
55
51
 
@@ -141,25 +137,20 @@ void giterr_system_set(int code);
141
137
  * Structure to preserve libgit2 error state
142
138
  */
143
139
  typedef struct {
144
- int error_code;
145
- unsigned int oom : 1;
140
+ int error_code;
146
141
  git_error error_msg;
147
142
  } git_error_state;
148
143
 
149
144
  /**
150
145
  * Capture current error state to restore later, returning error code.
151
- * If `error_code` is zero, this does not clear the current error state.
152
- * You must either restore this error state, or free it.
146
+ * If `error_code` is zero, this does nothing and returns zero.
153
147
  */
154
- extern int giterr_state_capture(git_error_state *state, int error_code);
148
+ int giterr_capture(git_error_state *state, int error_code);
155
149
 
156
150
  /**
157
151
  * Restore error state to a previous value, returning saved error code.
158
152
  */
159
- extern int giterr_state_restore(git_error_state *state);
160
-
161
- /** Free an error state. */
162
- extern void giterr_state_free(git_error_state *state);
153
+ int giterr_restore(git_error_state *state);
163
154
 
164
155
  /**
165
156
  * Check a versioned structure for validity
@@ -208,6 +199,15 @@ GIT_INLINE(void) git__init_structure(void *structure, size_t len, unsigned int v
208
199
  #define GITERR_CHECK_ALLOC_ADD(out, one, two) \
209
200
  if (GIT_ADD_SIZET_OVERFLOW(out, one, two)) { return -1; }
210
201
 
202
+ #define GITERR_CHECK_ALLOC_ADD3(out, one, two, three) \
203
+ if (GIT_ADD_SIZET_OVERFLOW(out, one, two) || \
204
+ GIT_ADD_SIZET_OVERFLOW(out, *(out), three)) { return -1; }
205
+
206
+ #define GITERR_CHECK_ALLOC_ADD4(out, one, two, three, four) \
207
+ if (GIT_ADD_SIZET_OVERFLOW(out, one, two) || \
208
+ GIT_ADD_SIZET_OVERFLOW(out, *(out), three) || \
209
+ GIT_ADD_SIZET_OVERFLOW(out, *(out), four)) { return -1; }
210
+
211
211
  /** Check for multiplicative overflow, failing if it would occur. */
212
212
  #define GITERR_CHECK_ALLOC_MULTIPLY(out, nelem, elsize) \
213
213
  if (GIT_MULTIPLY_SIZET_OVERFLOW(out, nelem, elsize)) { return -1; }
@@ -67,9 +67,9 @@ static int curls_certificate(git_cert **out, git_stream *stream)
67
67
 
68
68
  /* No information is available, can happen with SecureTransport */
69
69
  if (certinfo->num_of_certs == 0) {
70
- s->cert_info.parent.cert_type = GIT_CERT_NONE;
71
- s->cert_info.data = NULL;
72
- s->cert_info.len = 0;
70
+ s->cert_info.cert_type = GIT_CERT_NONE;
71
+ s->cert_info.data = NULL;
72
+ s->cert_info.len = 0;
73
73
  return 0;
74
74
  }
75
75
 
@@ -85,11 +85,11 @@ static int curls_certificate(git_cert **out, git_stream *stream)
85
85
  s->cert_info_strings.strings = (char **) strings.contents;
86
86
  s->cert_info_strings.count = strings.length;
87
87
 
88
- s->cert_info.parent.cert_type = GIT_CERT_STRARRAY;
89
- s->cert_info.data = &s->cert_info_strings;
90
- s->cert_info.len = strings.length;
88
+ s->cert_info.cert_type = GIT_CERT_STRARRAY;
89
+ s->cert_info.data = &s->cert_info_strings;
90
+ s->cert_info.len = strings.length;
91
91
 
92
- *out = &s->cert_info.parent;
92
+ *out = (git_cert *) &s->cert_info;
93
93
 
94
94
  return 0;
95
95
  }
@@ -220,6 +220,7 @@ int git_curl_stream_new(git_stream **out, const char *host, const char *port)
220
220
  curl_easy_setopt(handle, CURLOPT_SSL_VERIFYPEER, 1);
221
221
  curl_easy_setopt(handle, CURLOPT_CERTINFO, 1);
222
222
  curl_easy_setopt(handle, CURLOPT_HTTPPROXYTUNNEL, 1);
223
+ curl_easy_setopt(handle, CURLOPT_PROXYAUTH, CURLAUTH_ANY);
223
224
 
224
225
  /* curl_easy_setopt(handle, CURLOPT_VERBOSE, 1); */
225
226
 
@@ -1421,31 +1421,6 @@ int git_diff_tree_to_workdir_with_index(
1421
1421
  return error;
1422
1422
  }
1423
1423
 
1424
- int git_diff_index_to_index(
1425
- git_diff **diff,
1426
- git_repository *repo,
1427
- git_index *old_index,
1428
- git_index *new_index,
1429
- const git_diff_options *opts)
1430
- {
1431
- int error = 0;
1432
-
1433
- assert(diff && old_index && new_index);
1434
-
1435
- DIFF_FROM_ITERATORS(
1436
- git_iterator_for_index(
1437
- &a, old_index, GIT_ITERATOR_DONT_IGNORE_CASE, pfx, pfx),
1438
- git_iterator_for_index(
1439
- &b, new_index, GIT_ITERATOR_DONT_IGNORE_CASE, pfx, pfx)
1440
- );
1441
-
1442
- /* if index is in case-insensitive order, re-sort deltas to match */
1443
- if (!error && (old_index->ignore_case || new_index->ignore_case))
1444
- diff_set_ignore_case(*diff, true);
1445
-
1446
- return error;
1447
- }
1448
-
1449
1424
  size_t git_diff_num_deltas(const git_diff *diff)
1450
1425
  {
1451
1426
  assert(diff);
@@ -97,8 +97,7 @@ static int diff_driver_add_patterns(
97
97
  for (scan = regex_str; scan; scan = end) {
98
98
  /* get pattern to fill in */
99
99
  if ((pat = git_array_alloc(drv->fn_patterns)) == NULL) {
100
- error = -1;
101
- break;
100
+ return -1;
102
101
  }
103
102
 
104
103
  pat->flags = regex_flags;
@@ -117,10 +116,9 @@ static int diff_driver_add_patterns(
117
116
  break;
118
117
 
119
118
  if ((error = regcomp(&pat->re, buf.ptr, regex_flags)) != 0) {
120
- /* if regex fails to compile, warn? fail? */
121
- error = giterr_set_regex(&pat->re, error);
122
- regfree(&pat->re);
123
- break;
119
+ /*
120
+ * TODO: issue a warning
121
+ */
124
122
  }
125
123
  }
126
124
 
@@ -128,7 +126,8 @@ static int diff_driver_add_patterns(
128
126
  (void)git_array_pop(drv->fn_patterns); /* release last item */
129
127
  git_buf_free(&buf);
130
128
 
131
- return error;
129
+ /* We want to ignore bad patterns, so return success regardless */
130
+ return 0;
132
131
  }
133
132
 
134
133
  static int diff_driver_xfuncname(const git_config_entry *entry, void *payload)
@@ -30,6 +30,10 @@ static void diff_patch_update_binary(git_patch *patch)
30
30
  (patch->nfile.file->flags & GIT_DIFF_FLAG_BINARY) != 0)
31
31
  patch->delta->flags |= GIT_DIFF_FLAG_BINARY;
32
32
 
33
+ else if (patch->ofile.file->size > GIT_XDIFF_MAX_SIZE ||
34
+ patch->nfile.file->size > GIT_XDIFF_MAX_SIZE)
35
+ patch->delta->flags |= GIT_DIFF_FLAG_BINARY;
36
+
33
37
  else if ((patch->ofile.file->flags & DIFF_FLAGS_NOT_BINARY) != 0 &&
34
38
  (patch->nfile.file->flags & DIFF_FLAGS_NOT_BINARY) != 0)
35
39
  patch->delta->flags |= GIT_DIFF_FLAG_NOT_BINARY;
@@ -4,6 +4,7 @@
4
4
  * This file is part of libgit2, distributed under the GNU GPL v2 with
5
5
  * a Linking Exception. For full terms see the included COPYING file.
6
6
  */
7
+ #include "git2/errors.h"
7
8
  #include "common.h"
8
9
  #include "diff.h"
9
10
  #include "diff_driver.h"
@@ -208,6 +209,12 @@ static int git_xdiff(git_diff_output *output, git_patch *patch)
208
209
  git_patch__old_data(&info.xd_old_data.ptr, &info.xd_old_data.size, patch);
209
210
  git_patch__new_data(&info.xd_new_data.ptr, &info.xd_new_data.size, patch);
210
211
 
212
+ if (info.xd_old_data.size > GIT_XDIFF_MAX_SIZE ||
213
+ info.xd_new_data.size > GIT_XDIFF_MAX_SIZE) {
214
+ giterr_set(GITERR_INVALID, "files too large for diff");
215
+ return -1;
216
+ }
217
+
211
218
  xdl_diff(&info.xd_old_data, &info.xd_new_data,
212
219
  &xo->params, &xo->config, &xo->callback);
213
220
 
@@ -11,6 +11,11 @@
11
11
  #include "diff_patch.h"
12
12
  #include "xdiff/xdiff.h"
13
13
 
14
+ /* xdiff cannot cope with large files. these files should not be passed to
15
+ * xdiff. callers should treat these large files as binary.
16
+ */
17
+ #define GIT_XDIFF_MAX_SIZE (1024LL * 1024 * 1023)
18
+
14
19
  /* A git_xdiff_output is a git_diff_output with extra fields necessary
15
20
  * to use libxdiff. Calling git_xdiff_init() will set the diff_cb field
16
21
  * of the output to use xdiff to generate the diffs.
@@ -18,30 +18,19 @@ static git_error g_git_oom_error = {
18
18
  GITERR_NOMEMORY
19
19
  };
20
20
 
21
- static void set_error_from_buffer(int error_class)
21
+ static void set_error(int error_class, char *string)
22
22
  {
23
23
  git_error *error = &GIT_GLOBAL->error_t;
24
- git_buf *buf = &GIT_GLOBAL->error_buf;
25
24
 
26
- error->message = buf->ptr;
25
+ if (error->message != string)
26
+ git__free(error->message);
27
+
28
+ error->message = string;
27
29
  error->klass = error_class;
28
30
 
29
31
  GIT_GLOBAL->last_error = error;
30
32
  }
31
33
 
32
- static void set_error(int error_class, char *string)
33
- {
34
- git_buf *buf = &GIT_GLOBAL->error_buf;
35
-
36
- git_buf_clear(buf);
37
- if (string) {
38
- git_buf_puts(buf, string);
39
- git__free(string);
40
- }
41
-
42
- set_error_from_buffer(error_class);
43
- }
44
-
45
34
  void giterr_set_oom(void)
46
35
  {
47
36
  GIT_GLOBAL->last_error = &g_git_oom_error;
@@ -49,28 +38,27 @@ void giterr_set_oom(void)
49
38
 
50
39
  void giterr_set(int error_class, const char *string, ...)
51
40
  {
41
+ git_buf buf = GIT_BUF_INIT;
52
42
  va_list arglist;
53
43
  #ifdef GIT_WIN32
54
44
  DWORD win32_error_code = (error_class == GITERR_OS) ? GetLastError() : 0;
55
45
  #endif
56
46
  int error_code = (error_class == GITERR_OS) ? errno : 0;
57
- git_buf *buf = &GIT_GLOBAL->error_buf;
58
47
 
59
- git_buf_clear(buf);
60
48
  if (string) {
61
49
  va_start(arglist, string);
62
- git_buf_vprintf(buf, string, arglist);
50
+ git_buf_vprintf(&buf, string, arglist);
63
51
  va_end(arglist);
64
52
 
65
53
  if (error_class == GITERR_OS)
66
- git_buf_PUTS(buf, ": ");
54
+ git_buf_PUTS(&buf, ": ");
67
55
  }
68
56
 
69
57
  if (error_class == GITERR_OS) {
70
58
  #ifdef GIT_WIN32
71
59
  char * win32_error = git_win32_get_error_message(win32_error_code);
72
60
  if (win32_error) {
73
- git_buf_puts(buf, win32_error);
61
+ git_buf_puts(&buf, win32_error);
74
62
  git__free(win32_error);
75
63
 
76
64
  SetLastError(0);
@@ -78,29 +66,26 @@ void giterr_set(int error_class, const char *string, ...)
78
66
  else
79
67
  #endif
80
68
  if (error_code)
81
- git_buf_puts(buf, strerror(error_code));
69
+ git_buf_puts(&buf, strerror(error_code));
82
70
 
83
71
  if (error_code)
84
72
  errno = 0;
85
73
  }
86
74
 
87
- if (!git_buf_oom(buf))
88
- set_error_from_buffer(error_class);
75
+ if (!git_buf_oom(&buf))
76
+ set_error(error_class, git_buf_detach(&buf));
89
77
  }
90
78
 
91
79
  void giterr_set_str(int error_class, const char *string)
92
80
  {
93
- git_buf *buf = &GIT_GLOBAL->error_buf;
81
+ char *message;
94
82
 
95
83
  assert(string);
96
84
 
97
- if (!string)
98
- return;
85
+ message = git__strdup(string);
99
86
 
100
- git_buf_clear(buf);
101
- git_buf_puts(buf, string);
102
- if (!git_buf_oom(buf))
103
- set_error_from_buffer(error_class);
87
+ if (message)
88
+ set_error(error_class, message);
104
89
  }
105
90
 
106
91
  int giterr_set_regex(const regex_t *regex, int error_code)
@@ -131,65 +116,45 @@ void giterr_clear(void)
131
116
  #endif
132
117
  }
133
118
 
134
- const git_error *giterr_last(void)
135
- {
136
- return GIT_GLOBAL->last_error;
137
- }
138
-
139
- int giterr_state_capture(git_error_state *state, int error_code)
119
+ int giterr_detach(git_error *cpy)
140
120
  {
141
121
  git_error *error = GIT_GLOBAL->last_error;
142
- git_buf *error_buf = &GIT_GLOBAL->error_buf;
143
-
144
- memset(state, 0, sizeof(git_error_state));
145
122
 
146
- if (!error_code)
147
- return 0;
123
+ assert(cpy);
148
124
 
149
- state->error_code = error_code;
150
- state->oom = (error == &g_git_oom_error);
125
+ if (!error)
126
+ return -1;
151
127
 
152
- if (error) {
153
- state->error_msg.klass = error->klass;
154
-
155
- if (state->oom)
156
- state->error_msg.message = g_git_oom_error.message;
157
- else
158
- state->error_msg.message = git_buf_detach(error_buf);
159
- }
128
+ cpy->message = error->message;
129
+ cpy->klass = error->klass;
160
130
 
131
+ error->message = NULL;
161
132
  giterr_clear();
162
- return error_code;
133
+
134
+ return 0;
163
135
  }
164
136
 
165
- int giterr_state_restore(git_error_state *state)
137
+ const git_error *giterr_last(void)
166
138
  {
167
- int ret = 0;
168
-
169
- giterr_clear();
170
-
171
- if (state && state->error_msg.message) {
172
- if (state->oom)
173
- giterr_set_oom();
174
- else
175
- set_error(state->error_msg.klass, state->error_msg.message);
176
-
177
- ret = state->error_code;
178
- memset(state, 0, sizeof(git_error_state));
179
- }
180
-
181
- return ret;
139
+ return GIT_GLOBAL->last_error;
182
140
  }
183
141
 
184
- void giterr_state_free(git_error_state *state)
142
+ int giterr_capture(git_error_state *state, int error_code)
185
143
  {
186
- if (!state)
187
- return;
144
+ state->error_code = error_code;
145
+ if (error_code)
146
+ giterr_detach(&state->error_msg);
147
+ return error_code;
148
+ }
188
149
 
189
- if (!state->oom)
190
- git__free(state->error_msg.message);
150
+ int giterr_restore(git_error_state *state)
151
+ {
152
+ if (state && state->error_code && state->error_msg.message)
153
+ set_error(state->error_msg.klass, state->error_msg.message);
154
+ else
155
+ giterr_clear();
191
156
 
192
- memset(state, 0, sizeof(git_error_state));
157
+ return state ? state->error_code : 0;
193
158
  }
194
159
 
195
160
  int giterr_system_last(void)
@@ -433,11 +433,8 @@ static int filter_list_check_attributes(
433
433
  want_type = git_attr_value(want);
434
434
  found_type = git_attr_value(strs[i]);
435
435
 
436
- if (want_type != found_type)
437
- error = GIT_ENOTFOUND;
438
- else if (want_type == GIT_ATTR_VALUE_T &&
439
- strcmp(want, strs[i]) &&
440
- strcmp(want, "*"))
436
+ if (want_type != found_type ||
437
+ (want_type == GIT_ATTR_VALUE_T && strcmp(want, strs[i])))
441
438
  error = GIT_ENOTFOUND;
442
439
  }
443
440
 
@@ -11,10 +11,7 @@
11
11
  #include "git2/global.h"
12
12
  #include "git2/sys/openssl.h"
13
13
  #include "thread-utils.h"
14
- #if defined(GIT_MSVC_CRTDBG)
15
- #include "win32/w32_stack.h"
16
- #include "win32/w32_crtdbg_stacktrace.h"
17
- #endif
14
+
18
15
 
19
16
  git_mutex git__mwindow_mutex;
20
17
 
@@ -228,11 +225,6 @@ int git_libgit2_init(void)
228
225
 
229
226
  /* Only do work on a 0 -> 1 transition of the refcount */
230
227
  if ((ret = git_atomic_inc(&git__n_inits)) == 1) {
231
- #if defined(GIT_MSVC_CRTDBG)
232
- git_win32__crtdbg_stacktrace_init();
233
- git_win32__stack_init();
234
- #endif
235
-
236
228
  if (synchronized_threads_init() < 0)
237
229
  ret = -1;
238
230
  }
@@ -262,15 +254,9 @@ int git_libgit2_shutdown(void)
262
254
  while (InterlockedCompareExchange(&_mutex, 1, 0)) { Sleep(0); }
263
255
 
264
256
  /* Only do work on a 1 -> 0 transition of the refcount */
265
- if ((ret = git_atomic_dec(&git__n_inits)) == 0) {
257
+ if ((ret = git_atomic_dec(&git__n_inits)) == 0)
266
258
  synchronized_threads_shutdown();
267
259
 
268
- #if defined(GIT_MSVC_CRTDBG)
269
- git_win32__crtdbg_stacktrace_cleanup();
270
- git_win32__stack_cleanup();
271
- #endif
272
- }
273
-
274
260
  /* Exit the lock */
275
261
  InterlockedExchange(&_mutex, 0);
276
262
 
@@ -279,19 +265,18 @@ int git_libgit2_shutdown(void)
279
265
 
280
266
  git_global_st *git__global_state(void)
281
267
  {
282
- git_global_st *ptr;
268
+ void *ptr;
283
269
 
284
270
  assert(git_atomic_get(&git__n_inits) > 0);
285
271
 
286
272
  if ((ptr = TlsGetValue(_tls_index)) != NULL)
287
273
  return ptr;
288
274
 
289
- ptr = git__calloc(1, sizeof(git_global_st));
275
+ ptr = git__malloc(sizeof(git_global_st));
290
276
  if (!ptr)
291
277
  return NULL;
292
278
 
293
- git_buf_init(&ptr->error_buf, 0);
294
-
279
+ memset(ptr, 0x0, sizeof(git_global_st));
295
280
  TlsSetValue(_tls_index, ptr);
296
281
  return ptr;
297
282
  }
@@ -345,8 +330,8 @@ int git_libgit2_init(void)
345
330
  {
346
331
  int ret;
347
332
 
348
- ret = git_atomic_inc(&git__n_inits);
349
333
  pthread_once(&_once_init, init_once);
334
+ ret = git_atomic_inc(&git__n_inits);
350
335
 
351
336
  return init_error ? init_error : ret;
352
337
  }
@@ -379,18 +364,18 @@ int git_libgit2_shutdown(void)
379
364
 
380
365
  git_global_st *git__global_state(void)
381
366
  {
382
- git_global_st *ptr;
367
+ void *ptr;
383
368
 
384
369
  assert(git_atomic_get(&git__n_inits) > 0);
385
370
 
386
371
  if ((ptr = pthread_getspecific(_tls_key)) != NULL)
387
372
  return ptr;
388
373
 
389
- ptr = git__calloc(1, sizeof(git_global_st));
374
+ ptr = git__malloc(sizeof(git_global_st));
390
375
  if (!ptr)
391
376
  return NULL;
392
377
 
393
- git_buf_init(&ptr->error_buf, 0);
378
+ memset(ptr, 0x0, sizeof(git_global_st));
394
379
  pthread_setspecific(_tls_key, ptr);
395
380
  return ptr;
396
381
  }
@@ -408,7 +393,6 @@ int git_libgit2_init(void)
408
393
  ssl_inited = 1;
409
394
  }
410
395
 
411
- git_buf_init(&__state.error_buf, 0);
412
396
  return git_atomic_inc(&git__n_inits);
413
397
  }
414
398