rugged 0.23.0b2 → 0.23.0b4

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 (124) hide show
  1. checksums.yaml +4 -4
  2. data/ext/rugged/rugged_blob.c +39 -0
  3. data/ext/rugged/rugged_diff.c +7 -3
  4. data/ext/rugged/rugged_index.c +2 -2
  5. data/ext/rugged/rugged_remote.c +27 -148
  6. data/ext/rugged/rugged_remote_collection.c +134 -12
  7. data/ext/rugged/rugged_repo.c +74 -5
  8. data/ext/rugged/rugged_submodule.c +18 -208
  9. data/ext/rugged/rugged_submodule_collection.c +148 -0
  10. data/lib/rugged/version.rb +1 -1
  11. data/vendor/libgit2/AUTHORS +1 -0
  12. data/vendor/libgit2/CMakeLists.txt +33 -25
  13. data/vendor/libgit2/deps/winhttp/winhttp.def +29 -29
  14. data/vendor/libgit2/include/git2.h +1 -1
  15. data/vendor/libgit2/include/git2/blob.h +4 -6
  16. data/vendor/libgit2/include/git2/checkout.h +10 -1
  17. data/vendor/libgit2/include/git2/clone.h +6 -7
  18. data/vendor/libgit2/include/git2/commit.h +11 -0
  19. data/vendor/libgit2/include/git2/cred_helpers.h +2 -2
  20. data/vendor/libgit2/include/git2/describe.h +1 -1
  21. data/vendor/libgit2/include/git2/diff.h +68 -11
  22. data/vendor/libgit2/include/git2/errors.h +4 -1
  23. data/vendor/libgit2/include/git2/filter.h +16 -0
  24. data/vendor/libgit2/include/git2/index.h +38 -11
  25. data/vendor/libgit2/include/git2/odb.h +1 -1
  26. data/vendor/libgit2/include/git2/odb_backend.h +2 -2
  27. data/vendor/libgit2/include/git2/remote.h +300 -207
  28. data/vendor/libgit2/include/git2/reset.h +1 -0
  29. data/vendor/libgit2/include/git2/stash.h +135 -4
  30. data/vendor/libgit2/include/git2/status.h +1 -0
  31. data/vendor/libgit2/include/git2/submodule.h +46 -75
  32. data/vendor/libgit2/include/git2/sys/odb_backend.h +1 -1
  33. data/vendor/libgit2/include/git2/sys/stream.h +2 -0
  34. data/vendor/libgit2/include/git2/sys/transport.h +1 -21
  35. data/vendor/libgit2/include/git2/transport.h +27 -0
  36. data/vendor/libgit2/include/git2/types.h +20 -10
  37. data/vendor/libgit2/include/git2/version.h +3 -3
  38. data/vendor/libgit2/libgit2.pc.in +4 -2
  39. data/vendor/libgit2/src/attr.c +2 -1
  40. data/vendor/libgit2/src/attr_file.c +18 -37
  41. data/vendor/libgit2/src/blame.c +2 -2
  42. data/vendor/libgit2/src/blob.c +4 -3
  43. data/vendor/libgit2/src/branch.c +6 -3
  44. data/vendor/libgit2/src/buf_text.c +4 -6
  45. data/vendor/libgit2/src/buf_text.h +1 -2
  46. data/vendor/libgit2/src/buffer.c +8 -6
  47. data/vendor/libgit2/src/buffer.h +1 -1
  48. data/vendor/libgit2/src/cache.c +1 -0
  49. data/vendor/libgit2/src/checkout.c +34 -20
  50. data/vendor/libgit2/src/clone.c +29 -29
  51. data/vendor/libgit2/src/commit.c +65 -0
  52. data/vendor/libgit2/src/common.h +5 -0
  53. data/vendor/libgit2/src/config.c +20 -0
  54. data/vendor/libgit2/src/config.h +6 -0
  55. data/vendor/libgit2/src/config_file.c +2 -2
  56. data/vendor/libgit2/src/crlf.c +39 -17
  57. data/vendor/libgit2/src/curl_stream.c +257 -0
  58. data/vendor/libgit2/src/curl_stream.h +14 -0
  59. data/vendor/libgit2/src/diff.c +223 -88
  60. data/vendor/libgit2/src/diff.h +21 -1
  61. data/vendor/libgit2/src/diff_file.c +23 -13
  62. data/vendor/libgit2/src/diff_file.h +4 -2
  63. data/vendor/libgit2/src/diff_patch.c +266 -71
  64. data/vendor/libgit2/src/diff_patch.h +36 -0
  65. data/vendor/libgit2/src/diff_print.c +156 -126
  66. data/vendor/libgit2/src/diff_tform.c +32 -54
  67. data/vendor/libgit2/src/fetch.c +27 -10
  68. data/vendor/libgit2/src/fetch.h +2 -2
  69. data/vendor/libgit2/src/filebuf.c +1 -1
  70. data/vendor/libgit2/src/fileops.c +6 -2
  71. data/vendor/libgit2/src/filter.c +28 -7
  72. data/vendor/libgit2/src/fnmatch.c +5 -5
  73. data/vendor/libgit2/src/global.c +16 -0
  74. data/vendor/libgit2/src/ident.c +2 -2
  75. data/vendor/libgit2/src/ignore.c +1 -0
  76. data/vendor/libgit2/src/index.c +338 -80
  77. data/vendor/libgit2/src/index.h +4 -1
  78. data/vendor/libgit2/src/indexer.c +19 -5
  79. data/vendor/libgit2/src/iterator.c +118 -11
  80. data/vendor/libgit2/src/iterator.h +25 -0
  81. data/vendor/libgit2/src/merge.c +96 -106
  82. data/vendor/libgit2/src/merge.h +14 -4
  83. data/vendor/libgit2/src/netops.c +3 -3
  84. data/vendor/libgit2/src/odb.c +17 -9
  85. data/vendor/libgit2/src/odb.h +1 -1
  86. data/vendor/libgit2/src/odb_loose.c +2 -2
  87. data/vendor/libgit2/src/odb_pack.c +1 -1
  88. data/vendor/libgit2/src/openssl_stream.c +118 -27
  89. data/vendor/libgit2/src/pack-objects.c +28 -0
  90. data/vendor/libgit2/src/pack-objects.h +1 -0
  91. data/vendor/libgit2/src/pack.c +18 -10
  92. data/vendor/libgit2/src/path.c +16 -11
  93. data/vendor/libgit2/src/path.h +1 -1
  94. data/vendor/libgit2/src/push.c +26 -42
  95. data/vendor/libgit2/src/push.h +2 -34
  96. data/vendor/libgit2/src/rebase.c +1 -1
  97. data/vendor/libgit2/src/refs.c +1 -1
  98. data/vendor/libgit2/src/refspec.c +6 -0
  99. data/vendor/libgit2/src/remote.c +381 -274
  100. data/vendor/libgit2/src/remote.h +0 -4
  101. data/vendor/libgit2/src/repository.c +33 -12
  102. data/vendor/libgit2/src/repository.h +0 -1
  103. data/vendor/libgit2/src/reset.c +1 -0
  104. data/vendor/libgit2/src/stash.c +439 -17
  105. data/vendor/libgit2/src/status.c +6 -0
  106. data/vendor/libgit2/src/stransport_stream.c +58 -21
  107. data/vendor/libgit2/src/stream.h +15 -0
  108. data/vendor/libgit2/src/submodule.c +410 -664
  109. data/vendor/libgit2/src/submodule.h +0 -24
  110. data/vendor/libgit2/src/transaction.c +1 -0
  111. data/vendor/libgit2/src/transports/cred.c +55 -1
  112. data/vendor/libgit2/src/transports/http.c +18 -2
  113. data/vendor/libgit2/src/transports/local.c +60 -59
  114. data/vendor/libgit2/src/transports/smart.h +1 -1
  115. data/vendor/libgit2/src/transports/smart_protocol.c +11 -11
  116. data/vendor/libgit2/src/transports/ssh.c +46 -7
  117. data/vendor/libgit2/src/unix/posix.h +4 -0
  118. data/vendor/libgit2/src/util.c +9 -9
  119. data/vendor/libgit2/src/util.h +9 -0
  120. data/vendor/libgit2/src/win32/posix.h +3 -0
  121. data/vendor/libgit2/src/win32/posix_w32.c +38 -0
  122. data/vendor/libgit2/src/win32/w32_util.h +10 -0
  123. metadata +4 -3
  124. data/vendor/libgit2/include/git2/push.h +0 -94
