rugged 1.5.1 → 1.6.2

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 (154) hide show
  1. checksums.yaml +4 -4
  2. data/ext/rugged/extconf.rb +2 -2
  3. data/ext/rugged/rugged_blame.c +2 -0
  4. data/ext/rugged/rugged_blob.c +3 -0
  5. data/ext/rugged/rugged_commit.c +1 -0
  6. data/ext/rugged/rugged_config.c +2 -0
  7. data/ext/rugged/rugged_diff.c +1 -0
  8. data/ext/rugged/rugged_index.c +2 -0
  9. data/ext/rugged/rugged_patch.c +1 -0
  10. data/ext/rugged/rugged_rebase.c +1 -0
  11. data/ext/rugged/rugged_reference.c +1 -0
  12. data/ext/rugged/rugged_remote.c +1 -0
  13. data/ext/rugged/rugged_repo.c +5 -2
  14. data/ext/rugged/rugged_revwalk.c +5 -1
  15. data/ext/rugged/rugged_submodule.c +1 -0
  16. data/ext/rugged/rugged_tag.c +1 -0
  17. data/ext/rugged/rugged_tree.c +4 -0
  18. data/lib/rugged/index.rb +1 -1
  19. data/lib/rugged/tree.rb +1 -1
  20. data/lib/rugged/version.rb +1 -1
  21. data/vendor/libgit2/CMakeLists.txt +5 -1
  22. data/vendor/libgit2/COPYING +30 -0
  23. data/vendor/libgit2/cmake/ExperimentalFeatures.cmake +23 -0
  24. data/vendor/libgit2/deps/ntlmclient/CMakeLists.txt +2 -0
  25. data/vendor/libgit2/include/git2/common.h +13 -6
  26. data/vendor/libgit2/include/git2/deprecated.h +6 -0
  27. data/vendor/libgit2/include/git2/diff.h +1 -1
  28. data/vendor/libgit2/include/git2/experimental.h +20 -0
  29. data/vendor/libgit2/include/git2/indexer.h +29 -0
  30. data/vendor/libgit2/include/git2/object.h +28 -2
  31. data/vendor/libgit2/include/git2/odb.h +58 -7
  32. data/vendor/libgit2/include/git2/odb_backend.h +106 -18
  33. data/vendor/libgit2/include/git2/oid.h +115 -15
  34. data/vendor/libgit2/include/git2/repository.h +20 -1
  35. data/vendor/libgit2/include/git2/stash.h +60 -6
  36. data/vendor/libgit2/include/git2/strarray.h +0 -13
  37. data/vendor/libgit2/include/git2/sys/odb_backend.h +1 -1
  38. data/vendor/libgit2/include/git2/sys/transport.h +12 -0
  39. data/vendor/libgit2/include/git2/version.h +4 -4
  40. data/vendor/libgit2/include/git2.h +1 -0
  41. data/vendor/libgit2/src/CMakeLists.txt +0 -6
  42. data/vendor/libgit2/src/cli/CMakeLists.txt +6 -2
  43. data/vendor/libgit2/src/cli/cmd_hash_object.c +27 -8
  44. data/vendor/libgit2/src/cli/opt.c +1 -1
  45. data/vendor/libgit2/src/libgit2/CMakeLists.txt +25 -15
  46. data/vendor/libgit2/src/libgit2/annotated_commit.c +1 -1
  47. data/vendor/libgit2/src/libgit2/annotated_commit.h +1 -1
  48. data/vendor/libgit2/src/libgit2/attr_file.c +1 -1
  49. data/vendor/libgit2/src/libgit2/attrcache.c +1 -1
  50. data/vendor/libgit2/src/libgit2/blame.c +2 -0
  51. data/vendor/libgit2/src/libgit2/blob.c +4 -2
  52. data/vendor/libgit2/src/libgit2/blob.h +2 -2
  53. data/vendor/libgit2/src/libgit2/branch.c +2 -2
  54. data/vendor/libgit2/src/libgit2/cherrypick.c +3 -3
  55. data/vendor/libgit2/src/libgit2/clone.c +31 -2
  56. data/vendor/libgit2/src/libgit2/commit.c +52 -17
  57. data/vendor/libgit2/src/libgit2/commit.h +25 -7
  58. data/vendor/libgit2/src/libgit2/commit_graph.c +47 -32
  59. data/vendor/libgit2/src/libgit2/commit_graph.h +3 -0
  60. data/vendor/libgit2/src/libgit2/commit_list.c +6 -2
  61. data/vendor/libgit2/src/libgit2/config.c +1 -1
  62. data/vendor/libgit2/src/libgit2/config_file.c +2 -2
  63. data/vendor/libgit2/src/libgit2/describe.c +8 -8
  64. data/vendor/libgit2/src/libgit2/diff.c +5 -1
  65. data/vendor/libgit2/src/libgit2/diff_file.c +15 -6
  66. data/vendor/libgit2/src/libgit2/diff_generate.c +17 -12
  67. data/vendor/libgit2/src/libgit2/diff_print.c +5 -5
  68. data/vendor/libgit2/src/libgit2/diff_tform.c +4 -0
  69. data/vendor/libgit2/src/libgit2/email.c +2 -2
  70. data/vendor/libgit2/src/libgit2/experimental.h.in +13 -0
  71. data/vendor/libgit2/src/libgit2/fetch.c +3 -6
  72. data/vendor/libgit2/src/libgit2/fetchhead.c +4 -4
  73. data/vendor/libgit2/src/libgit2/ident.c +3 -3
  74. data/vendor/libgit2/src/libgit2/index.c +11 -9
  75. data/vendor/libgit2/src/libgit2/indexer.c +107 -44
  76. data/vendor/libgit2/src/libgit2/iterator.c +4 -2
  77. data/vendor/libgit2/src/libgit2/libgit2.c +19 -0
  78. data/vendor/libgit2/src/libgit2/merge.c +3 -3
  79. data/vendor/libgit2/src/libgit2/midx.c +16 -15
  80. data/vendor/libgit2/src/libgit2/mwindow.c +5 -2
  81. data/vendor/libgit2/src/libgit2/mwindow.h +4 -1
  82. data/vendor/libgit2/src/libgit2/notes.c +5 -5
  83. data/vendor/libgit2/src/libgit2/object.c +89 -25
  84. data/vendor/libgit2/src/libgit2/object.h +12 -3
  85. data/vendor/libgit2/src/libgit2/odb.c +194 -50
  86. data/vendor/libgit2/src/libgit2/odb.h +43 -4
  87. data/vendor/libgit2/src/libgit2/odb_loose.c +128 -70
  88. data/vendor/libgit2/src/libgit2/odb_pack.c +96 -44
  89. data/vendor/libgit2/src/libgit2/oid.c +134 -76
  90. data/vendor/libgit2/src/libgit2/oid.h +183 -9
  91. data/vendor/libgit2/src/libgit2/pack-objects.c +15 -4
  92. data/vendor/libgit2/src/libgit2/pack.c +90 -66
  93. data/vendor/libgit2/src/libgit2/pack.h +29 -15
  94. data/vendor/libgit2/src/libgit2/parse.c +4 -3
  95. data/vendor/libgit2/src/libgit2/patch_parse.c +5 -5
  96. data/vendor/libgit2/src/libgit2/push.c +13 -3
  97. data/vendor/libgit2/src/libgit2/reader.c +1 -1
  98. data/vendor/libgit2/src/libgit2/rebase.c +19 -18
  99. data/vendor/libgit2/src/libgit2/refdb_fs.c +70 -39
  100. data/vendor/libgit2/src/libgit2/reflog.c +7 -5
  101. data/vendor/libgit2/src/libgit2/reflog.h +1 -2
  102. data/vendor/libgit2/src/libgit2/refs.c +2 -0
  103. data/vendor/libgit2/src/libgit2/remote.c +38 -37
  104. data/vendor/libgit2/src/libgit2/remote.h +40 -0
  105. data/vendor/libgit2/src/libgit2/repository.c +212 -36
  106. data/vendor/libgit2/src/libgit2/repository.h +9 -0
  107. data/vendor/libgit2/src/libgit2/reset.c +2 -2
  108. data/vendor/libgit2/src/libgit2/revert.c +4 -4
  109. data/vendor/libgit2/src/libgit2/revparse.c +23 -7
  110. data/vendor/libgit2/src/libgit2/revwalk.c +5 -1
  111. data/vendor/libgit2/src/libgit2/stash.c +201 -26
  112. data/vendor/libgit2/src/libgit2/strarray.c +1 -0
  113. data/vendor/libgit2/src/libgit2/strarray.h +25 -0
  114. data/vendor/libgit2/src/libgit2/streams/openssl.c +1 -1
  115. data/vendor/libgit2/src/libgit2/streams/openssl_dynamic.c +7 -3
  116. data/vendor/libgit2/src/libgit2/streams/socket.c +4 -1
  117. data/vendor/libgit2/src/libgit2/submodule.c +6 -2
  118. data/vendor/libgit2/src/libgit2/sysdir.c +294 -7
  119. data/vendor/libgit2/src/libgit2/sysdir.h +39 -9
  120. data/vendor/libgit2/src/libgit2/tag.c +29 -10
  121. data/vendor/libgit2/src/libgit2/tag.h +2 -2
  122. data/vendor/libgit2/src/libgit2/threadstate.h +1 -1
  123. data/vendor/libgit2/src/libgit2/transports/http.c +8 -7
  124. data/vendor/libgit2/src/libgit2/transports/httpclient.c +9 -0
  125. data/vendor/libgit2/src/libgit2/transports/httpclient.h +10 -0
  126. data/vendor/libgit2/src/libgit2/transports/local.c +14 -0
  127. data/vendor/libgit2/src/libgit2/transports/smart.c +35 -0
  128. data/vendor/libgit2/src/libgit2/transports/smart.h +10 -1
  129. data/vendor/libgit2/src/libgit2/transports/smart_pkt.c +153 -41
  130. data/vendor/libgit2/src/libgit2/transports/smart_protocol.c +42 -12
  131. data/vendor/libgit2/src/libgit2/transports/ssh.c +62 -65
  132. data/vendor/libgit2/src/libgit2/transports/winhttp.c +9 -4
  133. data/vendor/libgit2/src/libgit2/tree-cache.c +4 -4
  134. data/vendor/libgit2/src/libgit2/tree.c +22 -16
  135. data/vendor/libgit2/src/libgit2/tree.h +2 -2
  136. data/vendor/libgit2/src/libgit2/worktree.c +5 -0
  137. data/vendor/libgit2/src/util/CMakeLists.txt +7 -1
  138. data/vendor/libgit2/src/util/fs_path.c +1 -1
  139. data/vendor/libgit2/src/util/futils.c +0 -3
  140. data/vendor/libgit2/src/util/git2_util.h +2 -2
  141. data/vendor/libgit2/src/util/hash/openssl.c +4 -3
  142. data/vendor/libgit2/src/util/hash/rfc6234/sha.h +0 -112
  143. data/vendor/libgit2/src/util/hash.h +13 -0
  144. data/vendor/libgit2/src/util/net.c +338 -84
  145. data/vendor/libgit2/src/util/net.h +7 -0
  146. data/vendor/libgit2/src/util/posix.h +2 -0
  147. data/vendor/libgit2/src/util/rand.c +4 -0
  148. data/vendor/libgit2/src/util/regexp.c +3 -3
  149. data/vendor/libgit2/src/util/thread.h +20 -19
  150. data/vendor/libgit2/src/util/util.h +1 -0
  151. metadata +7 -5
  152. data/vendor/libgit2/src/util/win32/findfile.c +0 -286
  153. data/vendor/libgit2/src/util/win32/findfile.h +0 -22
  154. /data/vendor/libgit2/src/{features.h.in → util/git2_features.h.in} +0 -0
