rugged 0.24.6.1 → 0.25.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (213) hide show
  1. checksums.yaml +4 -4
  2. data/LICENSE +1 -1
  3. data/ext/rugged/extconf.rb +9 -2
  4. data/ext/rugged/rugged.c +85 -21
  5. data/ext/rugged/rugged.h +7 -21
  6. data/ext/rugged/rugged_backend.c +3 -20
  7. data/ext/rugged/rugged_blame.c +7 -24
  8. data/ext/rugged/rugged_blob.c +136 -59
  9. data/ext/rugged/rugged_branch.c +3 -20
  10. data/ext/rugged/rugged_branch_collection.c +3 -20
  11. data/ext/rugged/rugged_commit.c +251 -101
  12. data/ext/rugged/rugged_config.c +3 -20
  13. data/ext/rugged/rugged_cred.c +3 -20
  14. data/ext/rugged/rugged_diff.c +3 -20
  15. data/ext/rugged/rugged_diff_delta.c +3 -20
  16. data/ext/rugged/rugged_diff_hunk.c +3 -20
  17. data/ext/rugged/rugged_diff_line.c +3 -20
  18. data/ext/rugged/rugged_index.c +46 -229
  19. data/ext/rugged/rugged_note.c +3 -20
  20. data/ext/rugged/rugged_object.c +3 -20
  21. data/ext/rugged/rugged_patch.c +192 -34
  22. data/ext/rugged/rugged_rebase.c +90 -48
  23. data/ext/rugged/rugged_reference.c +4 -21
  24. data/ext/rugged/rugged_reference_collection.c +3 -20
  25. data/ext/rugged/rugged_remote.c +70 -42
  26. data/ext/rugged/rugged_remote_collection.c +3 -20
  27. data/ext/rugged/rugged_repo.c +50 -59
  28. data/ext/rugged/rugged_revwalk.c +4 -21
  29. data/ext/rugged/rugged_settings.c +3 -20
  30. data/ext/rugged/rugged_signature.c +3 -20
  31. data/ext/rugged/rugged_submodule.c +4 -21
  32. data/ext/rugged/rugged_submodule_collection.c +3 -20
  33. data/ext/rugged/rugged_tag.c +3 -20
  34. data/ext/rugged/rugged_tag_collection.c +3 -20
  35. data/ext/rugged/rugged_tree.c +189 -184
  36. data/lib/rugged/attributes.rb +5 -0
  37. data/lib/rugged/blob.rb +5 -0
  38. data/lib/rugged/branch.rb +6 -1
  39. data/lib/rugged/commit.rb +5 -0
  40. data/lib/rugged/console.rb +5 -0
  41. data/lib/rugged/credentials.rb +5 -0
  42. data/lib/rugged/diff/delta.rb +5 -0
  43. data/lib/rugged/diff/hunk.rb +5 -0
  44. data/lib/rugged/diff/line.rb +5 -0
  45. data/lib/rugged/diff.rb +5 -0
  46. data/lib/rugged/index.rb +120 -0
  47. data/lib/rugged/object.rb +5 -0
  48. data/lib/rugged/patch.rb +5 -0
  49. data/lib/rugged/reference.rb +5 -0
  50. data/lib/rugged/remote.rb +5 -0
  51. data/lib/rugged/repository.rb +9 -4
  52. data/lib/rugged/submodule_collection.rb +5 -0
  53. data/lib/rugged/tag.rb +5 -0
  54. data/lib/rugged/tree.rb +156 -1
  55. data/lib/rugged/version.rb +6 -1
  56. data/lib/rugged/walker.rb +5 -0
  57. data/lib/rugged.rb +5 -0
  58. data/vendor/libgit2/CMakeLists.txt +12 -2
  59. data/vendor/libgit2/include/git2/blob.h +39 -28
  60. data/vendor/libgit2/include/git2/commit.h +76 -0
  61. data/vendor/libgit2/include/git2/common.h +21 -1
  62. data/vendor/libgit2/include/git2/describe.h +5 -2
  63. data/vendor/libgit2/include/git2/diff.h +62 -7
  64. data/vendor/libgit2/include/git2/errors.h +2 -1
  65. data/vendor/libgit2/include/git2/index.h +25 -0
  66. data/vendor/libgit2/include/git2/merge.h +10 -1
  67. data/vendor/libgit2/include/git2/odb.h +47 -1
  68. data/vendor/libgit2/include/git2/pack.h +4 -4
  69. data/vendor/libgit2/include/git2/patch.h +1 -1
  70. data/vendor/libgit2/include/git2/proxy.h +92 -0
  71. data/vendor/libgit2/include/git2/refs.h +11 -0
  72. data/vendor/libgit2/include/git2/remote.h +21 -8
  73. data/vendor/libgit2/include/git2/repository.h +20 -1
  74. data/vendor/libgit2/include/git2/revwalk.h +4 -6
  75. data/vendor/libgit2/include/git2/signature.h +13 -0
  76. data/vendor/libgit2/include/git2/submodule.h +11 -3
  77. data/vendor/libgit2/include/git2/sys/merge.h +177 -0
  78. data/vendor/libgit2/include/git2/sys/odb_backend.h +11 -0
  79. data/vendor/libgit2/include/git2/sys/remote.h +16 -0
  80. data/vendor/libgit2/include/git2/sys/stream.h +2 -1
  81. data/vendor/libgit2/include/git2/sys/time.h +31 -0
  82. data/vendor/libgit2/include/git2/sys/transport.h +3 -1
  83. data/vendor/libgit2/include/git2/tag.h +9 -0
  84. data/vendor/libgit2/include/git2/transaction.h +9 -0
  85. data/vendor/libgit2/include/git2/tree.h +55 -0
  86. data/vendor/libgit2/include/git2/version.h +4 -4
  87. data/vendor/libgit2/include/git2.h +1 -0
  88. data/vendor/libgit2/src/annotated_commit.c +99 -80
  89. data/vendor/libgit2/src/annotated_commit.h +5 -2
  90. data/vendor/libgit2/src/apply.c +377 -0
  91. data/vendor/libgit2/src/apply.h +21 -0
  92. data/vendor/libgit2/src/array.h +0 -1
  93. data/vendor/libgit2/src/blob.c +71 -39
  94. data/vendor/libgit2/src/branch.c +7 -5
  95. data/vendor/libgit2/src/buffer.c +252 -20
  96. data/vendor/libgit2/src/buffer.h +8 -0
  97. data/vendor/libgit2/src/checkout.c +69 -42
  98. data/vendor/libgit2/src/clone.c +0 -8
  99. data/vendor/libgit2/src/commit.c +193 -49
  100. data/vendor/libgit2/src/commit_list.c +8 -3
  101. data/vendor/libgit2/src/commit_list.h +1 -0
  102. data/vendor/libgit2/src/common.h +2 -1
  103. data/vendor/libgit2/src/config.c +3 -3
  104. data/vendor/libgit2/src/config_file.c +20 -10
  105. data/vendor/libgit2/src/crlf.c +1 -0
  106. data/vendor/libgit2/src/curl_stream.c +106 -6
  107. data/vendor/libgit2/src/delta.c +238 -62
  108. data/vendor/libgit2/src/delta.h +79 -58
  109. data/vendor/libgit2/src/describe.c +1 -1
  110. data/vendor/libgit2/src/diff.c +32 -1554
  111. data/vendor/libgit2/src/diff.h +14 -122
  112. data/vendor/libgit2/src/diff_driver.c +4 -6
  113. data/vendor/libgit2/src/diff_file.c +3 -0
  114. data/vendor/libgit2/src/diff_generate.c +1613 -0
  115. data/vendor/libgit2/src/diff_generate.h +123 -0
  116. data/vendor/libgit2/src/diff_parse.c +101 -0
  117. data/vendor/libgit2/src/diff_parse.h +18 -0
  118. data/vendor/libgit2/src/diff_print.c +263 -144
  119. data/vendor/libgit2/src/diff_stats.c +21 -12
  120. data/vendor/libgit2/src/diff_tform.c +1 -0
  121. data/vendor/libgit2/src/diff_tform.h +22 -0
  122. data/vendor/libgit2/src/diff_xdiff.c +9 -9
  123. data/vendor/libgit2/src/diff_xdiff.h +5 -5
  124. data/vendor/libgit2/src/fetchhead.c +8 -8
  125. data/vendor/libgit2/src/filebuf.c +6 -1
  126. data/vendor/libgit2/src/filebuf.h +1 -0
  127. data/vendor/libgit2/src/fileops.c +22 -1
  128. data/vendor/libgit2/src/fileops.h +8 -2
  129. data/vendor/libgit2/src/fnmatch.c +18 -5
  130. data/vendor/libgit2/src/global.c +21 -4
  131. data/vendor/libgit2/src/global.h +6 -0
  132. data/vendor/libgit2/src/graph.c +1 -1
  133. data/vendor/libgit2/src/index.c +159 -46
  134. data/vendor/libgit2/src/index.h +2 -0
  135. data/vendor/libgit2/src/iterator.c +1573 -1468
  136. data/vendor/libgit2/src/iterator.h +52 -69
  137. data/vendor/libgit2/src/merge.c +163 -64
  138. data/vendor/libgit2/src/merge.h +61 -2
  139. data/vendor/libgit2/src/merge_driver.c +397 -0
  140. data/vendor/libgit2/src/merge_driver.h +60 -0
  141. data/vendor/libgit2/src/merge_file.c +11 -49
  142. data/vendor/libgit2/src/netops.c +12 -10
  143. data/vendor/libgit2/src/object_api.c +19 -1
  144. data/vendor/libgit2/src/odb.c +228 -52
  145. data/vendor/libgit2/src/odb_loose.c +19 -1
  146. data/vendor/libgit2/src/odb_mempack.c +1 -1
  147. data/vendor/libgit2/src/odb_pack.c +27 -1
  148. data/vendor/libgit2/src/openssl_stream.c +4 -5
  149. data/vendor/libgit2/src/pack-objects.c +105 -76
  150. data/vendor/libgit2/src/pack-objects.h +13 -12
  151. data/vendor/libgit2/src/pack.c +16 -10
  152. data/vendor/libgit2/src/pack.h +2 -0
  153. data/vendor/libgit2/src/patch.c +216 -0
  154. data/vendor/libgit2/src/patch.h +66 -0
  155. data/vendor/libgit2/src/{diff_patch.c → patch_generate.c} +203 -376
  156. data/vendor/libgit2/src/patch_generate.h +68 -0
  157. data/vendor/libgit2/src/patch_parse.c +1159 -0
  158. data/vendor/libgit2/src/patch_parse.h +56 -0
  159. data/vendor/libgit2/src/path.c +38 -2
  160. data/vendor/libgit2/src/path.h +18 -0
  161. data/vendor/libgit2/src/pathspec.c +1 -1
  162. data/vendor/libgit2/src/pool.h +5 -0
  163. data/vendor/libgit2/src/pqueue.c +12 -5
  164. data/vendor/libgit2/src/pqueue.h +1 -0
  165. data/vendor/libgit2/src/proxy.c +32 -0
  166. data/vendor/libgit2/src/proxy.h +14 -0
  167. data/vendor/libgit2/src/push.c +1 -1
  168. data/vendor/libgit2/src/rebase.c +63 -36
  169. data/vendor/libgit2/src/refdb.c +4 -2
  170. data/vendor/libgit2/src/refdb_fs.c +82 -54
  171. data/vendor/libgit2/src/refs.c +13 -1
  172. data/vendor/libgit2/src/remote.c +20 -81
  173. data/vendor/libgit2/src/repository.c +212 -29
  174. data/vendor/libgit2/src/reset.c +1 -1
  175. data/vendor/libgit2/src/revparse.c +1 -1
  176. data/vendor/libgit2/src/revwalk.c +260 -184
  177. data/vendor/libgit2/src/settings.c +11 -3
  178. data/vendor/libgit2/src/signature.c +27 -2
  179. data/vendor/libgit2/src/sortedcache.c +14 -5
  180. data/vendor/libgit2/src/stash.c +1 -0
  181. data/vendor/libgit2/src/status.c +1 -0
  182. data/vendor/libgit2/src/stransport_stream.c +4 -2
  183. data/vendor/libgit2/src/stream.h +2 -2
  184. data/vendor/libgit2/src/submodule.c +16 -4
  185. data/vendor/libgit2/src/sysdir.c +1 -1
  186. data/vendor/libgit2/src/transport.c +3 -5
  187. data/vendor/libgit2/src/transports/http.c +38 -13
  188. data/vendor/libgit2/src/transports/local.c +4 -1
  189. data/vendor/libgit2/src/transports/smart.c +6 -0
  190. data/vendor/libgit2/src/transports/smart.h +1 -0
  191. data/vendor/libgit2/src/transports/smart_pkt.c +5 -13
  192. data/vendor/libgit2/src/transports/smart_protocol.c +22 -7
  193. data/vendor/libgit2/src/transports/winhttp.c +144 -11
  194. data/vendor/libgit2/src/tree.c +267 -2
  195. data/vendor/libgit2/src/unix/posix.h +10 -0
  196. data/vendor/libgit2/src/unix/pthread.h +2 -0
  197. data/vendor/libgit2/src/util.c +25 -2
  198. data/vendor/libgit2/src/util.h +10 -0
  199. data/vendor/libgit2/src/varint.c +44 -0
  200. data/vendor/libgit2/src/varint.h +15 -0
  201. data/vendor/libgit2/src/vector.c +58 -0
  202. data/vendor/libgit2/src/vector.h +8 -0
  203. data/vendor/libgit2/src/win32/posix.h +3 -0
  204. data/vendor/libgit2/src/win32/thread.c +18 -0
  205. data/vendor/libgit2/src/win32/thread.h +2 -0
  206. data/vendor/libgit2/src/win32/w32_util.h +1 -1
  207. data/vendor/libgit2/src/zstream.c +37 -8
  208. data/vendor/libgit2/src/zstream.h +8 -1
  209. metadata +100 -82
  210. data/vendor/libgit2/Makefile.embed +0 -60
  211. data/vendor/libgit2/src/delta-apply.c +0 -166
  212. data/vendor/libgit2/src/delta-apply.h +0 -62
  213. data/vendor/libgit2/src/diff_patch.h +0 -83
