rugged 0.24.0 → 0.24.5

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 (71) hide show
  1. checksums.yaml +7 -0
  2. data/lib/rugged/version.rb +1 -1
  3. data/vendor/libgit2/CMakeLists.txt +20 -9
  4. data/vendor/libgit2/deps/http-parser/http_parser.c +5 -2
  5. data/vendor/libgit2/include/git2/checkout.h +7 -0
  6. data/vendor/libgit2/include/git2/common.h +16 -1
  7. data/vendor/libgit2/include/git2/version.h +2 -2
  8. data/vendor/libgit2/src/array.h +40 -0
  9. data/vendor/libgit2/src/blame.c +8 -3
  10. data/vendor/libgit2/src/blame_git.c +20 -9
  11. data/vendor/libgit2/src/checkout.c +13 -5
  12. data/vendor/libgit2/src/commit.c +5 -4
  13. data/vendor/libgit2/src/common.h +1 -1
  14. data/vendor/libgit2/src/config_cache.c +2 -1
  15. data/vendor/libgit2/src/config_file.c +14 -20
  16. data/vendor/libgit2/src/delta-apply.c +36 -5
  17. data/vendor/libgit2/src/delta-apply.h +12 -0
  18. data/vendor/libgit2/src/describe.c +2 -1
  19. data/vendor/libgit2/src/diff_tform.c +5 -3
  20. data/vendor/libgit2/src/filebuf.c +6 -1
  21. data/vendor/libgit2/src/global.c +28 -8
  22. data/vendor/libgit2/src/global.h +1 -0
  23. data/vendor/libgit2/src/ignore.c +56 -19
  24. data/vendor/libgit2/src/index.c +27 -8
  25. data/vendor/libgit2/src/indexer.c +11 -7
  26. data/vendor/libgit2/src/iterator.c +2 -2
  27. data/vendor/libgit2/src/merge.c +1 -0
  28. data/vendor/libgit2/src/mwindow.c +20 -21
  29. data/vendor/libgit2/src/mwindow.h +1 -2
  30. data/vendor/libgit2/src/object.c +3 -6
  31. data/vendor/libgit2/src/odb.c +11 -15
  32. data/vendor/libgit2/src/odb.h +2 -1
  33. data/vendor/libgit2/src/odb_loose.c +13 -9
  34. data/vendor/libgit2/src/odb_pack.c +5 -6
  35. data/vendor/libgit2/src/oid.h +9 -0
  36. data/vendor/libgit2/src/openssl_stream.c +60 -27
  37. data/vendor/libgit2/src/openssl_stream.h +106 -0
  38. data/vendor/libgit2/src/pack-objects.c +4 -2
  39. data/vendor/libgit2/src/pack.c +10 -14
  40. data/vendor/libgit2/src/posix.c +7 -0
  41. data/vendor/libgit2/src/posix.h +1 -0
  42. data/vendor/libgit2/src/push.c +6 -6
  43. data/vendor/libgit2/src/refdb_fs.c +1 -0
  44. data/vendor/libgit2/src/refs.c +3 -0
  45. data/vendor/libgit2/src/refspec.c +4 -2
  46. data/vendor/libgit2/src/remote.c +15 -5
  47. data/vendor/libgit2/src/repository.c +29 -21
  48. data/vendor/libgit2/src/settings.c +23 -1
  49. data/vendor/libgit2/src/stransport_stream.c +15 -9
  50. data/vendor/libgit2/src/submodule.c +3 -2
  51. data/vendor/libgit2/src/sysdir.c +41 -47
  52. data/vendor/libgit2/src/sysdir.h +0 -5
  53. data/vendor/libgit2/src/tag.c +8 -2
  54. data/vendor/libgit2/src/thread-utils.h +5 -51
  55. data/vendor/libgit2/src/transport.c +2 -0
  56. data/vendor/libgit2/src/transports/http.c +2 -1
  57. data/vendor/libgit2/src/transports/smart_pkt.c +1 -0
  58. data/vendor/libgit2/src/transports/smart_protocol.c +72 -17
  59. data/vendor/libgit2/src/transports/ssh.c +32 -17
  60. data/vendor/libgit2/src/tree.c +83 -100
  61. data/vendor/libgit2/src/tree.h +4 -5
  62. data/vendor/libgit2/src/unix/map.c +5 -0
  63. data/vendor/libgit2/src/unix/pthread.h +54 -0
  64. data/vendor/libgit2/src/util.c +3 -3
  65. data/vendor/libgit2/src/win32/map.c +24 -5
  66. data/vendor/libgit2/src/win32/precompiled.h +1 -1
  67. data/vendor/libgit2/src/win32/{pthread.c → thread.c} +50 -80
  68. data/vendor/libgit2/src/win32/thread.h +62 -0
  69. data/vendor/libgit2/src/xdiff/xprepare.c +2 -1
  70. metadata +384 -394
  71. data/vendor/libgit2/src/win32/pthread.h +0 -92
