rugged 0.23.2 → 0.23.3

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 (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
@@ -14,7 +14,6 @@
14
14
  typedef struct {
15
15
  git_error *last_error;
16
16
  git_error error_t;
17
- git_buf error_buf;
18
17
  char oid_fmt[GIT_OID_HEXSZ+1];
19
18
  } git_global_st;
20
19
 
@@ -1286,13 +1286,13 @@ int git_index_add_bypath(git_index *index, const char *path)
1286
1286
  git_submodule *sm;
1287
1287
  git_error_state err;
1288
1288
 
1289
- giterr_state_capture(&err, ret);
1289
+ giterr_capture(&err, ret);
1290
1290
 
1291
1291
  ret = git_submodule_lookup(&sm, INDEX_OWNER(index), path);
1292
1292
  if (ret == GIT_ENOTFOUND)
1293
- return giterr_state_restore(&err);
1293
+ return giterr_restore(&err);
1294
1294
 
1295
- giterr_state_free(&err);
1295
+ git__free(err.error_msg.message);
1296
1296
 
1297
1297
  /*
1298
1298
  * EEXISTS means that there is a repository at that path, but it's not known
@@ -1120,7 +1120,7 @@ static int fs_iterator__expand_dir(fs_iterator *fi)
1120
1120
 
1121
1121
  if (error < 0) {
1122
1122
  git_error_state last_error = { 0 };
1123
- giterr_state_capture(&last_error, error);
1123
+ giterr_capture(&last_error, error);
1124
1124
 
1125
1125
  /* these callbacks may clear the error message */
1126
1126
  fs_iterator__free_frame(ff);
@@ -1128,7 +1128,7 @@ static int fs_iterator__expand_dir(fs_iterator *fi)
1128
1128
  /* next time return value we skipped to */
1129
1129
  fi->base.flags &= ~GIT_ITERATOR_FIRST_ACCESS;
1130
1130
 
1131
- return giterr_state_restore(&last_error);
1131
+ return giterr_restore(&last_error);
1132
1132
  }
1133
1133
 