@@ -8,8 +8,8 @@
8
8
  #include "common.h"
9
9
  #include "diff.h"
10
10
  #include "diff_driver.h"
11
- #include "diff_patch.h"
12
11
  #include "diff_xdiff.h"
12
+ #include "patch_generate.h"
13
13
 
14
14
  static int git_xdiff_scan_int(const char **str, int *value)
15
15
  {
@@ -56,7 +56,7 @@ fail:
56
56
 
57
57
  typedef struct {
58
58
  git_xdiff_output *xo;
59
- git_patch *patch;
59
+ git_patch_generated *patch;
60
60
  git_diff_hunk hunk;
61
61
  int old_lineno, new_lineno;
62
62
  mmfile_t xd_old_data, xd_new_data;
@@ -110,9 +110,9 @@ static int diff_update_lines(
110
110
  static int git_xdiff_cb(void *priv, mmbuffer_t *bufs, int len)
111
111
  {
112
112
  git_xdiff_info *info = priv;
113
- git_patch *patch = info->patch;
114
- const git_diff_delta *delta = git_patch_get_delta(patch);
115
- git_diff_output *output = &info->xo->output;
113
+ git_patch_generated *patch = info->patch;
114
+ const git_diff_delta *delta = patch->base.delta;
115
+ git_patch_generated_output *output = &info->xo->output;
116
116
  git_diff_line line;
117
117
 
118
118
  if (len == 1) {
@@ -181,7 +181,7 @@ static int git_xdiff_cb(void *priv, mmbuffer_t *bufs, int len)
181
181
  return output->error;
182
182
  }
183
183
 
184
- static int git_xdiff(git_diff_output *output, git_patch *patch)
184
+ static int git_xdiff(git_patch_generated_output *output, git_patch_generated *patch)
185
185
  {
186
186
  git_xdiff_output *xo = (git_xdiff_output *)output;
187
187
  git_xdiff_info info;
@@ -194,7 +194,7 @@ static int git_xdiff(git_diff_output *output, git_patch *patch)
194
194
  xo->callback.priv = &info;
195
195
 
196
196
  git_diff_find_context_init(
197
- &xo->config.find_func, &findctxt, git_patch__driver(patch));
197
+ &xo->config.find_func, &findctxt, git_patch_generated_driver(patch));
198
198
  xo->config.find_func_priv = &findctxt;
199
199
 
200
200
  if (xo->config.find_func != NULL)
@@ -206,8 +206,8 @@ static int git_xdiff(git_diff_output *output, git_patch *patch)
206
206
  * updates are needed to xo->params.flags
207
207
  */
208
208
 
209
- git_patch__old_data(&info.xd_old_data.ptr, &info.xd_old_data.size, patch);
210
- git_patch__new_data(&info.xd_new_data.ptr, &info.xd_new_data.size, patch);
209
+ git_patch_generated_old_data(&info.xd_old_data.ptr, &info.xd_old_data.size, patch);
210
+ git_patch_generated_new_data(&info.xd_new_data.ptr, &info.xd_new_data.size, patch);
211
211
 
212
212
  if (info.xd_old_data.size > GIT_XDIFF_MAX_SIZE ||
213
213
  info.xd_new_data.size > GIT_XDIFF_MAX_SIZE) {
@@ -8,20 +8,20 @@
8
8
  #define INCLUDE_diff_xdiff_h__
9
9
 
10
10
  #include "diff.h"
11
- #include "diff_patch.h"
12
11
  #include "xdiff/xdiff.h"
12
+ #include "patch_generate.h"
13
13
 
14
14
  /* xdiff cannot cope with large files. these files should not be passed to
15
15
  * xdiff. callers should treat these large files as binary.
16
16
  */
17
17
  #define GIT_XDIFF_MAX_SIZE (1024LL * 1024 * 1023)
18
18
 
19
- /* A git_xdiff_output is a git_diff_output with extra fields necessary
20
- * to use libxdiff. Calling git_xdiff_init() will set the diff_cb field
21
- * of the output to use xdiff to generate the diffs.
19
+ /* A git_xdiff_output is a git_patch_generate_output with extra fields
20
+ * necessary to use libxdiff. Calling git_xdiff_init() will set the diff_cb
21
+ * field of the output to use xdiff to generate the diffs.
22
22
  */
23
23
  typedef struct {
24
- git_diff_output output;
24
+ git_patch_generated_output output;
25
25
 
26
26
  xdemitconf_t config;
27
27
  xpparam_t params;
@@ -149,7 +149,7 @@ static int fetchhead_ref_parse(
149
149
 
150
150
  if (!*line) {
151
151
  giterr_set(GITERR_FETCHHEAD,
152
- "Empty line in FETCH_HEAD line %d", line_num);
152
+ "Empty line in FETCH_HEAD line %"PRIuZ, line_num);
153
153
  return -1;
154
154
  }
155
155
 
@@ -163,7 +163,7 @@ static int fetchhead_ref_parse(
163
163
 
164
164
  if (strlen(oid_str) != GIT_OID_HEXSZ) {
165
165
  giterr_set(GITERR_FETCHHEAD,
166
- "Invalid object ID in FETCH_HEAD line %d", line_num);
166
+ "Invalid object ID in FETCH_HEAD line %"PRIuZ, line_num);
167
167
  return -1;
168
168
  }
169
169
 
@@ -171,7 +171,7 @@ static int fetchhead_ref_parse(
171
171
  const git_error *oid_err = giterr_last();
172
172
  const char *err_msg = oid_err ? oid_err->message : "Invalid object ID";
173
173
 
174
- giterr_set(GITERR_FETCHHEAD, "%s in FETCH_HEAD line %d",
174
+ giterr_set(GITERR_FETCHHEAD, "%s in FETCH_HEAD line %"PRIuZ,
175
175
  err_msg, line_num);
176
176
  return -1;
177
177
  }
@@ -180,7 +180,7 @@ static int fetchhead_ref_parse(
180
180
  if (*line) {
181
181
  if ((is_merge_str = git__strsep(&line, "\t")) == NULL) {
182
182
  giterr_set(GITERR_FETCHHEAD,
183
- "Invalid description data in FETCH_HEAD line %d", line_num);
183
+ "Invalid description data in FETCH_HEAD line %"PRIuZ, line_num);
184
184
  return -1;
185
185
  }
186
186
 
@@ -190,13 +190,13 @@ static int fetchhead_ref_parse(
190
190
  *is_merge = 0;
191
191
  else {
192
192
  giterr_set(GITERR_FETCHHEAD,
193
- "Invalid for-merge entry in FETCH_HEAD line %d", line_num);
193
+ "Invalid for-merge entry in FETCH_HEAD line %"PRIuZ, line_num);
194
194
  return -1;
195
195
  }
196
196
 
197
197
  if ((desc = line) == NULL) {
198
198
  giterr_set(GITERR_FETCHHEAD,
199
- "Invalid description in FETCH_HEAD line %d", line_num);
199
+ "Invalid description in FETCH_HEAD line %"PRIuZ, line_num);
200
200
  return -1;
201
201
  }
202
202
 
@@ -213,7 +213,7 @@ static int fetchhead_ref_parse(
213
213
  if ((desc = strstr(name, "' ")) == NULL ||
214
214
  git__prefixcmp(desc, "' of ") != 0) {
215
215
  giterr_set(GITERR_FETCHHEAD,
216
- "Invalid description in FETCH_HEAD line %d", line_num);
216
+ "Invalid description in FETCH_HEAD line %"PRIuZ, line_num);
217
217
  return -1;
218
218
  }
219
219
 
@@ -277,7 +277,7 @@ int git_repository_fetchhead_foreach(git_repository *repo,
277
277
  }
278
278
 
279
279
  if (*buffer) {
280
- giterr_set(GITERR_FETCHHEAD, "No EOL at line %d", line_num+1);
280
+ giterr_set(GITERR_FETCHHEAD, "No EOL at line %"PRIuZ, line_num+1);
281
281
  error = -1;
282
282
  goto done;
283
283
  }
@@ -272,6 +272,11 @@ cleanup:
272
272
  }
273
273
 
274
274
  int git_filebuf_open(git_filebuf *file, const char *path, int flags, mode_t mode)
275
+ {
276
+ return git_filebuf_open_withsize(file, path, flags, mode, WRITE_BUFFER_SIZE);
277
+ }
278
+
279
+ int git_filebuf_open_withsize(git_filebuf *file, const char *path, int flags, mode_t mode, size_t size)
275
280
  {
276
281
  int compression, error = -1;
277
282
  size_t path_len, alloc_len;
@@ -286,7 +291,7 @@ int git_filebuf_open(git_filebuf *file, const char *path, int flags, mode_t mode
286
291
  if (flags & GIT_FILEBUF_DO_NOT_BUFFER)
287
292
  file->do_not_buffer = true;
288
293
 
289
- file->buf_size = WRITE_BUFFER_SIZE;
294
+ file->buf_size = size;
290
295
  file->buf_pos = 0;
291
296
  file->fd = -1;
292
297
  file->last_error = BUFERR_OK;
@@ -79,6 +79,7 @@ int git_filebuf_reserve(git_filebuf *file, void **buff, size_t len);
79
79
  int git_filebuf_printf(git_filebuf *file, const char *format, ...) GIT_FORMAT_PRINTF(2, 3);
80
80
 
81
81
  int git_filebuf_open(git_filebuf *lock, const char *path, int flags, mode_t mode);
82
+ int git_filebuf_open_withsize(git_filebuf *file, const char *path, int flags, mode_t mode, size_t size);
82
83
  int git_filebuf_commit(git_filebuf *lock);
83
84
  int git_filebuf_commit_at(git_filebuf *lock, const char *path);
84
85
  void git_filebuf_cleanup(git_filebuf *lock);
@@ -72,8 +72,16 @@ int git_futils_creat_locked(const char *path, const mode_t mode)
72
72
  O_EXCL | O_BINARY | O_CLOEXEC, mode);
73
73
 
74
74
  if (fd < 0) {
75
+ int error = errno;
75
76
  giterr_set(GITERR_OS, "Failed to create locked file '%s'", path);
76
- return errno == EEXIST ? GIT_ELOCKED : -1;
77
+ switch (error) {
78
+ case EEXIST:
79
+ return GIT_ELOCKED;
80
+ case ENOENT:
81
+ return GIT_ENOTFOUND;
82
+ default:
83
+ return -1;
84
+ }
77
85
  }
78
86
 
79
87
  return fd;
@@ -837,6 +845,19 @@ int git_futils_cp(const char *from, const char *to, mode_t filemode)
837
845
  return cp_by_fd(ifd, ofd, true);
838
846
  }
839
847
 
848
+ int git_futils_touch(const char *path, time_t *when)
849
+ {
850
+ struct p_timeval times[2];
851
+ int ret;
852
+
853
+ times[0].tv_sec = times[1].tv_sec = when ? *when : time(NULL);
854
+ times[0].tv_usec = times[1].tv_usec = 0;
855
+
856
+ ret = p_utimes(path, times);
857
+
858
+ return (ret < 0) ? git_path_set_error(errno, path, "touch") : 0;
859
+ }
860
+
840
861
  static int cp_link(const char *from, const char *to, size_t link_size)
841
862
  {
842
863
  int error = 0;
@@ -45,12 +45,12 @@ extern int git_futils_writebuffer(
45
45
  extern int git_futils_creat_withpath(const char *path, const mode_t dirmode, const mode_t mode);
46
46
 
47
47
  /**
48
- * Create an open a process-locked file
48
+ * Create and open a process-locked file
49
49
  */
50
50
  extern int git_futils_creat_locked(const char *path, const mode_t mode);
51
51
 
52
52
  /**
53
- * Create an open a process-locked file, while
53
+ * Create and open a process-locked file, while
54
54
  * also creating all the folders in its path
55
55
  */
56
56
  extern int git_futils_creat_locked_withpath(const char *path, const mode_t dirmode, const mode_t mode);
@@ -184,6 +184,12 @@ extern int git_futils_cp(
184
184
  const char *to,
185
185
  mode_t filemode);
186
186
 
187
+ /**
188
+ * Set the files atime and mtime to the given time, or the current time
189
+ * if `ts` is NULL.
190
+ */
191
+ extern int git_futils_touch(const char *path, time_t *when);
192
+
187
193
  /**
188
194
  * Flags that can be passed to `git_futils_cp_r`.
189
195
  *
@@ -93,11 +93,24 @@ p_fnmatchx(const char *pattern, const char *string, int flags, size_t recurs)
93
93
  * It will be restored if/when we recurse below.
94
94
  */
95
95
  if (c == '*') {
96
- flags &= ~FNM_PATHNAME;
97
- while (c == '*')
98
- c = *++pattern;
99
- if (c == '/')
100
- c = *++pattern;
96
+ c = *++pattern;
97
+ /* star-star-slash is at the end, match by default */
98
+ if (c == EOS)
99
+ return 0;
100
+ /* Double-star must be at end or between slashes */
101
+ if (c != '/')
102
+ return (FNM_NOMATCH);
103
+
104
+ c = *++pattern;
105
+ do {
106
+ int e = p_fnmatchx(pattern, string, recurs_flags, recurs);
107
+ if (e != FNM_NOMATCH)
108
+ return e;
109
+ string = strchr(string, '/');
110
+ } while (string++);
111
+
112
+ /* If we get here, we didn't find a match */
113
+ return FNM_NOMATCH;
101
114
  }
102
115
 
103
116
  if (*string == '.' && (flags & FNM_PERIOD) &&
@@ -9,6 +9,7 @@
9
9
  #include "hash.h"
10
10
  #include "sysdir.h"
11
11
  #include "filter.h"
12
+ #include "merge_driver.h"
12
13
  #include "openssl_stream.h"
13
14
  #include "thread-utils.h"
14
15
  #include "git2/global.h"
@@ -59,6 +60,7 @@ static int init_common(void)
59
60
  if ((ret = git_hash_global_init()) == 0 &&
60
61
  (ret = git_sysdir_global_init()) == 0 &&
61
62
  (ret = git_filter_global_init()) == 0 &&
63
+ (ret = git_merge_driver_global_init()) == 0 &&
62
64
  (ret = git_transport_ssh_global_init()) == 0 &&
63
65
  (ret = git_openssl_stream_global_init()) == 0)
64
66
  ret = git_mwindow_global_init();
@@ -245,6 +247,7 @@ BOOL WINAPI DllMain(HINSTANCE hInstDll, DWORD fdwReason, LPVOID lpvReserved)
245
247
  #elif defined(GIT_THREADS) && defined(_POSIX_THREADS)
246
248
 
247
249
  static pthread_key_t _tls_key;
250
+ static pthread_mutex_t _init_mutex = PTHREAD_MUTEX_INITIALIZER;
248
251
  static pthread_once_t _once_init = PTHREAD_ONCE_INIT;
249
252
  int init_error = 0;
250
253
 
@@ -266,12 +269,19 @@ static void init_once(void)
266
269
 
267
270
  int git_libgit2_init(void)
268
271
  {
269
- int ret;
272
+ int ret, err;
270
273
 
271
274
  ret = git_atomic_inc(&git__n_inits);
272
- pthread_once(&_once_init, init_once);
273
275
 
274
- return init_error ? init_error : ret;
276
+ if ((err = pthread_mutex_lock(&_init_mutex)) != 0)
277
+ return err;
278
+ err = pthread_once(&_once_init, init_once);
279
+ err |= pthread_mutex_unlock(&_init_mutex);
280
+
281
+ if (err || init_error)
282
+ return err | init_error;
283
+
284
+ return ret;
275
285
  }
276
286
 
277
287
  int git_libgit2_shutdown(void)
@@ -283,6 +293,9 @@ int git_libgit2_shutdown(void)
283
293
  if ((ret = git_atomic_dec(&git__n_inits)) != 0)
284
294
  return ret;
285
295
 
296
+ if ((ret = pthread_mutex_lock(&_init_mutex)) != 0)
297
+ return ret;
298
+
286
299
  /* Shut down any subsystems that have global state */
287
300
  shutdown_common();
288
301
 
@@ -296,6 +309,9 @@ int git_libgit2_shutdown(void)
296
309
  git_mutex_free(&git__mwindow_mutex);
297
310
  _once_init = new_once;
298
311
 
312
+ if ((ret = pthread_mutex_unlock(&_init_mutex)) != 0)
313
+ return ret;
314
+
299
315
  return 0;
300
316
  }
301
317
 
@@ -325,7 +341,7 @@ int git_libgit2_init(void)
325
341
  {
326
342
  int ret;
327
343
 
328
- /* Only init SSL the first time */
344
+ /* Only init subsystems the first time */
329
345
  if ((ret = git_atomic_inc(&git__n_inits)) != 1)
330
346
  return ret;
331
347
 
@@ -343,6 +359,7 @@ int git_libgit2_shutdown(void)
343
359
  if ((ret = git_atomic_dec(&git__n_inits)) == 0) {
344
360
  shutdown_common();
345
361
  git__global_state_cleanup(&__state);
362
+ memset(&__state, 0, sizeof(__state));
346
363
  }
347
364
 
348
365
  return ret;
@@ -16,6 +16,12 @@ typedef struct {
16
16
  git_error error_t;
17
17
  git_buf error_buf;
18
18
  char oid_fmt[GIT_OID_HEXSZ+1];
19
+
20
+ /* On Windows, this is the current child thread that was started by
21
+ * `git_thread_create`. This is used to set the thread's exit code
22
+ * when terminated by `git_thread_exit`. It is unused on POSIX.
23
+ */
24
+ git_thread *current_thread;
19
25
  } git_global_st;
20
26
 
21
27
  #ifdef GIT_OPENSSL
@@ -59,7 +59,7 @@ static int mark_parents(git_revwalk *walk, git_commit_list_node *one,
59
59
  /* as long as there are non-STALE commits */
60
60
  while (interesting(&list, roots)) {
61
61
  git_commit_list_node *commit = git_pqueue_pop(&list);
62
- int flags;
62
+ unsigned int flags;
63
63
 
64
64
  if (commit == NULL)
65
65
  break;