rugged 0.21.4 → 0.22.0b1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (224) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +12 -5
  3. data/ext/rugged/extconf.rb +9 -9
  4. data/ext/rugged/rugged.c +4 -2
  5. data/ext/rugged/rugged.h +3 -7
  6. data/ext/rugged/rugged_blob.c +57 -0
  7. data/ext/rugged/rugged_cred.c +23 -0
  8. data/ext/rugged/rugged_index.c +6 -2
  9. data/ext/rugged/rugged_remote.c +65 -52
  10. data/ext/rugged/rugged_remote_collection.c +59 -10
  11. data/ext/rugged/rugged_repo.c +345 -11
  12. data/ext/rugged/rugged_revwalk.c +10 -0
  13. data/ext/rugged/rugged_submodule.c +1042 -0
  14. data/ext/rugged/rugged_submodule_collection.c +236 -0
  15. data/ext/rugged/rugged_tag_collection.c +70 -2
  16. data/ext/rugged/rugged_tree.c +29 -10
  17. data/lib/rugged.rb +3 -0
  18. data/lib/rugged/attributes.rb +41 -0
  19. data/lib/rugged/blob.rb +28 -0
  20. data/lib/rugged/diff.rb +0 -1
  21. data/lib/rugged/diff/line.rb +1 -3
  22. data/lib/rugged/patch.rb +12 -2
  23. data/lib/rugged/repository.rb +7 -0
  24. data/lib/rugged/submodule_collection.rb +48 -0
  25. data/lib/rugged/version.rb +1 -1
  26. data/vendor/libgit2/CMakeLists.txt +27 -3
  27. data/vendor/libgit2/cmake/Modules/FindGSSAPI.cmake +324 -0
  28. data/vendor/libgit2/deps/http-parser/http_parser.h +2 -0
  29. data/vendor/libgit2/deps/zlib/adler32.c +39 -29
  30. data/vendor/libgit2/deps/zlib/crc32.c +33 -50
  31. data/vendor/libgit2/deps/zlib/crc32.h +1 -1
  32. data/vendor/libgit2/deps/zlib/deflate.c +198 -65
  33. data/vendor/libgit2/deps/zlib/deflate.h +8 -4
  34. data/vendor/libgit2/deps/zlib/infback.c +640 -0
  35. data/vendor/libgit2/deps/zlib/inffast.c +3 -3
  36. data/vendor/libgit2/deps/zlib/inffixed.h +3 -3
  37. data/vendor/libgit2/deps/zlib/inflate.c +84 -52
  38. data/vendor/libgit2/deps/zlib/inftrees.c +15 -39
  39. data/vendor/libgit2/deps/zlib/trees.c +18 -36
  40. data/vendor/libgit2/deps/zlib/zconf.h +4 -0
  41. data/vendor/libgit2/deps/zlib/zlib.h +250 -95
  42. data/vendor/libgit2/deps/zlib/zutil.c +13 -10
  43. data/vendor/libgit2/deps/zlib/zutil.h +41 -62
  44. data/vendor/libgit2/include/git2.h +4 -0
  45. data/vendor/libgit2/include/git2/annotated_commit.h +99 -0
  46. data/vendor/libgit2/include/git2/attr.h +16 -13
  47. data/vendor/libgit2/include/git2/branch.h +11 -0
  48. data/vendor/libgit2/include/git2/buffer.h +16 -0
  49. data/vendor/libgit2/include/git2/checkout.h +12 -12
  50. data/vendor/libgit2/include/git2/cherrypick.h +15 -15
  51. data/vendor/libgit2/include/git2/clone.h +77 -69
  52. data/vendor/libgit2/include/git2/common.h +13 -1
  53. data/vendor/libgit2/include/git2/config.h +0 -14
  54. data/vendor/libgit2/include/git2/describe.h +162 -0
  55. data/vendor/libgit2/include/git2/diff.h +13 -8
  56. data/vendor/libgit2/include/git2/errors.h +5 -0
  57. data/vendor/libgit2/include/git2/global.h +38 -0
  58. data/vendor/libgit2/include/git2/merge.h +38 -64
  59. data/vendor/libgit2/include/git2/net.h +2 -2
  60. data/vendor/libgit2/include/git2/notes.h +17 -0
  61. data/vendor/libgit2/include/git2/oid.h +8 -4
  62. data/vendor/libgit2/include/git2/oidarray.h +40 -0
  63. data/vendor/libgit2/include/git2/rebase.h +261 -0
  64. data/vendor/libgit2/include/git2/reflog.h +1 -1
  65. data/vendor/libgit2/include/git2/remote.h +25 -47
  66. data/vendor/libgit2/include/git2/repository.h +4 -1
  67. data/vendor/libgit2/include/git2/reset.h +10 -1
  68. data/vendor/libgit2/include/git2/revert.h +1 -1
  69. data/vendor/libgit2/include/git2/revwalk.h +28 -23
  70. data/vendor/libgit2/include/git2/status.h +19 -15
  71. data/vendor/libgit2/include/git2/submodule.h +18 -0
  72. data/vendor/libgit2/include/git2/sys/config.h +0 -1
  73. data/vendor/libgit2/{src → include/git2/sys}/hashsig.h +11 -7
  74. data/vendor/libgit2/include/git2/sys/refdb_backend.h +13 -0
  75. data/vendor/libgit2/include/git2/sys/refs.h +0 -11
  76. data/vendor/libgit2/include/git2/sys/repository.h +13 -0
  77. data/vendor/libgit2/include/git2/sys/transport.h +352 -0
  78. data/vendor/libgit2/include/git2/threads.h +10 -20
  79. data/vendor/libgit2/include/git2/transaction.h +111 -0
  80. data/vendor/libgit2/include/git2/transport.h +79 -313
  81. data/vendor/libgit2/include/git2/tree.h +4 -2
  82. data/vendor/libgit2/include/git2/types.h +77 -8
  83. data/vendor/libgit2/include/git2/version.h +2 -2
  84. data/vendor/libgit2/src/annotated_commit.c +121 -0
  85. data/vendor/libgit2/src/annotated_commit.h +22 -0
  86. data/vendor/libgit2/src/attr.c +8 -4
  87. data/vendor/libgit2/src/attr_file.c +24 -2
  88. data/vendor/libgit2/src/blame.c +0 -1
  89. data/vendor/libgit2/src/branch.c +32 -3
  90. data/vendor/libgit2/src/buf_text.c +9 -5
  91. data/vendor/libgit2/src/buf_text.h +3 -2
  92. data/vendor/libgit2/src/buffer.c +67 -10
  93. data/vendor/libgit2/src/buffer.h +4 -2
  94. data/vendor/libgit2/src/cache.c +9 -9
  95. data/vendor/libgit2/src/cache.h +1 -1
  96. data/vendor/libgit2/src/cc-compat.h +2 -0
  97. data/vendor/libgit2/src/checkout.c +263 -82
  98. data/vendor/libgit2/src/checkout.h +1 -0
  99. data/vendor/libgit2/src/cherrypick.c +41 -44
  100. data/vendor/libgit2/src/clone.c +96 -58
  101. data/vendor/libgit2/src/commit.c +5 -31
  102. data/vendor/libgit2/src/commit_list.h +3 -1
  103. data/vendor/libgit2/src/config.c +0 -17
  104. data/vendor/libgit2/src/config_cache.c +0 -2
  105. data/vendor/libgit2/src/config_file.c +12 -15
  106. data/vendor/libgit2/src/crlf.c +2 -1
  107. data/vendor/libgit2/src/describe.c +886 -0
  108. data/vendor/libgit2/src/diff.c +29 -3
  109. data/vendor/libgit2/src/diff_file.c +1 -0
  110. data/vendor/libgit2/src/diff_patch.c +2 -3
  111. data/vendor/libgit2/src/diff_print.c +11 -9
  112. data/vendor/libgit2/src/diff_tform.c +4 -4
  113. data/vendor/libgit2/src/errors.c +9 -7
  114. data/vendor/libgit2/src/fetch.c +6 -6
  115. data/vendor/libgit2/src/fetchhead.h +2 -4
  116. data/vendor/libgit2/src/filebuf.c +0 -2
  117. data/vendor/libgit2/src/filebuf.h +2 -3
  118. data/vendor/libgit2/src/fileops.c +9 -7
  119. data/vendor/libgit2/src/global.c +44 -35
  120. data/vendor/libgit2/src/global.h +2 -0
  121. data/vendor/libgit2/src/graph.c +2 -2
  122. data/vendor/libgit2/src/hash.h +3 -1
  123. data/vendor/libgit2/src/hash/hash_common_crypto.h +44 -0
  124. data/vendor/libgit2/src/hash/hash_win32.c +1 -1
  125. data/vendor/libgit2/src/hashsig.c +1 -1
  126. data/vendor/libgit2/src/ignore.c +5 -88
  127. data/vendor/libgit2/src/index.c +70 -57
  128. data/vendor/libgit2/src/index.h +1 -0
  129. data/vendor/libgit2/src/indexer.c +16 -5
  130. data/vendor/libgit2/src/iterator.c +70 -1
  131. data/vendor/libgit2/src/iterator.h +5 -1
  132. data/vendor/libgit2/src/map.h +0 -1
  133. data/vendor/libgit2/src/merge.c +203 -327
  134. data/vendor/libgit2/src/merge.h +3 -13
  135. data/vendor/libgit2/src/mwindow.c +119 -8
  136. data/vendor/libgit2/src/mwindow.h +9 -1
  137. data/vendor/libgit2/src/netops.c +7 -8
  138. data/vendor/libgit2/src/netops.h +6 -16
  139. data/vendor/libgit2/src/notes.c +31 -4
  140. data/vendor/libgit2/src/notes.h +3 -0
  141. data/vendor/libgit2/src/odb.c +23 -1
  142. data/vendor/libgit2/src/odb_loose.c +1 -1
  143. data/vendor/libgit2/src/odb_pack.c +6 -3
  144. data/vendor/libgit2/src/oid.c +9 -1
  145. data/vendor/libgit2/src/oid.h +11 -0
  146. data/vendor/libgit2/src/oidarray.c +21 -0
  147. data/vendor/libgit2/src/oidarray.h +18 -0
  148. data/vendor/libgit2/src/oidmap.h +16 -0
  149. data/vendor/libgit2/src/pack.c +20 -7
  150. data/vendor/libgit2/src/pack.h +3 -0
  151. data/vendor/libgit2/src/path.c +120 -293
  152. data/vendor/libgit2/src/path.h +21 -44
  153. data/vendor/libgit2/src/pathspec.c +1 -1
  154. data/vendor/libgit2/src/pool.c +5 -11
  155. data/vendor/libgit2/src/pool.h +0 -2
  156. data/vendor/libgit2/src/posix.c +6 -6
  157. data/vendor/libgit2/src/posix.h +48 -28
  158. data/vendor/libgit2/src/push.c +19 -48
  159. data/vendor/libgit2/src/push.h +2 -4
  160. data/vendor/libgit2/src/rebase.c +1125 -0
  161. data/vendor/libgit2/src/refdb.c +19 -0
  162. data/vendor/libgit2/src/refdb.h +2 -1
  163. data/vendor/libgit2/src/refdb_fs.c +101 -29
  164. data/vendor/libgit2/src/reflog.c +1 -1
  165. data/vendor/libgit2/src/refs.c +38 -3
  166. data/vendor/libgit2/src/refs.h +13 -2
  167. data/vendor/libgit2/src/refspec.c +20 -2
  168. data/vendor/libgit2/src/remote.c +288 -154
  169. data/vendor/libgit2/src/remote.h +5 -1
  170. data/vendor/libgit2/src/repository.c +75 -36
  171. data/vendor/libgit2/src/repository.h +3 -25
  172. data/vendor/libgit2/src/reset.c +5 -1
  173. data/vendor/libgit2/src/revert.c +4 -6
  174. data/vendor/libgit2/src/revparse.c +15 -18
  175. data/vendor/libgit2/src/revwalk.c +96 -22
  176. data/vendor/libgit2/src/revwalk.h +5 -4
  177. data/vendor/libgit2/src/settings.c +22 -0
  178. data/vendor/libgit2/src/signature.c +37 -2
  179. data/vendor/libgit2/src/signature.h +3 -0
  180. data/vendor/libgit2/src/stash.c +17 -12
  181. data/vendor/libgit2/src/status.c +13 -3
  182. data/vendor/libgit2/src/strnlen.h +2 -1
  183. data/vendor/libgit2/src/submodule.c +75 -35
  184. data/vendor/libgit2/src/thread-utils.h +4 -9
  185. data/vendor/libgit2/src/trace.h +9 -1
  186. data/vendor/libgit2/src/transaction.c +352 -0
  187. data/vendor/libgit2/src/transport.c +91 -97
  188. data/vendor/libgit2/src/transports/auth.c +71 -0
  189. data/vendor/libgit2/src/transports/auth.h +63 -0
  190. data/vendor/libgit2/src/transports/auth_negotiate.c +275 -0
  191. data/vendor/libgit2/src/transports/auth_negotiate.h +27 -0
  192. data/vendor/libgit2/src/transports/cred.c +58 -0
  193. data/vendor/libgit2/src/transports/cred.h +14 -0
  194. data/vendor/libgit2/src/transports/cred_helpers.c +3 -0
  195. data/vendor/libgit2/src/transports/git.c +1 -0
  196. data/vendor/libgit2/src/transports/http.c +208 -82
  197. data/vendor/libgit2/src/transports/local.c +2 -2
  198. data/vendor/libgit2/src/transports/smart.c +2 -0
  199. data/vendor/libgit2/src/transports/smart.h +2 -0
  200. data/vendor/libgit2/src/transports/smart_protocol.c +10 -10
  201. data/vendor/libgit2/src/transports/ssh.c +243 -57
  202. data/vendor/libgit2/src/transports/winhttp.c +139 -35
  203. data/vendor/libgit2/src/tree-cache.c +118 -31
  204. data/vendor/libgit2/src/tree-cache.h +12 -7
  205. data/vendor/libgit2/src/tree.c +83 -64
  206. data/vendor/libgit2/src/tree.h +2 -3
  207. data/vendor/libgit2/src/unix/map.c +8 -2
  208. data/vendor/libgit2/src/unix/posix.h +23 -9
  209. data/vendor/libgit2/src/unix/realpath.c +8 -7
  210. data/vendor/libgit2/src/userdiff.h +3 -3
  211. data/vendor/libgit2/src/util.c +2 -92
  212. data/vendor/libgit2/src/util.h +3 -15
  213. data/vendor/libgit2/src/win32/findfile.c +0 -1
  214. data/vendor/libgit2/src/win32/map.c +3 -2
  215. data/vendor/libgit2/src/win32/mingw-compat.h +5 -12
  216. data/vendor/libgit2/src/win32/msvc-compat.h +3 -32
  217. data/vendor/libgit2/src/win32/posix.h +20 -32
  218. data/vendor/libgit2/src/win32/posix_w32.c +103 -31
  219. data/vendor/libgit2/src/win32/utf-conv.c +6 -36
  220. data/vendor/libgit2/src/win32/utf-conv.h +39 -0
  221. data/vendor/libgit2/src/win32/w32_util.h +0 -1
  222. metadata +32 -7
  223. data/vendor/libgit2/src/win32/path_w32.c +0 -305
  224. data/vendor/libgit2/src/win32/path_w32.h +0 -82