@@ -9,11 +9,120 @@
9
9
 
10
10
  #include "common.h"
11
11
 
12
+ #include "git2/experimental.h"
12
13
  #include "git2/oid.h"
14
+ #include "hash.h"
15
+
16
+ #ifdef GIT_EXPERIMENTAL_SHA256
17
+ # define GIT_OID_NONE { 0, { 0 } }
18
+ # define GIT_OID_INIT(type, ...) { type, __VA_ARGS__ }
19
+ #else
20
+ # define GIT_OID_NONE { { 0 } }
21
+ # define GIT_OID_INIT(type, ...) { __VA_ARGS__ }
22
+ #endif
13
23
 
14
24
  extern const git_oid git_oid__empty_blob_sha1;
15
25
  extern const git_oid git_oid__empty_tree_sha1;
16
26
 
27
+ GIT_INLINE(git_oid_t) git_oid_type(const git_oid *oid)
28
+ {
29
+ #ifdef GIT_EXPERIMENTAL_SHA256
30
+ return oid->type;
31
+ #else
32
+ GIT_UNUSED(oid);
33
+ return GIT_OID_SHA1;
34
+ #endif
35
+ }
36
+
37
+ GIT_INLINE(size_t) git_oid_size(git_oid_t type)
38
+ {
39
+ switch (type) {
40
+ case GIT_OID_SHA1:
41
+ return GIT_OID_SHA1_SIZE;
42
+
43
+ #ifdef GIT_EXPERIMENTAL_SHA256
44
+ case GIT_OID_SHA256:
45
+ return GIT_OID_SHA256_SIZE;
46
+ #endif
47
+
48
+ }
49
+
50
+ return 0;
51
+ }
52
+
53
+ GIT_INLINE(size_t) git_oid_hexsize(git_oid_t type)
54
+ {
55
+ switch (type) {
56
+ case GIT_OID_SHA1:
57
+ return GIT_OID_SHA1_HEXSIZE;
58
+
59
+ #ifdef GIT_EXPERIMENTAL_SHA256
60
+ case GIT_OID_SHA256:
61
+ return GIT_OID_SHA256_HEXSIZE;
62
+ #endif
63
+
64
+ }
65
+
66
+ return 0;
67
+ }
68
+
69
+ GIT_INLINE(const char *) git_oid_type_name(git_oid_t type)
70
+ {
71
+ switch (type) {
72
+ case GIT_OID_SHA1:
73
+ return "sha1";
74
+
75
+ #ifdef GIT_EXPERIMENTAL_SHA256
76
+ case GIT_OID_SHA256:
77
+ return "sha256";
78
+ #endif
79
+ }
80
+
81
+ return "unknown";
82
+ }
83
+
84
+ GIT_INLINE(git_oid_t) git_oid_type_fromstr(const char *name)
85
+ {
86
+ if (strcmp(name, "sha1") == 0)
87
+ return GIT_OID_SHA1;
88
+
89
+ #ifdef GIT_EXPERIMENTAL_SHA256
90
+ if (strcmp(name, "sha256") == 0)
91
+ return GIT_OID_SHA256;
92
+ #endif
93
+
94
+ return 0;
95
+ }
96
+
97
+ GIT_INLINE(git_oid_t) git_oid_type_fromstrn(const char *name, size_t len)
98
+ {
99
+ if (len == CONST_STRLEN("sha1") && strncmp(name, "sha1", len) == 0)
100
+ return GIT_OID_SHA1;
101
+
102
+ #ifdef GIT_EXPERIMENTAL_SHA256
103
+ if (len == CONST_STRLEN("sha256") && strncmp(name, "sha256", len) == 0)
104
+ return GIT_OID_SHA256;
105
+ #endif
106
+
107
+ return 0;
108
+ }
109
+
110
+ GIT_INLINE(git_hash_algorithm_t) git_oid_algorithm(git_oid_t type)
111
+ {
112
+ switch (type) {
113
+ case GIT_OID_SHA1:
114
+ return GIT_HASH_ALGORITHM_SHA1;
115
+
116
+ #ifdef GIT_EXPERIMENTAL_SHA256
117
+ case GIT_OID_SHA256:
118
+ return GIT_HASH_ALGORITHM_SHA256;
119
+ #endif
120
+
121
+ }
122
+
123
+ return 0;
124
+ }
125
+
17
126
  /**
18
127
  * Format a git_oid into a newly allocated c-string.
19
128
  *
@@ -25,13 +134,42 @@ extern const git_oid git_oid__empty_tree_sha1;
25
134
  */