@@ -15,7 +15,7 @@
15
15
  #include "fileops.h"
16
16
  #include "config.h"
17
17
 
18
- static git_diff_delta *diff_delta__dup(
18
+ git_diff_delta *git_diff__delta_dup(
19
19
  const git_diff_delta *d, git_pool *pool)
20
20
  {
21
21
  git_diff_delta *delta = git__malloc(sizeof(git_diff_delta));
@@ -46,7 +46,7 @@ fail:
46
46
  return NULL;
47
47
  }
48
48
 
49
- static git_diff_delta *diff_delta__merge_like_cgit(
49
+ git_diff_delta *git_diff__merge_like_cgit(
50
50
  const git_diff_delta *a,
51
51
  const git_diff_delta *b,
52
52
  git_pool *pool)
@@ -65,19 +65,26 @@ static git_diff_delta *diff_delta__merge_like_cgit(
65
65
  * f3 = b->new_file
66
66
  */
67
67
 
68
+ /* If one of the diffs is a conflict, just dup it */
69
+ if (b->status == GIT_DELTA_CONFLICTED)
70
+ return git_diff__delta_dup(b, pool);
71
+ if (a->status == GIT_DELTA_CONFLICTED)
72
+ return git_diff__delta_dup(a, pool);
73
+
68
74
  /* if f2 == f3 or f2 is deleted, then just dup the 'a' diff */
69
75
  if (b->status == GIT_DELTA_UNMODIFIED || a->status == GIT_DELTA_DELETED)
70
- return diff_delta__dup(a, pool);
76
+ return git_diff__delta_dup(a, pool);
71
77
 
72
78
  /* otherwise, base this diff on the 'b' diff */
73
- if ((dup = diff_delta__dup(b, pool)) == NULL)
79
+ if ((dup = git_diff__delta_dup(b, pool)) == NULL)
74
80
  return NULL;
75
81
 
76
82
  /* If 'a' status is uninteresting, then we're done */
77
- if (a->status == GIT_DELTA_UNMODIFIED)
83
+ if (a->status == GIT_DELTA_UNMODIFIED ||
84
+ a->status == GIT_DELTA_UNTRACKED ||
85
+ a->status == GIT_DELTA_UNREADABLE)
78
86
  return dup;
79
87
 
80
- assert(a->status != GIT_DELTA_UNMODIFIED);
81
88
  assert(b->status != GIT_DELTA_UNMODIFIED);
82
89
 
83
90
  /* A cgit exception is that the diff of a file that is only in the
@@ -102,43 +109,8 @@ static git_diff_delta *diff_delta__merge_like_cgit(
102
109
  return dup;
103
110
  }
104
111
 
105
- static git_diff_delta *diff_delta__merge_like_cgit_reversed(
106
- const git_diff_delta *a,
107
- const git_diff_delta *b,
108
- git_pool *pool)
109
- {
110
- git_diff_delta *dup;
111
-
112
- /* reversed version of above logic */
113
-
114
- if (a->status == GIT_DELTA_UNMODIFIED)
115
- return diff_delta__dup(b, pool);
116
-
117
- if ((dup = diff_delta__dup(a, pool)) == NULL)
118
- return NULL;
119
-
120
- if (b->status == GIT_DELTA_UNMODIFIED || b->status == GIT_DELTA_UNTRACKED || b->status == GIT_DELTA_UNREADABLE)
121
- return dup;
122
-
123
- if (dup->status == GIT_DELTA_DELETED) {
124
- if (b->status == GIT_DELTA_ADDED) {
125
- dup->status = GIT_DELTA_UNMODIFIED;
126
- dup->nfiles = 2;
127
- }
128
- } else {
129
- dup->status = b->status;
130
- dup->nfiles = b->nfiles;
131
- }
132
-
133
- git_oid_cpy(&dup->old_file.id, &b->old_file.id);
134
- dup->old_file.mode = b->old_file.mode;
135
- dup->old_file.size = b->old_file.size;
136
- dup->old_file.flags = b->old_file.flags;
137
-
138
- return dup;
139
- }
140
-
141
- int git_diff_merge(git_diff *onto, const git_diff *from)
112
+ int git_diff__merge(
113
+ git_diff *onto, const git_diff *from, git_diff__merge_cb cb)
142
114
  {
143
115
  int error = 0;
144
116
  git_pool onto_pool;
@@ -174,15 +146,16 @@ int git_diff_merge(git_diff *onto, const git_diff *from)
174
146
  STRCMP_CASESELECT(ignore_case, o->old_file.path, f->old_file.path);
175
147
 
176
148
  if (cmp < 0) {
177
- delta = diff_delta__dup(o, &onto_pool);
149
+ delta = git_diff__delta_dup(o, &onto_pool);
178
150
  i++;
179
151
  } else if (cmp > 0) {
180
- delta = diff_delta__dup(f, &onto_pool);
152
+ delta = git_diff__delta_dup(f, &onto_pool);
181
153
  j++;
182
154
  } else {
183
- delta = reversed ?
184
- diff_delta__merge_like_cgit_reversed(o, f, &onto_pool) :
185
- diff_delta__merge_like_cgit(o, f, &onto_pool);
155
+ const git_diff_delta *left = reversed ? f : o;
156
+ const git_diff_delta *right = reversed ? o : f;
157
+
158
+ delta = cb(left, right, &onto_pool);
186
159
  i++;
187
160
  j++;
188
161
  }
@@ -190,7 +163,7 @@ int git_diff_merge(git_diff *onto, const git_diff *from)
190
163
  /* the ignore rules for the target may not match the source
191
164
  * or the result of a merged delta could be skippable...
192
165
  */
193
- if (git_diff_delta__should_skip(&onto->opts, delta)) {
166
+ if (delta && git_diff_delta__should_skip(&onto->opts, delta)) {
194
167
  git__free(delta);
195
168
  continue;
196
169
  }
@@ -221,6 +194,11 @@ int git_diff_merge(git_diff *onto, const git_diff *from)
221
194
  return error;
222
195
  }
223
196
 
197
+ int git_diff_merge(git_diff *onto, const git_diff *from)
198
+ {
199
+ return git_diff__merge(onto, from, git_diff__merge_like_cgit);
200
+ }
201
+
224
202
  int git_diff_find_similar__hashsig_for_file(
225
203
  void **out, const git_diff_file *f, const char *path, void *p)
226
204
  {
@@ -369,7 +347,7 @@ static int insert_delete_side_of_split(
369
347
  git_diff *diff, git_vector *onto, const git_diff_delta *delta)
370
348
  {
371
349
  /* make new record for DELETED side of split */
372
- git_diff_delta *deleted = diff_delta__dup(delta, &diff->pool);
350
+ git_diff_delta *deleted = git_diff__delta_dup(delta, &diff->pool);
373
351
  GITERR_CHECK_ALLOC(deleted);
374
352
 
375
353
  deleted->status = GIT_DELTA_DELETED;
@@ -676,11 +654,13 @@ static bool is_rename_target(
676
654
  return false;
677
655
 
678
656
  /* only consider ADDED, RENAMED, COPIED, and split MODIFIED as
679
- * targets; maybe include UNTRACKED and IGNORED if requested.
657
+ * targets; maybe include UNTRACKED if requested.
680
658
  */
681
659
  switch (delta->status) {
682
660
  case GIT_DELTA_UNMODIFIED:
683
661
  case GIT_DELTA_DELETED:
662
+ case GIT_DELTA_IGNORED:
663
+ case GIT_DELTA_CONFLICTED:
684
664
  return false;
685
665
 
686
666
  case GIT_DELTA_MODIFIED:
@@ -707,9 +687,6 @@ static bool is_rename_target(
707
687
  return false;
708
688
  break;
709
689
 
710
- case GIT_DELTA_IGNORED:
711
- return false;
712
-
713
690
  default: /* all other status values should be checked */
714
691
  break;
715
692
  }
@@ -735,6 +712,7 @@ static bool is_rename_source(
735
712
  case GIT_DELTA_UNTRACKED:
736
713
  case GIT_DELTA_UNREADABLE:
737
714
  case GIT_DELTA_IGNORED:
715
+ case GIT_DELTA_CONFLICTED:
738
716
  return false;
739
717
 
740
718
  case GIT_DELTA_DELETED:
@@ -19,14 +19,14 @@
19
19
  #include "repository.h"
20
20
  #include "refs.h"
21
21
 
22
- static int maybe_want(git_remote *remote, git_remote_head *head, git_odb *odb, git_refspec *tagspec)
22
+ static int maybe_want(git_remote *remote, git_remote_head *head, git_odb *odb, git_refspec *tagspec, git_remote_autotag_option_t tagopt)
23
23
  {
24
24
  int match = 0;
25
25
 
26
26
  if (!git_reference_is_valid_name(head->name))
27
27
  return 0;
28
28
 
29
- if (remote->download_tags == GIT_REMOTE_DOWNLOAD_TAGS_ALL) {
29
+ if (tagopt == GIT_REMOTE_DOWNLOAD_TAGS_ALL) {
30
30
  /*
31
31
  * If tagopt is --tags, always request tags
32
32
  * in addition to the remote's refspecs
@@ -51,13 +51,17 @@ static int maybe_want(git_remote *remote, git_remote_head *head, git_odb *odb, g
51
51
  return git_vector_insert(&remote->refs, head);
52
52
  }
53
53
 
54
- static int filter_wants(git_remote *remote)
54
+ static int filter_wants(git_remote *remote, const git_fetch_options *opts)
55
55
  {
56
56
  git_remote_head **heads;
57
57
  git_refspec tagspec, head;
58
58
  int error = 0;
59
59
  git_odb *odb;
60
60
  size_t i, heads_len;
61
+ git_remote_autotag_option_t tagopt = remote->download_tags;
62
+
63
+ if (opts && opts->download_tags != GIT_REMOTE_DOWNLOAD_TAGS_UNSPECIFIED)
64
+ tagopt = opts->download_tags;
61
65
 
62
66
  git_vector_clear(&remote->refs);
63
67
  if ((error = git_refspec__parse(&tagspec, GIT_REFSPEC_TAGS, true)) < 0)
@@ -87,7 +91,7 @@ static int filter_wants(git_remote *remote)
87
91
  goto cleanup;
88
92
 
89
93
  for (i = 0; i < heads_len; i++) {
90
- if ((error = maybe_want(remote, heads[i], odb, &tagspec)) < 0)
94
+ if ((error = maybe_want(remote, heads[i], odb, &tagspec, tagopt)) < 0)
91
95
  break;
92
96
  }
93
97
 
@@ -102,13 +106,13 @@ cleanup:
102
106
  * them out. When we get an ACK we hide that commit and continue
103
107
  * traversing until we're done
104
108
  */
105
- int git_fetch_negotiate(git_remote *remote)
109
+ int git_fetch_negotiate(git_remote *remote, const git_fetch_options *opts)
106
110
  {
107
111
  git_transport *t = remote->transport;
108
112
 
109
- remote->need_pack = 0;
113
+ remote->need_pack = 0;
110
114
 
111
- if (filter_wants(remote) < 0) {
115
+ if (filter_wants(remote, opts) < 0) {
112
116
  giterr_set(GITERR_NET, "Failed to filter the reference list for wants");
113
117
  return -1;
114
118
  }
@@ -127,13 +131,26 @@ int git_fetch_negotiate(git_remote *remote)
127
131
  remote->refs.length);
128
132
  }
129
133
 
130
- int git_fetch_download_pack(git_remote *remote)
134
+ int git_fetch_download_pack(git_remote *remote, const git_remote_callbacks *callbacks)
131
135
  {
132
136
  git_transport *t = remote->transport;
137
+ git_transfer_progress_cb progress = NULL;
138
+ void *payload = NULL;
133
139
 
134
140
  if (!remote->need_pack)
135
141
  return 0;
136
142
 
137
- return t->download_pack(t, remote->repo, &remote->stats,
138
- remote->callbacks.transfer_progress, remote->callbacks.payload);
143
+ if (callbacks) {
144
+ progress = callbacks->transfer_progress;
145
+ payload = callbacks->payload;
146
+ }
147
+
148
+ return t->download_pack(t, remote->repo, &remote->stats, progress, payload);
149
+ }
150
+
151
+ int git_fetch_init_options(git_fetch_options *opts, unsigned int version)
152
+ {
153
+ GIT_INIT_STRUCTURE_FROM_TEMPLATE(
154
+ opts, version, git_fetch_options, GIT_FETCH_OPTIONS_INIT);
155
+ return 0;
139
156
  }
@@ -9,9 +9,9 @@
9
9
 
10
10
  #include "netops.h"
11
11
 
12
- int git_fetch_negotiate(git_remote *remote);
12
+ int git_fetch_negotiate(git_remote *remote, const git_fetch_options *opts);
13
13
 
14
- int git_fetch_download_pack(git_remote *remote);
14
+ int git_fetch_download_pack(git_remote *remote, const git_remote_callbacks *callbacks);
15
15
 
16
16
  int git_fetch__download_pack(
17
17
  git_transport *t,
@@ -68,7 +68,7 @@ static int lock_file(git_filebuf *file, int flags, mode_t mode)
68
68
 
69
69
  if ((flags & GIT_FILEBUF_APPEND) && git_path_exists(file->path_original) == true) {
70
70
  git_file source;
71
- char buffer[2048];
71
+ char buffer[FILEIO_BUFSIZE];
72
72
  ssize_t read_bytes;
73
73
 
74
74
  source = p_open(file->path_original, O_RDONLY);
@@ -689,7 +689,7 @@ int git_futils_fake_symlink(const char *old, const char *new)
689
689
  static int cp_by_fd(int ifd, int ofd, bool close_fd_when_done)
690
690
  {
691
691
  int error = 0;
692
- char buffer[4096];
692
+ char buffer[FILEIO_BUFSIZE];
693
693
  ssize_t len = 0;
694
694
 
695
695
  while (!error && (len = p_read(ifd, buffer, sizeof(buffer))) > 0)
@@ -703,6 +703,9 @@ static int cp_by_fd(int ifd, int ofd, bool close_fd_when_done)
703
703
  error = (int)len;
704
704
  }
705
705
 
706
+ if (error < 0)
707
+ giterr_set(GITERR_OS, "write error while copying file");
708
+
706
709
  if (close_fd_when_done) {
707
710
  p_close(ifd);
708
711
  p_close(ofd);
@@ -861,7 +864,8 @@ static int _cp_r_callback(void *ref, git_buf *from)
861
864
 
862
865
  /* make symlink or regular file */
863
866
  if (info->flags & GIT_CPDIR_LINK_FILES) {
864
- error = p_link(from->ptr, info->to.ptr);
867
+ if ((error = p_link(from->ptr, info->to.ptr)) < 0)
868
+ giterr_set(GITERR_OS, "failed to link '%s'", from->ptr);
865
869
  } else if (S_ISLNK(from_st.st_mode)) {
866
870
  error = cp_link(from->ptr, info->to.ptr, (size_t)from_st.st_size);
867
871
  } else {
@@ -27,6 +27,7 @@ struct git_filter_source {
27
27
  };
28
28
 
29
29
  typedef struct {
30
+ const char *filter_name;
30
31
  git_filter *filter;
31
32
  void *payload;
32
33
  } git_filter_entry;
@@ -526,7 +527,9 @@ int git_filter_list__load_ext(
526
527
 
527
528
  fe = git_array_alloc(fl->filters);
528
529
  GITERR_CHECK_ALLOC(fe);
529
- fe->filter = fdef->filter;
530
+
531
+ fe->filter = fdef->filter;
532
+ fe->filter_name = fdef->filter_name;
530
533
  fe->payload = payload;
531
534
  }
532
535
  }
@@ -574,6 +577,25 @@ void git_filter_list_free(git_filter_list *fl)
574
577
  git__free(fl);
575
578
  }
576
579
 
580
+ int git_filter_list_contains(
581
+ git_filter_list *fl,
582
+ const char *name)
583
+ {
584
+ size_t i;
585
+
586
+ assert(name);
587
+
588
+ if (!fl)
589
+ return 0;
590
+
591
+ for (i = 0; i < fl->filters.size; i++) {
592
+ if (strcmp(fl->filters.ptr[i].filter_name, name) == 0)
593
+ return 1;
594
+ }
595
+
596
+ return 0;
597
+ }
598
+
577
599
  int git_filter_list_push(
578
600
  git_filter_list *fl, git_filter *filter, void *payload)
579
601
  {
@@ -875,21 +897,19 @@ void stream_list_free(git_vector *streams)
875
897
  git_vector_free(streams);
876
898
  }
877
899
 
878
- #define STREAM_BUFSIZE 10240
879
-
880
900
  int git_filter_list_stream_file(
881
901
  git_filter_list *filters,
882
902
  git_repository *repo,
883
903
  const char *path,
884
904
  git_writestream *target)
885
905
  {
886
- char buf[STREAM_BUFSIZE];
906
+ char buf[FILTERIO_BUFSIZE];
887
907
  git_buf abspath = GIT_BUF_INIT;
888
908
  const char *base = repo ? git_repository_workdir(repo) : NULL;
889
909
  git_vector filter_streams = GIT_VECTOR_INIT;
890
910
  git_writestream *stream_start;
891
911
  ssize_t readlen;
892
- int fd, error;
912
+ int fd = -1, error;
893
913
 
894
914
  if ((error = stream_list_init(
895
915
  &stream_start, &filter_streams, filters, target)) < 0 ||
@@ -901,7 +921,7 @@ int git_filter_list_stream_file(
901
921
  goto done;
902
922
  }
903
923
 
904
- while ((readlen = p_read(fd, buf, STREAM_BUFSIZE)) > 0) {
924
+ while ((readlen = p_read(fd, buf, sizeof(buf))) > 0) {
905
925
  if ((error = stream_start->write(stream_start, buf, readlen)) < 0)
906
926
  goto done;
907
927
  }
@@ -911,9 +931,10 @@ int git_filter_list_stream_file(
911
931
  else if (readlen < 0)
912
932
  error = readlen;
913
933
 
914
- p_close(fd);
915
934
 
916
935
  done:
936
+ if (fd >= 0)
937
+ p_close(fd);
917
938
  stream_list_free(&filter_streams);
918
939
  git_buf_free(&abspath);
919
940
  return error;
@@ -164,8 +164,8 @@ p_fnmatchx(const char *pattern, const char *string, int flags, size_t recurs)
164
164
  default:
165
165
  normal:
166
166
  if (c != *string && !((flags & FNM_CASEFOLD) &&
167
- (tolower((unsigned char)c) ==
168
- tolower((unsigned char)*string))))
167
+ (git__tolower((unsigned char)c) ==
168
+ git__tolower((unsigned char)*string))))
169
169
  return (FNM_NOMATCH);
170
170
  ++string;
171
171
  break;
@@ -190,7 +190,7 @@ rangematch(const char *pattern, char test, int flags, char **newp)
190
190
  ++pattern;
191
191
 
192
192
  if (flags & FNM_CASEFOLD)
193
- test = (char)tolower((unsigned char)test);
193
+ test = (char)git__tolower((unsigned char)test);
194
194
 
195
195
  /*
196
196
  * A right bracket shall lose its special meaning and represent
@@ -207,7 +207,7 @@ rangematch(const char *pattern, char test, int flags, char **newp)
207
207
  if (c == '/' && (flags & FNM_PATHNAME))
208
208
  return (RANGE_NOMATCH);
209
209
  if ((flags & FNM_CASEFOLD))
210
- c = (char)tolower((unsigned char)c);
210
+ c = (char)git__tolower((unsigned char)c);
211
211
  if (*pattern == '-'
212
212
  && (c2 = *(pattern+1)) != EOS && c2 != ']') {
213
213
  pattern += 2;
@@ -216,7 +216,7 @@ rangematch(const char *pattern, char test, int flags, char **newp)
216
216
  if (c2 == EOS)
217
217
  return (RANGE_ERROR);
218
218
  if (flags & FNM_CASEFOLD)
219
- c2 = (char)tolower((unsigned char)c2);
219
+ c2 = (char)git__tolower((unsigned char)c2);
220
220
  if (c <= test && test <= c2)
221
221
  ok = 1;
222
222
  } else if (c == test)
@@ -116,6 +116,20 @@ static void init_ssl(void)
116
116
  #endif
117
117
  }
118
118
 
119
+ /**
120
+ * This function aims to clean-up the SSL context which
121
+ * we allocated.
122
+ */
123
+ static void uninit_ssl(void)
124
+ {
125
+ #ifdef GIT_OPENSSL
126
+ if (git__ssl_ctx) {
127
+ SSL_CTX_free(git__ssl_ctx);
128
+ git__ssl_ctx = NULL;
129
+ }
130
+ #endif
131
+ }
132
+
119
133
  int git_openssl_set_locking(void)
120
134
  {
121
135
  #ifdef GIT_OPENSSL
@@ -333,6 +347,7 @@ int git_libgit2_shutdown(void)
333
347
 
334
348
  /* Shut down any subsystems that have global state */
335
349
  git__shutdown();
350
+ uninit_ssl();
336
351
 
337
352
  ptr = pthread_getspecific(_tls_key);
338
353
  pthread_setspecific(_tls_key, NULL);
@@ -391,6 +406,7 @@ int git_libgit2_shutdown(void)
391
406
 
392
407
  git__shutdown();
393
408
  git__global_state_cleanup(&__state);
409
+ uninit_ssl();
394
410
 
395
411
  return 0;
396
412
  }