1134
1134
  if (ff->entries.length == 0) {
@@ -20,7 +20,6 @@
20
20
  #include "diff.h"
21
21
  #include "checkout.h"
22
22
  #include "tree.h"
23
- #include "merge_file.h"
24
23
  #include "blob.h"
25
24
  #include "oid.h"
26
25
  #include "index.h"
@@ -61,12 +60,6 @@ struct merge_diff_df_data {
61
60
  git_merge_diff *prev_conflict;
62
61
  };
63
62
 
64
- GIT_INLINE(int) merge_diff_detect_binary(
65
- bool *binary_out,
66
- git_repository *repo,
67
- const git_merge_diff *conflict);
68
-
69
-
70
63
  /* Merge base computation */
71
64
 
72
65
  int merge_bases_many(git_commit_list **out, git_revwalk **walk_out, git_repository *repo, size_t length, const git_oid input_array[])
@@ -668,7 +661,6 @@ static int merge_conflict_resolve_automerge(
668
661
  git_odb *odb = NULL;
669
662
  git_oid automerge_oid;
670
663
  int error = 0;
671
- bool binary = false;
672
664
 
673
665
  assert(resolved && diff_list && conflict);
674
666
 
@@ -703,12 +695,6 @@ static int merge_conflict_resolve_automerge(
703
695
  strcmp(conflict->ancestor_entry.path, conflict->their_entry.path) != 0)
704
696
  return 0;
705
697
 
706
- /* Reject binary conflicts */
707
- if ((error = merge_diff_detect_binary(&binary, diff_list->repo, conflict)) < 0)
708
- return error;
709
- if (binary)
710
- return 0;
711
-
712
698
  ancestor = GIT_MERGE_INDEX_ENTRY_EXISTS(conflict->ancestor_entry) ?
713
699
  &conflict->ancestor_entry : NULL;
714
700
  ours = GIT_MERGE_INDEX_ENTRY_EXISTS(conflict->our_entry) ?
@@ -1314,48 +1300,6 @@ GIT_INLINE(int) merge_diff_detect_type(
1314
1300
  return 0;
1315
1301
  }
1316
1302
 
1317
- GIT_INLINE(int) merge_diff_detect_binary(
1318
- bool *binary_out,
1319
- git_repository *repo,
1320
- const git_merge_diff *conflict)
1321
- {
1322
- git_blob *ancestor_blob = NULL, *our_blob = NULL, *their_blob = NULL;
1323
- int error = 0;
1324
- bool binary = false;
1325
-
1326
- if (GIT_MERGE_INDEX_ENTRY_ISFILE(conflict->ancestor_entry)) {
1327
- if ((error = git_blob_lookup(&ancestor_blob, repo, &conflict->ancestor_entry.id)) < 0)
1328
- goto done;
1329
-
1330
- binary = git_blob_is_binary(ancestor_blob);
1331
- }
1332
-
1333
- if (!binary &&
1334
- GIT_MERGE_INDEX_ENTRY_ISFILE(conflict->our_entry)) {
1335
- if ((error = git_blob_lookup(&our_blob, repo, &conflict->our_entry.id)) < 0)
1336
- goto done;
1337
-
1338
- binary = git_blob_is_binary(our_blob);
1339
- }
1340
-
1341
- if (!binary &&
1342
- GIT_MERGE_INDEX_ENTRY_ISFILE(conflict->their_entry)) {
1343
- if ((error = git_blob_lookup(&their_blob, repo, &conflict->their_entry.id)) < 0)
1344
- goto done;
1345
-
1346
- binary = git_blob_is_binary(their_blob);
1347
- }
1348
-
1349
- *binary_out = binary;
1350
-
1351
- done:
1352
- git_blob_free(ancestor_blob);
1353
- git_blob_free(our_blob);
1354
- git_blob_free(their_blob);
1355
-
1356
- return error;
1357
- }
1358
-
1359
1303
  GIT_INLINE(int) index_entry_dup_pool(
1360
1304
  git_index_entry *out,
1361
1305
  git_pool *pool,
@@ -7,17 +7,23 @@
7
7
 
8
8
  #include "common.h"
9
9
  #include "repository.h"
10
- #include "merge_file.h"
11
10
  #include "posix.h"
12
11
  #include "fileops.h"
13
12
  #include "index.h"
13
+ #include "diff_xdiff.h"
14
14
 
15
15
  #include "git2/repository.h"
16
16
  #include "git2/object.h"
17
17
  #include "git2/index.h"
18
+ #include "git2/merge.h"
18
19
 
19
20
  #include "xdiff/xdiff.h"
20
21
 
22
+ /* only examine the first 8000 bytes for binaryness.
23
+ * https://github.com/git/git/blob/77bd3ea9f54f1584147b594abc04c26ca516d987/xdiff-interface.c#L197
24
+ */
25
+ #define GIT_MERGE_FILE_BINARY_SIZE 8000
26
+
21
27
  #define GIT_MERGE_FILE_SIDE_EXISTS(X) ((X)->mode != 0)
22
28
 
23
29
  GIT_INLINE(const char *) merge_file_best_path(
@@ -100,7 +106,7 @@ static void merge_file_normalize_opts(
100
106
  }
101
107
  }
102
108
 
103
- static int git_merge_file__from_inputs(
109
+ static int merge_file__xdiff(
104
110
  git_merge_file_result *out,
105
111
  const git_merge_file_input *ancestor,
106
112
  const git_merge_file_input *ours,
@@ -189,6 +195,63 @@ done:
189
195
  return error;
190
196
  }
191
197
 
198
+ static bool merge_file__is_binary(const git_merge_file_input *file)
199
+ {
200
+ size_t len = file ? file->size : 0;
201
+
202
+ if (len > GIT_XDIFF_MAX_SIZE)
203
+ return true;
204
+ if (len > GIT_MERGE_FILE_BINARY_SIZE)
205
+ len = GIT_MERGE_FILE_BINARY_SIZE;
206
+
207
+ return len ? (memchr(file->ptr, 0, len) != NULL) : false;
208
+ }
209
+
210
+ static int merge_file__binary(
211
+ git_merge_file_result *out,
212
+ const git_merge_file_input *ours,
213
+ const git_merge_file_input *theirs,
214
+ const git_merge_file_options *given_opts)
215
+ {
216
+ const git_merge_file_input *favored = NULL;
217
+
218
+ memset(out, 0x0, sizeof(git_merge_file_result));
219
+
220
+ if (given_opts && given_opts->favor == GIT_MERGE_FILE_FAVOR_OURS)
221
+ favored = ours;
222
+ else if (given_opts && given_opts->favor == GIT_MERGE_FILE_FAVOR_THEIRS)
223
+ favored = theirs;
224
+ else
225
+ goto done;
226
+
227
+ if ((out->path = git__strdup(favored->path)) == NULL ||
228
+ (out->ptr = git__malloc(favored->size)) == NULL)
229
+ goto done;
230
+
231
+ memcpy((char *)out->ptr, favored->ptr, favored->size);
232
+ out->len = favored->size;
233
+ out->mode = favored->mode;
234
+ out->automergeable = 1;
235
+
236
+ done:
237
+ return 0;
238
+ }
239
+
240
+ static int merge_file__from_inputs(
241
+ git_merge_file_result *out,
242
+ const git_merge_file_input *ancestor,
243
+ const git_merge_file_input *ours,
244
+ const git_merge_file_input *theirs,
245
+ const git_merge_file_options *given_opts)
246
+ {
247
+ if (merge_file__is_binary(ancestor) ||
248
+ merge_file__is_binary(ours) ||
249
+ merge_file__is_binary(theirs))
250
+ return merge_file__binary(out, ours, theirs, given_opts);
251
+
252
+ return merge_file__xdiff(out, ancestor, ours, theirs, given_opts);
253
+ }
254
+
192
255
  static git_merge_file_input *git_merge_file__normalize_inputs(
193
256
  git_merge_file_input *out,
194
257
  const git_merge_file_input *given)
@@ -223,7 +286,7 @@ int git_merge_file(
223
286
  ours = git_merge_file__normalize_inputs(&inputs[1], ours);
224
287
  theirs = git_merge_file__normalize_inputs(&inputs[2], theirs);
225
288
 
226
- return git_merge_file__from_inputs(out, ancestor, ours, theirs, options);
289
+ return merge_file__from_inputs(out, ancestor, ours, theirs, options);
227
290
  }
228
291
 
229
292
  int git_merge_file_from_index(
@@ -234,8 +297,8 @@ int git_merge_file_from_index(
234
297
  const git_index_entry *theirs,
235
298
  const git_merge_file_options *options)
236
299
  {
237
- git_merge_file_input inputs[3] = { {0} },
238
- *ancestor_input = NULL, *our_input = NULL, *their_input = NULL;
300
+ git_merge_file_input *ancestor_ptr = NULL,
301
+ ancestor_input = {0}, our_input = {0}, their_input = {0};
239
302
  git_odb *odb = NULL;
240
303
  git_odb_object *odb_object[3] = { 0 };
241
304
  int error = 0;
@@ -249,27 +312,20 @@ int git_merge_file_from_index(
249
312
 
250
313
  if (ancestor) {
251
314
  if ((error = git_merge_file__input_from_index(
252
- &inputs[0], &odb_object[0], odb, ancestor)) < 0)
315
+ &ancestor_input, &odb_object[0], odb, ancestor)) < 0)
253
316
  goto done;
254
317
 
255
- ancestor_input = &inputs[0];
318
+ ancestor_ptr = &ancestor_input;
256
319
  }
257
320
 
258
321
  if ((error = git_merge_file__input_from_index(
259
- &inputs[1], &odb_object[1], odb, ours)) < 0)
260
- goto done;
261
-
262
- our_input = &inputs[1];
263
-
264
- if ((error = git_merge_file__input_from_index(
265
- &inputs[2], &odb_object[2], odb, theirs)) < 0)
322
+ &our_input, &odb_object[1], odb, ours)) < 0 ||
323
+ (error = git_merge_file__input_from_index(
324
+ &their_input, &odb_object[2], odb, theirs)) < 0)
266
325
  goto done;
267
326
 
268
- their_input = &inputs[2];
269
-
270
- if ((error = git_merge_file__from_inputs(out,
271
- ancestor_input, our_input, their_input, options)) < 0)
272
- goto done;
327
+ error = merge_file__from_inputs(out,
328
+ ancestor_ptr, &our_input, &their_input, options);
273
329
 
274
330
  done:
275
331
  git_odb_object_free(odb_object[0]);
@@ -286,7 +342,5 @@ void git_merge_file_result_free(git_merge_file_result *result)
286
342
  return;
287
343
 
288
344
  git__free((char *)result->path);
289
-
290
- /* xdiff uses malloc() not git_malloc, so we use free(), not git_free() */
291
- free((char *)result->ptr);
345
+ git__free((char *)result->ptr);
292
346
  }