26
135
  char *git_oid_allocfmt(const git_oid *id);
27
136
 
137
+ /**
138
+ * Format the requested nibbles of an object id.
139
+ *
140
+ * @param str the string to write into
141
+ * @param oid the oid structure to format
142
+ * @param start the starting number of nibbles
143
+ * @param count the number of nibbles to format
144
+ */
145
+ GIT_INLINE(void) git_oid_fmt_substr(
146
+ char *str,
147
+ const git_oid *oid,
148
+ size_t start,
149
+ size_t count)
150
+ {
151
+ static char hex[] = "0123456789abcdef";
152
+ size_t i, end = start + count, min = start / 2, max = end / 2;
153
+
154
+ if (start & 1)
155
+ *str++ = hex[oid->id[min++] & 0x0f];
156
+
157
+ for (i = min; i < max; i++) {
158
+ *str++ = hex[oid->id[i] >> 4];
159
+ *str++ = hex[oid->id[i] & 0x0f];
160
+ }
161
+
162
+ if (end & 1)
163
+ *str++ = hex[oid->id[i] >> 4];
164
+ }
165
+
28
166
  GIT_INLINE(int) git_oid_raw_ncmp(
29
167
  const unsigned char *sha1,
30
168
  const unsigned char *sha2,
31
169
  size_t len)