@@ -13,4 +13,110 @@ extern int git_openssl_stream_global_init(void);
13
13
 
14
14
  extern int git_openssl_stream_new(git_stream **out, const char *host, const char *port);
15
15
 
16
+ /*
17
+ * OpenSSL 1.1 made BIO opaque so we have to use functions to interact with it
18
+ * which do not exist in previous versions. We define these inline functions so
19
+ * we can program against the interface instead of littering the implementation
20
+ * with ifdefs.
21
+ */
22
+ #ifdef GIT_OPENSSL
23
+ # include <openssl/ssl.h>
24
+ # include <openssl/err.h>
25
+ # include <openssl/x509v3.h>
26
+ # include <openssl/bio.h>
27
+
28
+
29
+
30
+ # if OPENSSL_VERSION_NUMBER < 0x10100000L
31
+
32
+ GIT_INLINE(BIO_METHOD*) BIO_meth_new(int type, const char *name)
33
+ {
34
+ BIO_METHOD *meth = git__calloc(1, sizeof(BIO_METHOD));
35
+ if (!meth) {
36
+ return NULL;
37
+ }
38
+
39
+ meth->type = type;
40
+ meth->name = name;
41
+
42
+ return meth;
43
+ }
44
+
45
+ GIT_INLINE(void) BIO_meth_free(BIO_METHOD *biom)
46
+ {
47
+ git__free(biom);
48
+ }
49
+
50
+ GIT_INLINE(int) BIO_meth_set_write(BIO_METHOD *biom, int (*write) (BIO *, const char *, int))
51
+ {
52
+ biom->bwrite = write;
53
+ return 1;
54
+ }
55
+
56
+ GIT_INLINE(int) BIO_meth_set_read(BIO_METHOD *biom, int (*read) (BIO *, char *, int))
57
+ {
58
+ biom->bread = read;
59
+ return 1;
60
+ }
61
+
62
+ GIT_INLINE(int) BIO_meth_set_puts(BIO_METHOD *biom, int (*puts) (BIO *, const char *))
63
+ {
64
+ biom->bputs = puts;
65
+ return 1;
66
+ }
67
+
68
+ GIT_INLINE(int) BIO_meth_set_gets(BIO_METHOD *biom, int (*gets) (BIO *, char *, int))
69
+
70
+ {
71
+ biom->bgets = gets;
72
+ return 1;
73
+ }
74
+
75
+ GIT_INLINE(int) BIO_meth_set_ctrl(BIO_METHOD *biom, long (*ctrl) (BIO *, int, long, void *))
76
+ {
77
+ biom->ctrl = ctrl;
78
+ return 1;
79
+ }
80
+
81
+ GIT_INLINE(int) BIO_meth_set_create(BIO_METHOD *biom, int (*create) (BIO *))
82
+ {
83
+ biom->create = create;
84
+ return 1;
85
+ }
86
+
87
+ GIT_INLINE(int) BIO_meth_set_destroy(BIO_METHOD *biom, int (*destroy) (BIO *))
88
+ {
89
+ biom->destroy = destroy;
90
+ return 1;
91
+ }
92
+
93
+ GIT_INLINE(int) BIO_get_new_index(void)
94
+ {
95
+ /* This exists as of 1.1 so before we'd just have 0 */
96
+ return 0;
97
+ }
98
+
99
+ GIT_INLINE(void) BIO_set_init(BIO *b, int init)
100
+ {
101
+ b->init = init;
102
+ }
103
+
104
+ GIT_INLINE(void) BIO_set_data(BIO *a, void *ptr)
105
+ {
106
+ a->ptr = ptr;
107
+ }
108
+
109
+ GIT_INLINE(void*) BIO_get_data(BIO *a)
110
+ {
111
+ return a->ptr;
112
+ }
113
+
114
+ GIT_INLINE(const unsigned char *) ASN1_STRING_get0_data(const ASN1_STRING *x)
115
+ {
116
+ return ASN1_STRING_data((ASN1_STRING *)x);
117
+ }
118
+
119
+ # endif // OpenSSL < 1.1
120
+ #endif // GIT_OPENSSL
121
+
16
122
  #endif