@@ -360,12 +360,11 @@ int openssl_certificate(git_cert **out, git_stream *stream)
360
360
  return -1;
361
361
  }
362
362
 
363
- st->cert_info.parent.cert_type = GIT_CERT_X509;
363
+ st->cert_info.cert_type = GIT_CERT_X509;
364
364
  st->cert_info.data = encoded_cert;
365
365
  st->cert_info.len = len;
366
366
 
367
- *out = &st->cert_info.parent;
368
-
367
+ *out = (git_cert *)&st->cert_info;
369
368
  return 0;
370
369
  }
371
370
 
@@ -1676,19 +1676,3 @@ bool git_path_isvalid(
1676
1676
 
1677
1677
  return verify_component(repo, start, (c - start), flags);
1678
1678
  }
1679
-
1680
- int git_path_normalize_slashes(git_buf *out, const char *path)
1681
- {
1682
- int error;
1683
- char *p;
1684
-
1685
- if ((error = git_buf_puts(out, path)) < 0)
1686
- return error;
1687
-
1688
- for (p = out->ptr; *p; p++) {
1689
- if (*p == '\\')
1690
- *p = '/';
1691
- }
1692
-
1693
- return 0;
1694
- }
@@ -591,9 +591,4 @@ extern bool git_path_isvalid(
591
591
  const char *path,
592
592
  unsigned int flags);