@@ -92,6 +92,10 @@ static int diff_delta__from_one(
92
92
  if (status == GIT_DELTA_UNTRACKED &&
93
93
  DIFF_FLAG_ISNT_SET(diff, GIT_DIFF_INCLUDE_UNTRACKED))
94
94
  return 0;
95
+
96
+ if (status == GIT_DELTA_UNREADABLE &&
97
+ DIFF_FLAG_ISNT_SET(diff, GIT_DIFF_INCLUDE_UNREADABLE))
98
+ return 0;
95
99
 
96
100
  if (!git_pathspec__match(
97
101
  &diff->pathspec, entry->path,
@@ -196,6 +200,7 @@ static git_diff_delta *diff_delta__last_for_item(
196
200
  if (git_oid__cmp(&delta->new_file.id, &item->id) == 0)
197
201
  return delta;
198
202
  break;
203
+ case GIT_DELTA_UNREADABLE:
199
204
  case GIT_DELTA_UNTRACKED:
200
205
  if (diff->strcomp(delta->new_file.path, item->path) == 0 &&
201
206
  git_oid__cmp(&delta->new_file.id, &item->id) == 0)
@@ -293,6 +298,10 @@ bool git_diff_delta__should_skip(
293
298
  (flags & GIT_DIFF_INCLUDE_UNTRACKED) == 0)
294
299
  return true;
295
300
 
301
+ if (delta->status == GIT_DELTA_UNREADABLE &&
302
+ (flags & GIT_DIFF_INCLUDE_UNREADABLE) == 0)
303
+ return true;
304
+
296
305
  return false;
297
306
  }
298
307
 
@@ -430,7 +439,7 @@ static int diff_list_apply_options(
430
439
  /* If not given explicit `opts`, check `diff.xyz` configs */
431
440
  if (!opts) {
432
441
  int context = git_config__get_int_force(cfg, "diff.context", 3);
433
- diff->opts.context_lines = context >= 0 ? (uint16_t)context : 3;
442
+ diff->opts.context_lines = context >= 0 ? (uint32_t)context : 3;
434
443
 
435
444
  /* add other defaults here */
436
445
  }
@@ -734,6 +743,11 @@ static int maybe_modified(
734
743
  else if (GIT_MODE_TYPE(omode) != GIT_MODE_TYPE(nmode)) {
735
744
  if (DIFF_FLAG_IS_SET(diff, GIT_DIFF_INCLUDE_TYPECHANGE))
736
745
  status = GIT_DELTA_TYPECHANGE;
746
+ else if (nmode == GIT_FILEMODE_UNREADABLE) {
747
+ if (!(error = diff_delta__from_one(diff, GIT_DELTA_DELETED, oitem)))
748
+ error = diff_delta__from_one(diff, GIT_DELTA_UNREADABLE, nitem);
749
+ return error;
750
+ }
737
751
  else {
738
752
  if (!(error = diff_delta__from_one(diff, GIT_DELTA_DELETED, oitem)))
739
753
  error = diff_delta__from_one(diff, GIT_DELTA_ADDED, nitem);
@@ -954,6 +968,13 @@ static int handle_unmatched_new_item(
954
968
  }
955
969
  }
956
970
 
971
+ else if (nitem->mode == GIT_FILEMODE_UNREADABLE) {
972
+ if (DIFF_FLAG_IS_SET(diff, GIT_DIFF_INCLUDE_UNREADABLE_AS_UNTRACKED))
973
+ delta_type = GIT_DELTA_UNTRACKED;
974
+ else
975
+ delta_type = GIT_DELTA_UNREADABLE;
976
+ }
977
+
957
978
  /* Actually create the record for this item if necessary */
958
979
  if ((error = diff_delta__from_one(diff, delta_type, nitem)) != 0)
959
980
  return error;
@@ -1193,7 +1214,7 @@ int git_diff_index_to_workdir(
1193
1214
  DIFF_FROM_ITERATORS(
1194
1215
  git_iterator_for_index(&a, index, 0, pfx, pfx),
1195
1216
  git_iterator_for_workdir(
1196
- &b, repo, GIT_ITERATOR_DONT_AUTOEXPAND, pfx, pfx)
1217
+ &b, repo, index, NULL, GIT_ITERATOR_DONT_AUTOEXPAND, pfx, pfx)
1197
1218
  );
1198
1219
 
1199
1220
  if (!error && DIFF_FLAG_IS_SET(*diff, GIT_DIFF_UPDATE_INDEX))
@@ -1209,15 +1230,20 @@ int git_diff_tree_to_workdir(
1209
1230
  const git_diff_options *opts)
1210
1231
  {
1211
1232
  int error = 0;
1233
+ git_index *index;
1212
1234
 
1213
1235
  assert(diff && repo);
1214
1236
 
1237
+ if ((error = git_repository_index(&index, repo)))
1238
+ return error;
1239
+
1215
1240
  DIFF_FROM_ITERATORS(
1216
1241
  git_iterator_for_tree(&a, old_tree, 0, pfx, pfx),
1217
1242
  git_iterator_for_workdir(
1218
- &b, repo, GIT_ITERATOR_DONT_AUTOEXPAND, pfx, pfx)
1243
+ &b, repo, index, old_tree, GIT_ITERATOR_DONT_AUTOEXPAND, pfx, pfx)
1219
1244
  );
1220
1245
 
1246
+ git_index_free(index);
1221
1247
  return error;
1222
1248
  }
1223
1249
 
@@ -112,6 +112,7 @@ int git_diff_file_content__init_from_diff(
112
112
  has_data = !use_old &&
113
113
  (diff->opts.flags & GIT_DIFF_SHOW_UNTRACKED_CONTENT) != 0;
114
114
  break;
115
+ case GIT_DELTA_UNREADABLE:
115
116
  case GIT_DELTA_MODIFIED:
116
117
  case GIT_DELTA_COPIED:
117
118
  case GIT_DELTA_RENAMED:
@@ -14,12 +14,11 @@
14
14
  #include "fileops.h"
15
15
 
16
16
  /* cached information about a hunk in a diff */
17
- typedef struct diff_patch_hunk diff_patch_hunk;
18
- struct diff_patch_hunk {
17
+ typedef struct diff_patch_hunk {
19
18
  git_diff_hunk hunk;
20
19
  size_t line_start;
21
20
  size_t line_count;
22
- };
21
+ } diff_patch_hunk;
23
22
 
24
23
  struct git_patch {
25
24
  git_refcount rc;
@@ -82,14 +82,15 @@ char git_diff_status_char(git_delta_t status)
82
82
  char code;
83
83
 
84
84
  switch (status) {
85
- case GIT_DELTA_ADDED: code = 'A'; break;
86
- case GIT_DELTA_DELETED: code = 'D'; break;
87
- case GIT_DELTA_MODIFIED: code = 'M'; break;
88
- case GIT_DELTA_RENAMED: code = 'R'; break;
89
- case GIT_DELTA_COPIED: code = 'C'; break;
90
- case GIT_DELTA_IGNORED: code = 'I'; break;
91
- case GIT_DELTA_UNTRACKED: code = '?'; break;
92
- default: code = ' '; break;
85
+ case GIT_DELTA_ADDED: code = 'A'; break;
86
+ case GIT_DELTA_DELETED: code = 'D'; break;
87
+ case GIT_DELTA_MODIFIED: code = 'M'; break;
88
+ case GIT_DELTA_RENAMED: code = 'R'; break;
89
+ case GIT_DELTA_COPIED: code = 'C'; break;
90
+ case GIT_DELTA_IGNORED: code = 'I'; break;
91
+ case GIT_DELTA_UNTRACKED: code = '?'; break;
92
+ case GIT_DELTA_UNREADABLE: code = 'X'; break;
93
+ default: code = ' '; break;
93
94
  }
94
95
 
95
96
  return code;
@@ -351,7 +352,7 @@ static int print_binary_hunk(diff_print_info *pi, git_blob *old, git_blob *new)
351
352
  else
352
353
  git_buf_putc(pi->buf, (char)chunk_len - 26 + 'a' - 1);
353
354
 
354
- git_buf_put_base85(pi->buf, scan, chunk_len);
355
+ git_buf_encode_base85(pi->buf, scan, chunk_len);
355
356
  git_buf_putc(pi->buf, '\n');
356
357
 
357
358
  if (git_buf_oom(pi->buf)) {
@@ -441,6 +442,7 @@ static int diff_print_patch_file(
441
442
  if (S_ISDIR(delta->new_file.mode) ||
442
443
  delta->status == GIT_DELTA_UNMODIFIED ||
443
444
  delta->status == GIT_DELTA_IGNORED ||
445
+ delta->status == GIT_DELTA_UNREADABLE ||
444
446
  (delta->status == GIT_DELTA_UNTRACKED &&
445
447
  (pi->flags & GIT_DIFF_SHOW_UNTRACKED_CONTENT) == 0))
446
448
  return 0;
@@ -8,9 +8,9 @@
8
8
 
9
9
  #include "git2/config.h"
10
10
  #include "git2/blob.h"
11
+ #include "git2/sys/hashsig.h"
11
12
 
12
13
  #include "diff.h"
13
- #include "hashsig.h"
14
14
  #include "path.h"
15
15
  #include "fileops.h"
16
16
  #include "config.h"
@@ -114,7 +114,7 @@ static git_diff_delta *diff_delta__merge_like_cgit_reversed(
114
114
  if ((dup = diff_delta__dup(a, pool)) == NULL)
115
115
  return NULL;
116
116
 
117
- if (b->status == GIT_DELTA_UNMODIFIED || b->status == GIT_DELTA_UNTRACKED)
117
+ if (b->status == GIT_DELTA_UNMODIFIED || b->status == GIT_DELTA_UNTRACKED || b->status == GIT_DELTA_UNREADABLE)
118
118
  return dup;
119
119
 
120
120
  if (dup->status == GIT_DELTA_DELETED) {
@@ -732,6 +732,7 @@ static bool is_rename_source(
732
732
  switch (delta->status) {
733
733
  case GIT_DELTA_ADDED:
734
734
  case GIT_DELTA_UNTRACKED:
735
+ case GIT_DELTA_UNREADABLE:
735
736
  case GIT_DELTA_IGNORED:
736
737
  return false;
737
738
 
@@ -786,6 +787,7 @@ GIT_INLINE(bool) delta_is_new_only(git_diff_delta *delta)
786
787
  {
787
788
  return (delta->status == GIT_DELTA_ADDED ||
788
789
  delta->status == GIT_DELTA_UNTRACKED ||
790
+ delta->status == GIT_DELTA_UNREADABLE ||
789
791
  delta->status == GIT_DELTA_IGNORED);
790
792
  }
791
793
 
@@ -947,8 +949,6 @@ find_best_matches:
947
949
  * Rewrite the diffs with renames / copies
948
950
  */
949
951
 
950
- tried_tgts = 0;
951
-
952
952
  git_vector_foreach(&diff->deltas, t, tgt) {
953
953
  /* skip things that are not rename targets */
954
954
  if ((tgt->flags & GIT_DIFF_FLAG__IS_RENAME_TARGET) == 0)
@@ -45,15 +45,19 @@ void giterr_set(int error_class, const char *string, ...)
45
45
  #endif
46
46
  int error_code = (error_class == GITERR_OS) ? errno : 0;
47
47
 
48
- va_start(arglist, string);
49
- git_buf_vprintf(&buf, string, arglist);
50
- va_end(arglist);
48
+ if (string) {
49
+ va_start(arglist, string);
50
+ git_buf_vprintf(&buf, string, arglist);
51
+ va_end(arglist);
52
+
53
+ if (error_class == GITERR_OS)
54
+ git_buf_PUTS(&buf, ": ");
55
+ }
51
56
 
52
57
  if (error_class == GITERR_OS) {
53
58
  #ifdef GIT_WIN32
54
59
  char * win32_error = git_win32_get_error_message(win32_error_code);
55
60
  if (win32_error) {
56
- git_buf_PUTS(&buf, ": ");
57
61
  git_buf_puts(&buf, win32_error);
58
62
  git__free(win32_error);
59
63
 
@@ -61,10 +65,8 @@ void giterr_set(int error_class, const char *string, ...)
61
65
  }
62
66
  else
63
67
  #endif
64
- if (error_code) {
65
- git_buf_PUTS(&buf, ": ");
68
+ if (error_code)
66
69
  git_buf_puts(&buf, strerror(error_code));
67
- }
68
70
 
69
71
  if (error_code)
70
72
  errno = 0;
@@ -28,15 +28,15 @@ static int maybe_want(git_remote *remote, git_remote_head *head, git_odb *odb, g
28
28
 
29
29
  if (remote->download_tags == GIT_REMOTE_DOWNLOAD_TAGS_ALL) {
30
30
  /*
31
- * If tagopt is --tags, then we only use the default
32
- * tags refspec and ignore the remote's
31
+ * If tagopt is --tags, always request tags
32
+ * in addition to the remote's refspecs
33
33
  */
34
34
  if (git_refspec_src_matches(tagspec, head->name))
35
35
  match = 1;
36
- else
37
- return 0;
38
- } else if (git_remote__matching_refspec(remote, head->name))
39
- match = 1;
36
+ }
37
+
38
+ if (!match && git_remote__matching_refspec(remote, head->name))
39
+ match = 1;
40
40
 
41
41
  if (!match)
42
42
  return 0;
@@ -9,14 +9,12 @@
9
9
 
10
10
  #include "vector.h"
11
11
 
12
- struct git_fetchhead_ref {
12
+ typedef struct git_fetchhead_ref {
13
13
  git_oid oid;
14
14
  unsigned int is_merge;
15
15
  char *ref_name;
16
16
  char *remote_url;
17
- };
18
-
19
- typedef struct git_fetchhead_ref git_fetchhead_ref;
17
+ } git_fetchhead_ref;
20
18
 
21
19
  int git_fetchhead_ref_create(
22
20
  git_fetchhead_ref **fetchhead_ref_out,
@@ -334,8 +334,6 @@ int git_filebuf_commit(git_filebuf *file)
334
334
 
335
335
  file->fd = -1;
336
336
 
337
- p_unlink(file->path_original);
338
-
339
337
  if (p_rename(file->path_lock, file->path_original) < 0) {
340
338
  giterr_set(GITERR_OS, "Failed to rename lockfile to '%s'", file->path_original);
341
339
  goto on_error;
@@ -25,11 +25,12 @@
25
25
  #define GIT_FILELOCK_EXTENSION ".lock\0"
26
26
  #define GIT_FILELOCK_EXTLENGTH 6
27
27
 
28
+ typedef struct git_filebuf git_filebuf;
28
29
  struct git_filebuf {
29
30
  char *path_original;
30
31
  char *path_lock;
31
32
 
32
- int (*write)(struct git_filebuf *file, void *source, size_t len);
33
+ int (*write)(git_filebuf *file, void *source, size_t len);
33
34
 
34
35
  bool compute_digest;
35
36
  git_hash_ctx digest;
@@ -47,8 +48,6 @@ struct git_filebuf {
47
48
  int last_error;
48
49
  };
49
50
 
50
- typedef struct git_filebuf git_filebuf;
51
-
52
51
  #define GIT_FILEBUF_INIT {0}
53
52
 
54
53
  /*
@@ -355,8 +355,9 @@ int git_futils_mkdir(
355
355
  if (p_mkdir(make_path.ptr, mode) < 0) {
356
356
  int tmp_errno = giterr_system_last();
357
357
 
358
- /* ignore error if directory already exists */
359
- if (p_stat(make_path.ptr, &st) < 0 || !S_ISDIR(st.st_mode)) {
358
+ /* ignore error if not at end or if directory already exists */
359
+ if (lastch == '\0' &&
360
+ (p_stat(make_path.ptr, &st) < 0 || !S_ISDIR(st.st_mode))) {
360
361
  giterr_system_set(tmp_errno);
361
362
  giterr_set(GITERR_OS, "Failed to make directory '%s'", make_path.ptr);
362
363
  goto done;
@@ -374,7 +375,8 @@ int git_futils_mkdir(
374
375
  if (((flags & GIT_MKDIR_CHMOD_PATH) != 0 ||
375
376
  (lastch == '\0' && (flags & GIT_MKDIR_CHMOD) != 0)) &&
376
377
  st.st_mode != mode &&
377
- (error = p_chmod(make_path.ptr, mode)) < 0) {
378
+ (error = p_chmod(make_path.ptr, mode)) < 0 &&
379
+ lastch == '\0') {
378
380
  giterr_set(GITERR_OS, "Failed to set permissions on '%s'", make_path.ptr);
379
381
  goto done;
380
382
  }
@@ -503,15 +505,15 @@ static int futils__rmdir_recurs_foreach(void *opaque, git_buf *path)
503
505
  return error;
504
506
  }
505
507
 
506
- static int futils__rmdir_empty_parent(void *opaque, git_buf *path)
508
+ static int futils__rmdir_empty_parent(void *opaque, const char *path)
507
509
  {
508
510
  futils__rmdir_data *data = opaque;
509
511
  int error = 0;
510
512
 
511
- if (git_buf_len(path) <= data->baselen)
513
+ if (strlen(path) <= data->baselen)
512
514
  error = GIT_ITEROVER;
513
515
 
514
- else if (p_rmdir(git_buf_cstr(path)) < 0) {
516
+ else if (p_rmdir(path) < 0) {
515
517
  int en = errno;
516
518
 
517
519
  if (en == ENOENT || en == ENOTDIR) {
@@ -519,7 +521,7 @@ static int futils__rmdir_empty_parent(void *opaque, git_buf *path)
519
521
  } else if (en == ENOTEMPTY || en == EEXIST || en == EBUSY) {
520
522
  error = GIT_ITEROVER;
521
523
  } else {
522
- error = git_path_set_error(errno, git_buf_cstr(path), "rmdir");
524
+ error = git_path_set_error(errno, path, "rmdir");
523
525
  }
524
526
  }
525
527
 
@@ -9,6 +9,7 @@
9
9
  #include "hash.h"
10
10
  #include "sysdir.h"
11
11
  #include "git2/threads.h"
12
+ #include "git2/global.h"
12
13
  #include "thread-utils.h"
13
14
 
14
15
 
@@ -19,7 +20,9 @@ git_mutex git__mwindow_mutex;
19
20
  #ifdef GIT_SSL
20
21
  # include <openssl/ssl.h>
21
22
  SSL_CTX *git__ssl_ctx;
23
+ # ifdef GIT_THREADS
22
24
  static git_mutex *openssl_locks;
25
+ # endif
23
26
  #endif
24
27
 
25
28
  static git_global_shutdown_fn git__shutdown_callbacks[MAX_SHUTDOWN_CB];
@@ -62,7 +65,7 @@ void openssl_locking_function(int mode, int n, const char *file, int line)
62
65
  }
63
66
  }
64
67
 
65
- static void shutdown_ssl(void)
68
+ static void shutdown_ssl_locking(void)
66
69
  {
67
70
  int num_locks, i;
68
71
 
@@ -78,6 +81,13 @@ static void shutdown_ssl(void)
78
81
  static void init_ssl(void)
79
82
  {
80
83
  #ifdef GIT_SSL
84
+ long ssl_opts = SSL_OP_NO_SSLv2 | SSL_OP_NO_SSLv3;
85
+
86
+ /* Older OpenSSL and MacOS OpenSSL doesn't have this */
87
+ #ifdef SSL_OP_NO_COMPRESSION
88
+ ssl_opts |= SSL_OP_NO_COMPRESSION;
89
+ #endif
90
+
81
91
  SSL_load_error_strings();
82
92
  OpenSSL_add_ssl_algorithms();
83
93
  /*
@@ -87,43 +97,42 @@ static void init_ssl(void)
87
97
  * to speak TLSv1 to perform the encryption itself.
88
98
  */
89
99
  git__ssl_ctx = SSL_CTX_new(SSLv23_method());
90
- SSL_CTX_set_options(git__ssl_ctx,
91
- SSL_OP_NO_SSLv2 | SSL_OP_NO_SSLv3
92
- /* Older OpenSSL and MacOS OpenSSL doesn't have this */
93
- # ifdef SSL_OP_NO_COMPRESSION
94
- | SSL_OP_NO_COMPRESSION
95
- # endif
96
- );
100
+ SSL_CTX_set_options(git__ssl_ctx, ssl_opts);
97
101
  SSL_CTX_set_mode(git__ssl_ctx, SSL_MODE_AUTO_RETRY);
98
102
  SSL_CTX_set_verify(git__ssl_ctx, SSL_VERIFY_NONE, NULL);
99
103
  if (!SSL_CTX_set_default_verify_paths(git__ssl_ctx)) {
100
104
  SSL_CTX_free(git__ssl_ctx);
101
105
  git__ssl_ctx = NULL;
102
106
  }
107
+ #endif
108
+ }
103
109
 
110
+ int git_openssl_set_locking(void)
111
+ {
112
+ #ifdef GIT_SSL
104
113
  # ifdef GIT_THREADS
105
- {
106
- int num_locks, i;
107
-
108
- num_locks = CRYPTO_num_locks();
109
- openssl_locks = git__calloc(num_locks, sizeof(git_mutex));
110
- if (openssl_locks == NULL) {
111
- SSL_CTX_free(git__ssl_ctx);
112
- git__ssl_ctx = NULL;
113
- }
114
+ int num_locks, i;
114
115
 
115
- for (i = 0; i < num_locks; i++) {
116
- if (git_mutex_init(&openssl_locks[i]) != 0) {
117
- SSL_CTX_free(git__ssl_ctx);
118
- git__ssl_ctx = NULL;
119
- }
120
- }
116
+ num_locks = CRYPTO_num_locks();
117
+ openssl_locks = git__calloc(num_locks, sizeof(git_mutex));
118
+ GITERR_CHECK_ALLOC(openssl_locks);
121
119
 
122
- CRYPTO_set_locking_callback(openssl_locking_function);
120
+ for (i = 0; i < num_locks; i++) {
121
+ if (git_mutex_init(&openssl_locks[i]) != 0) {
122
+ giterr_set(GITERR_SSL, "failed to initialize openssl locks");
123
+ return -1;
124
+ }
123
125
  }
124
126
 
125
- git__on_shutdown(shutdown_ssl);
127
+ CRYPTO_set_locking_callback(openssl_locking_function);
128
+ git__on_shutdown(shutdown_ssl_locking);
129
+ return 0;
130
+ # else
131
+ giterr_set(GITERR_THREAD, "libgit2 as not built with threads");
132
+ return -1;
126
133
  # endif
134
+ giterr_set(GITERR_SSL, "libgit2 was not built with OpenSSL support");
135
+ return -1;
127
136
  #endif
128
137
  }
129
138
 
@@ -131,7 +140,7 @@ static void init_ssl(void)
131
140
  * Handle the global state with TLS
132
141
  *
133
142
  * If libgit2 is built with GIT_THREADS enabled,
134
- * the `git_threads_init()` function must be called
143
+ * the `git_libgit2_init()` function must be called
135
144
  * before calling any other function of the library.
136
145
  *
137
146
  * This function allocates a TLS index (using pthreads
@@ -144,7 +153,7 @@ static void init_ssl(void)
144
153
  * allocated on each thread.
145
154
  *
146
155
  * Before shutting down the library, the
147
- * `git_threads_shutdown` method must be called to free
156
+ * `git_libgit2_shutdown` method must be called to free
148
157
  * the previously reserved TLS index.
149
158
  *
150
159
  * If libgit2 is built without threading support, the
@@ -154,9 +163,9 @@ static void init_ssl(void)
154
163
  */
155
164
 
156
165
  /*
157
- * `git_threads_init()` allows subsystems to perform global setup,
166
+ * `git_libgit2_init()` allows subsystems to perform global setup,
158
167
  * which may take place in the global scope. An explicit memory
159
- * fence exists at the exit of `git_threads_init()`. Without this,
168
+ * fence exists at the exit of `git_libgit2_init()`. Without this,
160
169
  * CPU cores are free to reorder cache invalidation of `_tls_init`
161
170
  * before cache invalidation of the subsystems' newly written global
162
171
  * state.
@@ -183,7 +192,7 @@ static int synchronized_threads_init(void)
183
192
  return error;
184
193
  }
185
194
 
186
- int git_threads_init(void)
195
+ int git_libgit2_init(void)
187
196
  {
188
197
  int error = 0;
189
198
 
@@ -208,7 +217,7 @@ static void synchronized_threads_shutdown(void)
208
217
  git_mutex_free(&git__mwindow_mutex);
209
218
  }
210
219
 
211
- void git_threads_shutdown(void)
220
+ void git_libgit2_shutdown(void)
212
221
  {
213
222
  /* Enter the lock */
214
223
  while (InterlockedCompareExchange(&_mutex, 1, 0)) { Sleep(0); }
@@ -270,14 +279,14 @@ static void init_once(void)
270
279
  GIT_MEMORY_BARRIER;
271
280
  }
272
281
 
273
- int git_threads_init(void)
282
+ int git_libgit2_init(void)
274
283
  {
275
284
  pthread_once(&_once_init, init_once);
276
285
  git_atomic_inc(&git__n_inits);
277
286
  return init_error;
278
287
  }
279
288
 
280
- void git_threads_shutdown(void)
289
+ void git_libgit2_shutdown(void)
281
290
  {
282
291
  void *ptr = NULL;
283
292
  pthread_once_t new_once = PTHREAD_ONCE_INIT;
@@ -318,7 +327,7 @@ git_global_st *git__global_state(void)
318
327
 
319
328
  static git_global_st __state;
320
329
 
321
- int git_threads_init(void)
330
+ int git_libgit2_init(void)
322
331
  {
323
332
  static int ssl_inited = 0;
324
333
 
@@ -331,7 +340,7 @@ int git_threads_init(void)
331
340
  return 0;
332
341
  }
333
342
 
334
- void git_threads_shutdown(void)
343
+ void git_libgit2_shutdown(void)
335
344
  {
336
345
  /* Shut down any subsystems that have global state */
337
346
  if (0 == git_atomic_dec(&git__n_inits))