@@ -848,8 +848,10 @@ static int try_delta(git_packbuilder *pb, struct unpacked *trg,
848
848
 
849
849
  git_packbuilder__cache_unlock(pb);
850
850
 
851
- if (overflow)
851
+ if (overflow) {
852
+ git__free(delta_buf);
852
853
  return -1;
854
+ }
853
855
 
854
856
  trg_object->delta_data = git__realloc(delta_buf, delta_size);
855
857
  GITERR_CHECK_ALLOC(trg_object->delta_data);
@@ -1184,7 +1186,7 @@ static int ll_find_deltas(git_packbuilder *pb, git_pobject **list,
1184
1186
  git_mutex_init(&p[i].mutex);
1185
1187
  git_cond_init(&p[i].cond);
1186
1188
 
1187
- ret = git_thread_create(&p[i].thread, NULL,
1189
+ ret = git_thread_create(&p[i].thread,
1188
1190
  threaded_find_deltas, &p[i]);
1189
1191
  if (ret) {
1190
1192
  giterr_set(GITERR_THREAD, "unable to create thread");
@@ -494,21 +494,19 @@ int git_packfile_resolve_header(
494
494
  int error;
495
495
 
496
496
  error = git_packfile_unpack_header(&size, &type, &p->mwf, &w_curs, &curpos);
497
- git_mwindow_close(&w_curs);
498
497
  if (error < 0)
499
498
  return error;
500
499
 
501
500
  if (type == GIT_OBJ_OFS_DELTA || type == GIT_OBJ_REF_DELTA) {
502
501
  size_t base_size;
503
- git_rawobj delta;
502
+ git_packfile_stream stream;
503
+
504
504
  base_offset = get_delta_base(p, &w_curs, &curpos, type, offset);
505
505
  git_mwindow_close(&w_curs);
506
- error = packfile_unpack_compressed(&delta, p, &w_curs, &curpos, size, type);
507
- git_mwindow_close(&w_curs);
508
- if (error < 0)
506
+ if ((error = git_packfile_stream_open(&stream, p, curpos)) < 0)
509
507
  return error;
510
- error = git__delta_read_header(delta.data, delta.len, &base_size, size_p);
511
- git__free(delta.data);
508
+ error = git__delta_read_header_fromstream(&base_size, size_p, &stream);
509
+ git_packfile_stream_free(&stream);
512
510
  if (error < 0)
513
511
  return error;
514
512
  } else
@@ -517,7 +515,6 @@ int git_packfile_resolve_header(
517
515
  while (type == GIT_OBJ_OFS_DELTA || type == GIT_OBJ_REF_DELTA) {
518
516
  curpos = base_offset;
519
517
  error = git_packfile_unpack_header(&size, &type, &p->mwf, &w_curs, &curpos);
520
- git_mwindow_close(&w_curs);
521
518
  if (error < 0)
522
519
  return error;
523
520
  if (type != GIT_OBJ_OFS_DELTA && type != GIT_OBJ_REF_DELTA)
@@ -585,7 +582,6 @@ static int pack_dependency_chain(git_dependency_chain *chain_out,
585
582
  elem->base_key = obj_offset;
586
583
 
587
584
  error = git_packfile_unpack_header(&size, &type, &p->mwf, &w_curs, &curpos);
588
- git_mwindow_close(&w_curs);
589
585
 
590
586
  if (error < 0)
591
587
  goto on_error;
@@ -1018,7 +1014,7 @@ static int packfile_open(struct git_pack_file *p)
1018
1014
  unsigned char *idx_sha1;
1019
1015
 
1020
1016
  if (p->index_version == -1 && pack_index_open(p) < 0)
1021
- return git_odb__error_notfound("failed to open packfile", NULL);
1017
+ return git_odb__error_notfound("failed to open packfile", NULL, 0);
1022
1018
 
1023
1019
  /* if mwf opened by another thread, return now */
1024
1020
  if (git_mutex_lock(&p->lock) < 0)
@@ -1099,7 +1095,7 @@ int git_packfile__name(char **out, const char *path)
1099
1095
  path_len = strlen(path);
1100
1096
 
1101
1097
  if (path_len < strlen(".idx"))
1102
- return git_odb__error_notfound("invalid packfile path", NULL);
1098
+ return git_odb__error_notfound("invalid packfile path", NULL, 0);
1103
1099
 
1104
1100
  if (git_buf_printf(&buf, "%.*s.pack", (int)(path_len - strlen(".idx")), path) < 0)
1105
1101
  return -1;
@@ -1117,7 +1113,7 @@ int git_packfile_alloc(struct git_pack_file **pack_out, const char *path)
1117
1113
  *pack_out = NULL;
1118
1114
 
1119
1115
  if (path_len < strlen(".idx"))
1120
- return git_odb__error_notfound("invalid packfile path", NULL);
1116
+ return git_odb__error_notfound("invalid packfile path", NULL, 0);
1121
1117
 
1122
1118
  GITERR_CHECK_ALLOC_ADD(&alloc_len, sizeof(*p), path_len);
1123
1119
  GITERR_CHECK_ALLOC_ADD(&alloc_len, alloc_len, 2);
@@ -1143,7 +1139,7 @@ int git_packfile_alloc(struct git_pack_file **pack_out, const char *path)
1143
1139
 
1144
1140
  if (p_stat(p->pack_name, &st) < 0 || !S_ISREG(st.st_mode)) {
1145
1141
  git__free(p);
1146
- return git_odb__error_notfound("packfile not found", NULL);
1142
+ return git_odb__error_notfound("packfile not found", NULL, 0);
1147
1143
  }
1148
1144
 
1149
1145
  /* ok, it looks sane as far as we can check without
@@ -1344,7 +1340,7 @@ static int pack_entry_find_offset(
1344
1340
  }
1345
1341
 
1346
1342
  if (!found)
1347
- return git_odb__error_notfound("failed to find offset for pack entry", short_oid);
1343
+ return git_odb__error_notfound("failed to find offset for pack entry", short_oid, len);
1348
1344
  if (found > 1)
1349
1345
  return git_odb__error_ambiguous("found multiple offsets for pack entry");
1350
1346
 
@@ -224,6 +224,13 @@ int git__page_size(size_t *page_size)
224
224
  return 0;
225
225
  }
226
226
 
227
+ int git__mmap_alignment(size_t *alignment)
228
+ {
229
+ /* dummy; here we don't need any alignment anyway */
230
+ *alignment = 4096;
231
+ return 0;
232
+ }
233
+
227
234
 
228
235
  int p_mmap(git_map *out, size_t len, int prot, int flags, int fd, git_off_t offset)
229
236
  {
@@ -109,6 +109,7 @@ extern int p_getcwd(char *buffer_out, size_t size);
109
109
  extern int p_rename(const char *from, const char *to);
110
110
 
111
111
  extern int git__page_size(size_t *page_size);
112
+ extern int git__mmap_alignment(size_t *page_size);
112
113
 
113
114
  /**
114
115
  * Platform-dependent methods
@@ -374,9 +374,9 @@ static int enqueue_object(
374
374
  case GIT_OBJ_COMMIT:
375
375
  return 0;
376
376
  case GIT_OBJ_TREE:
377
- return git_packbuilder_insert_tree(pb, &entry->oid);
377
+ return git_packbuilder_insert_tree(pb, entry->oid);
378
378
  default:
379
- return git_packbuilder_insert(pb, &entry->oid, entry->filename);
379
+ return git_packbuilder_insert(pb, entry->oid, entry->filename);
380
380
  }
381
381
  }
382
382
 
@@ -396,7 +396,7 @@ static int queue_differences(
396
396
  const git_tree_entry *d_entry = git_tree_entry_byindex(delta, j);
397
397
  int cmp = 0;
398
398
 
399
- if (!git_oid__cmp(&b_entry->oid, &d_entry->oid))
399
+ if (!git_oid__cmp(b_entry->oid, d_entry->oid))
400
400
  goto loop;
401
401
 
402
402
  cmp = strcmp(b_entry->filename, d_entry->filename);
@@ -407,15 +407,15 @@ static int queue_differences(
407
407
  git_tree_entry__is_tree(b_entry) &&
408
408
  git_tree_entry__is_tree(d_entry)) {
409
409
  /* Add the right-hand entry */
410
- if ((error = git_packbuilder_insert(pb, &d_entry->oid,
410
+ if ((error = git_packbuilder_insert(pb, d_entry->oid,
411
411
  d_entry->filename)) < 0)
412
412
  goto on_error;
413
413
 
414
414
  /* Acquire the subtrees and recurse */
415
415
  if ((error = git_tree_lookup(&b_child,
416
- git_tree_owner(base), &b_entry->oid)) < 0 ||
416
+ git_tree_owner(base), b_entry->oid)) < 0 ||
417
417
  (error = git_tree_lookup(&d_child,
418
- git_tree_owner(delta), &d_entry->oid)) < 0 ||
418
+ git_tree_owner(delta), d_entry->oid)) < 0 ||
419
419
  (error = queue_differences(b_child, d_child, pb)) < 0)
420
420
  goto on_error;
421
421
 
@@ -962,6 +962,7 @@ static int packed_write(refdb_fs_backend *backend)
962
962
 
963
963
  for (i = 0; i < git_sortedcache_entrycount(refcache); ++i) {
964
964
  struct packref *ref = git_sortedcache_entry(refcache, i);
965
+ assert(ref);
965
966
 
966
967
  if (packed_find_peel(backend, ref) < 0)
967
968
  goto fail;
@@ -289,6 +289,9 @@ cleanup:
289
289
  "Could not use '%s' as valid reference name", git_buf_cstr(&name));
290
290
  }
291
291
 
292
+ if (error == GIT_ENOTFOUND)
293
+ giterr_set(GITERR_REFERENCE, "no reference found for shorthand '%s'", refname);
294
+
292
295
  git_buf_free(&name);
293
296
  git_buf_free(&refnamebuf);
294
297
  return error;
@@ -53,8 +53,10 @@ int git_refspec__parse(git_refspec *refspec, const char *input, bool is_fetch)
53
53
 
54
54
  if (rhs) {
55
55
  size_t rlen = strlen(++rhs);
56
- is_glob = (1 <= rlen && strchr(rhs, '*'));
57
- refspec->dst = git__strndup(rhs, rlen);
56
+ if (rlen || !is_fetch) {
57
+ is_glob = (1 <= rlen && strchr(rhs, '*'));
58
+ refspec->dst = git__strndup(rhs, rlen);
59
+ }
58
60
  }
59
61
 
60
62
  llen = (rhs ? (size_t)(rhs - lhs - 1) : strlen(lhs));
@@ -1414,7 +1414,11 @@ static int update_tips_for_spec(
1414
1414
  /* In autotag mode, don't overwrite any locally-existing tags */
1415
1415
  error = git_reference_create(&ref, remote->repo, refname.ptr, &head->oid, !autotag,
1416
1416
  log_message);
1417
- if (error < 0 && error != GIT_EEXISTS)
1417
+
1418
+ if (error == GIT_EEXISTS)
1419
+ continue;
1420
+
1421
+ if (error < 0)
1418
1422
  goto on_error;
1419
1423
 
1420
1424
  git_reference_free(ref);
@@ -2224,15 +2228,21 @@ static int remove_branch_config_related_entries(
2224
2228
  if (git_buf_printf(&buf, "branch.%.*s.merge", (int)branch_len, branch) < 0)
2225
2229
  break;
2226
2230
 
2227
- if ((error = git_config_delete_entry(config, git_buf_cstr(&buf))) < 0)
2228
- break;
2231
+ if ((error = git_config_delete_entry(config, git_buf_cstr(&buf))) < 0) {
2232
+ if (error != GIT_ENOTFOUND)
2233
+ break;
2234
+ giterr_clear();
2235
+ }
2229
2236
 
2230
2237
  git_buf_clear(&buf);
2231
2238
  if (git_buf_printf(&buf, "branch.%.*s.remote", (int)branch_len, branch) < 0)
2232
2239
  break;
2233
2240
 
2234
- if ((error = git_config_delete_entry(config, git_buf_cstr(&buf))) < 0)
2235
- break;
2241
+ if ((error = git_config_delete_entry(config, git_buf_cstr(&buf))) < 0) {
2242
+ if (error != GIT_ENOTFOUND)
2243
+ break;
2244
+ giterr_clear();
2245
+ }
2236
2246
  }
2237
2247
 
2238
2248
  if (error == GIT_ITEROVER)
@@ -264,7 +264,7 @@ cleanup:
264
264
  * the stack could remove directories name limits, but at the cost of doing
265
265
  * repeated malloc/frees inside the loop below, so let's not do it now.
266
266
  */
267
- static int find_ceiling_dir_offset(
267
+ static size_t find_ceiling_dir_offset(
268
268
  const char *path,
269
269
  const char *ceiling_directories)
270
270
  {
@@ -278,7 +278,7 @@ static int find_ceiling_dir_offset(
278
278
  min_len = (size_t)(git_path_root(path) + 1);
279
279
 
280
280
  if (ceiling_directories == NULL || min_len == 0)
281
- return (int)min_len;
281
+ return min_len;
282
282
 
283
283
  for (sep = ceil = ceiling_directories; *sep; ceil = sep + 1) {
284
284
  for (sep = ceil; *sep && *sep != GIT_PATH_LIST_SEPARATOR; sep++);
@@ -305,7 +305,7 @@ static int find_ceiling_dir_offset(
305
305
  }
306
306
  }
307
307
 
308
- return (int)(max_len <= min_len ? min_len : max_len);
308
+ return (max_len <= min_len ? min_len : max_len);
309
309
  }
310
310
 
311
311
  /*
@@ -359,21 +359,36 @@ static int find_repo(
359
359
  git_buf path = GIT_BUF_INIT;
360
360
  struct stat st;
361
361
  dev_t initial_device = 0;
362
- bool try_with_dot_git = ((flags & GIT_REPOSITORY_OPEN_BARE) != 0);
363
- int ceiling_offset;
362
+ int min_iterations;
363
+ bool in_dot_git;
364
+ size_t ceiling_offset = 0;
364
365
 
365
366
  git_buf_free(repo_path);
366
367
 
367
368
  if ((error = git_path_prettify(&path, start_path, NULL)) < 0)
368
369
  return error;
369
370
 
370
- ceiling_offset = find_ceiling_dir_offset(path.ptr, ceiling_dirs);
371
+ /* in_dot_git toggles each loop:
372
+ * /a/b/c/.git, /a/b/c, /a/b/.git, /a/b, /a/.git, /a
373
+ * With GIT_REPOSITORY_OPEN_BARE, we assume we started with /a/b/c.git
374
+ * and don't append .git the first time through.
375
+ * min_iterations indicates the number of iterations left before going
376
+ * further counts as a search. */
377
+ if (flags & GIT_REPOSITORY_OPEN_BARE) {
378
+ in_dot_git = true;
379
+ min_iterations = 1;
380
+ } else {
381
+ in_dot_git = false;
382
+ min_iterations = 2;
383
+ }
371
384
 
372
- if (!try_with_dot_git &&
373
- (error = git_buf_joinpath(&path, path.ptr, DOT_GIT)) < 0)
374
- return error;
385
+ while (!error && (min_iterations || !(path.ptr[ceiling_offset] == 0 ||
386
+ (flags & GIT_REPOSITORY_OPEN_NO_SEARCH)))) {
387
+ if (!in_dot_git)
388
+ if ((error = git_buf_joinpath(&path, path.ptr, DOT_GIT)) < 0)
389
+ break;
390
+ in_dot_git = !in_dot_git;
375
391
 
376
- while (!error && !git_buf_len(repo_path)) {
377
392
  if (p_stat(path.ptr, &st) == 0) {
378
393
  /* check that we have not crossed device boundaries */
379
394
  if (initial_device == 0)
@@ -414,17 +429,10 @@ static int find_repo(
414
429
  break;
415
430
  }
416
431
 
417
- if (try_with_dot_git) {
418
- /* if we tried original dir with and without .git AND either hit
419
- * directory ceiling or NO_SEARCH was requested, then be done.
420
- */
421
- if (path.ptr[ceiling_offset] == '\0' ||
422
- (flags & GIT_REPOSITORY_OPEN_NO_SEARCH) != 0)
423
- break;
424
- /* otherwise look first for .git item */
425
- error = git_buf_joinpath(&path, path.ptr, DOT_GIT);
426
- }
427
- try_with_dot_git = !try_with_dot_git;
432
+ /* Once we've checked the directory (and .git if applicable),
433
+ * find the ceiling for a search. */
434
+ if (min_iterations && (--min_iterations == 0))
435
+ ceiling_offset = find_ceiling_dir_offset(path.ptr, ceiling_dirs);
428
436
  }
429
437
 
430
438
  if (!error && parent_path && !(flags & GIT_REPOSITORY_OPEN_BARE)) {
@@ -71,12 +71,18 @@ static int config_level_to_sysdir(int config_level)
71
71
  }
72
72
 
73
73
  extern char *git__user_agent;
74
+ extern char *git__ssl_ciphers;
74
75
 
75
76
  const char *git_libgit2__user_agent()
76
77
  {
77
78
  return git__user_agent;
78
79
  }
79
80
 
81
+ const char *git_libgit2__ssl_ciphers()
82
+ {
83
+ return git__ssl_ciphers;
84
+ }
85
+
80
86
  int git_libgit2_opts(int key, ...)
81
87
  {
82
88
  int error = 0;
@@ -169,7 +175,7 @@ int git_libgit2_opts(int key, ...)
169
175
  }
170
176
  }
171
177
  #else
172
- giterr_set(GITERR_NET, "Cannot set certificate locations: OpenSSL is not enabled");
178
+ giterr_set(GITERR_NET, "cannot set certificate locations: OpenSSL is not enabled");
173
179
  error = -1;
174
180
  #endif
175
181
  break;
@@ -187,6 +193,22 @@ int git_libgit2_opts(int key, ...)
187
193
  git_object__strict_input_validation = (va_arg(ap, int) != 0);
188
194
  break;
189
195
 
196
+ case GIT_OPT_SET_SSL_CIPHERS:
197
+ #ifdef GIT_OPENSSL
198
+ {
199
+ git__free(git__ssl_ciphers);
200
+ git__ssl_ciphers = git__strdup(va_arg(ap, const char *));
201
+ if (!git__ssl_ciphers) {
202
+ giterr_set_oom();
203
+ error = -1;
204
+ }
205
+ }
206
+ #else
207
+ giterr_set(GITERR_NET, "cannot set custom ciphers: OpenSSL is not enabled");
208
+ error = -1;
209
+ #endif
210
+ break;
211
+
190
212
  default:
191
213
  giterr_set(GITERR_INVALID, "invalid option key");
192
214
  error = -1;