32
170
  {
33
- if (len > GIT_OID_HEXSZ)
34
- len = GIT_OID_HEXSZ;
171
+ if (len > GIT_OID_MAX_HEXSIZE)
172
+ len = GIT_OID_MAX_HEXSIZE;
35
173
 
36
174
  while (len > 1) {
37
175
  if (*sha1 != *sha2)
@@ -50,16 +188,18 @@ GIT_INLINE(int) git_oid_raw_ncmp(
50
188
 
51
189
  GIT_INLINE(int) git_oid_raw_cmp(
52
190
  const unsigned char *sha1,
53
- const unsigned char *sha2)
191
+ const unsigned char *sha2,
192
+ size_t size)
54
193
  {
55
- return memcmp(sha1, sha2, GIT_OID_RAWSZ);
194
+ return memcmp(sha1, sha2, size);
56
195
  }
57
196
 
58
197
  GIT_INLINE(int) git_oid_raw_cpy(
59
198
  unsigned char *dst,
60
- const unsigned char *src)
199
+ const unsigned char *src,
200
+ size_t size)
61
201
  {
62
- memcpy(dst, src, GIT_OID_RAWSZ);
202
+ memcpy(dst, src, size);
63
203
  return 0;
64
204
  }
65
205
 
@@ -72,19 +212,30 @@ GIT_INLINE(int) git_oid_raw_cpy(
72
212
  */
73
213
  GIT_INLINE(int) git_oid__cmp(const git_oid *a, const git_oid *b)
74
214
  {
75
- return git_oid_raw_cmp(a->id, b->id);
215
+ #ifdef GIT_EXPERIMENTAL_SHA256
216
+ if (a->type != b->type)
217
+ return a->type - b->type;
218
+
219
+ return git_oid_raw_cmp(a->id, b->id, git_oid_size(a->type));
220
+ #else
221
+ return git_oid_raw_cmp(a->id, b->id, git_oid_size(GIT_OID_SHA1));
222
+ #endif
76
223
  }
77
224
 
78
225
  GIT_INLINE(void) git_oid__cpy_prefix(
79
226
  git_oid *out, const git_oid *id, size_t len)
80
227
  {
228
+ #ifdef GIT_EXPERIMENTAL_SHA256
229
+ out->type = id->type;
230
+ #endif
231
+
81
232
  memcpy(&out->id, id->id, (len + 1) / 2);
82
233
 
83
234
  if (len & 1)
84
235
  out->id[len / 2] &= 0xF0;
85
236
  }
86
237
 
87
- GIT_INLINE(bool) git_oid__is_hexstr(const char *str)
238
+ GIT_INLINE(bool) git_oid__is_hexstr(const char *str, git_oid_t type)
88
239
  {
89
240
  size_t i;
90
241
 
@@ -93,7 +244,30 @@ GIT_INLINE(bool) git_oid__is_hexstr(const char *str)
93
244
  return false;
94
245
  }
95
246
 
96
- return (i == GIT_OID_HEXSZ);
247
+ return (i == git_oid_hexsize(type));
97
248
  }
98
249
 
250
+ GIT_INLINE(void) git_oid_clear(git_oid *out, git_oid_t type)
251
+ {
252
+ memset(out->id, 0, git_oid_size(type));
253
+
254
+ #ifdef GIT_EXPERIMENTAL_SHA256
255
+ out->type = type;
256
+ #endif
257
+ }
258
+
259
+ /* SHA256 support */
260
+
261
+ int git_oid__fromstr(git_oid *out, const char *str, git_oid_t type);
262
+
263
+ int git_oid__fromstrp(git_oid *out, const char *str, git_oid_t type);
264
+
265
+ int git_oid__fromstrn(
266
+ git_oid *out,
267
+ const char *str,
268
+ size_t length,
269
+ git_oid_t type);
270
+
271
+ int git_oid__fromraw(git_oid *out, const unsigned char *raw, git_oid_t type);
272
+
99
273
  #endif
@@ -347,8 +347,8 @@ static int write_object(
347
347
  goto done;
348
348
 
349
349
  if (type == GIT_OBJECT_REF_DELTA) {
350
- if ((error = write_cb(po->delta->id.id, GIT_OID_RAWSZ, cb_data)) < 0 ||
351
- (error = git_hash_update(&pb->ctx, po->delta->id.id, GIT_OID_RAWSZ)) < 0)
350
+ if ((error = write_cb(po->delta->id.id, GIT_OID_SHA1_SIZE, cb_data)) < 0 ||
351
+ (error = git_hash_update(&pb->ctx, po->delta->id.id, GIT_OID_SHA1_SIZE)) < 0)
352
352
  goto done;
353
353
  }
354
354
 
@@ -668,7 +668,7 @@ static int write_pack(git_packbuilder *pb,
668
668
  if ((error = git_hash_final(entry_oid.id, &pb->ctx)) < 0)
669
669
  goto done;
670
670
 
671
- error = write_cb(entry_oid.id, GIT_OID_RAWSZ, cb_data);
671
+ error = write_cb(entry_oid.id, GIT_OID_SHA1_SIZE, cb_data);
672
672
 
673
673
  done:
674
674
  /* if callback cancelled writing, we must still free delta_data */
@@ -1407,7 +1407,18 @@ int git_packbuilder_write(
1407
1407
  opts.progress_cb = progress_cb;
1408
1408
  opts.progress_cb_payload = progress_cb_payload;
1409
1409
 
1410
- if ((error = git_indexer_new(&indexer, path, mode, pb->odb, &opts)) < 0)
1410
+ /* TODO: SHA256 */
1411
+
1412
+ #ifdef GIT_EXPERIMENTAL_SHA256
1413
+ opts.mode = mode;
1414
+ opts.odb = pb->odb;
1415
+
1416
+ error = git_indexer_new(&indexer, path, GIT_OID_SHA1, &opts);
1417
+ #else
1418
+ error = git_indexer_new(&indexer, path, mode, pb->odb, &opts);
1419
+ #endif
1420
+
1421
+ if (error < 0)
1411
1422
  goto cleanup;
1412
1423
 
1413
1424
  if (!git_repository__configmap_lookup(&t, pb->repo, GIT_CONFIGMAP_FSYNCOBJECTFILES) && t)