593
593
 
594
- /**
595
- * Convert any backslashes into slashes
596
- */
597
- int git_path_normalize_slashes(git_buf *out, const char *path);
598
-
599
594
  #endif
@@ -63,8 +63,6 @@ typedef struct refdb_fs_backend {
63
63
  uint32_t direach_flags;
64
64
  } refdb_fs_backend;
65
65
 
66
- static int refdb_reflog_fs__delete(git_refdb_backend *_backend, const char *name);
67
-
68
66
  static int packref_cmp(const void *a_, const void *b_)
69
67
  {
70
68
  const struct packref *a = a_, *b = b_;
@@ -1219,11 +1217,6 @@ static int refdb_fs_backend__delete(
1219
1217
  if ((error = loose_lock(&file, backend, ref_name)) < 0)
1220
1218
  return error;
1221
1219
 
1222
- if ((error = refdb_reflog_fs__delete(_backend, ref_name)) < 0) {
1223
- git_filebuf_cleanup(&file);
1224
- return error;
1225
- }
1226
-
1227
1220
  return refdb_fs_backend__delete_tail(_backend, &file, ref_name, old_id, old_target);
1228
1221
  }
1229
1222
 
@@ -153,7 +153,7 @@ static int get_check_cert(int *out, git_repository *repo)
153
153
  * most specific to least specific. */
154
154
 
155
155
  /* GIT_SSL_NO_VERIFY environment variable */
156
- if ((val = p_getenv("GIT_SSL_NO_VERIFY")) != NULL)
156
+ if ((val = getenv("GIT_SSL_NO_VERIFY")) != NULL)
157
157
  return git_config_parse_bool(out, val);
158
158
 
159
159
  /* http.sslVerify config setting */
@@ -759,7 +759,7 @@ int git_remote__get_http_proxy(git_remote *remote, bool use_ssl, char **proxy_ur
759
759
  {
760
760
  git_config *cfg;
761
761
  git_config_entry *ce = NULL;
762
- git_buf val = GIT_BUF_INIT;
762
+ const char *val = NULL;
763
763
  int error;
764
764
 
765
765
  assert(remote);
@@ -789,7 +789,7 @@ int git_remote__get_http_proxy(git_remote *remote, bool use_ssl, char **proxy_ur
789
789
  return error;
790
790
 
791
791
  if (ce && ce->value) {
792
- *proxy_url = git__strdup(ce->value);
792
+ val = ce->value;
793
793
  goto found;
794
794
  }
795
795
  }
@@ -797,28 +797,19 @@ int git_remote__get_http_proxy(git_remote *remote, bool use_ssl, char **proxy_ur
797
797
  /* http.proxy config setting */
798
798
  if ((error = git_config__lookup_entry(&ce, cfg, "http.proxy", false)) < 0)
799
799
  return error;
800
-
801
800
  if (ce && ce->value) {
802
- *proxy_url = git__strdup(ce->value);
801
+ val = ce->value;
803
802
  goto found;
804
803
  }
805
804
 
806
805
  /* HTTP_PROXY / HTTPS_PROXY environment variables */
807
- error = git__getenv(&val, use_ssl ? "HTTPS_PROXY" : "HTTP_PROXY");
808
-
809
- if (error < 0) {
810
- if (error == GIT_ENOTFOUND) {
811
- giterr_clear();
812
- error = 0;
813
- }
814
-
815
- return error;
816
- }
817
-
818
- *proxy_url = git_buf_detach(&val);
806
+ val = use_ssl ? getenv("HTTPS_PROXY") : getenv("HTTP_PROXY");
819
807
 
820
808
  found:
821
- GITERR_CHECK_ALLOC(*proxy_url);
809
+ if (val && val[0]) {
810
+ *proxy_url = git__strdup(val);
811
+ GITERR_CHECK_ALLOC(*proxy_url);
812
+ }
822
813
  git_config_entry_free(ce);
823
814
 
824
815
  return 0;
@@ -108,7 +108,7 @@ int stransport_certificate(git_cert **out, git_stream *stream)
108
108
  return -1;
109
109
  }
110
110
 
111
- st->cert_info.parent.cert_type = GIT_CERT_X509;
111
+ st->cert_info.cert_type = GIT_CERT_X509;
112
112
  st->cert_info.data = (void *) CFDataGetBytePtr(st->der_data);
113
113
  st->cert_info.len = CFDataGetLength(st->der_data);
114
114
 
@@ -787,15 +787,19 @@ int git_submodule_resolve_url(git_buf *out, git_repository *repo, const char *ur
787
787
 
788
788
  git_buf_sanitize(out);
789
789
 
790
- /* We do this in all platforms in case someone on Windows created the .gitmodules */
791
790
  if (strchr(url, '\\')) {
792
- if ((error = git_path_normalize_slashes(&normalized, url)) < 0)
791
+ char *p;
792
+ if ((error = git_buf_puts(&normalized, url)) < 0)
793
793
  return error;
794
794
 
795
+ for (p = normalized.ptr; *p; p++) {
796
+ if (*p == '\\')
797
+ *p = '/';
798
+ }
799
+
795
800
  url = normalized.ptr;
796
801
  }
797
802
 
798
-
799
803
  if (git_path_is_relative(url)) {
800
804
  if (!(error = get_url_base(out, repo)))
801
805
  error = git_path_apply_relative(out, url);