rugged 0.17.0.b6 → 0.17.0.b7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (158) hide show
  1. data/README.md +3 -3
  2. data/Rakefile +3 -1
  3. data/ext/rugged/rugged.c +30 -0
  4. data/ext/rugged/rugged.h +9 -0
  5. data/ext/rugged/rugged_branch.c +306 -0
  6. data/ext/rugged/rugged_config.c +16 -13
  7. data/ext/rugged/rugged_index.c +25 -0
  8. data/ext/rugged/rugged_object.c +6 -2
  9. data/ext/rugged/rugged_reference.c +11 -18
  10. data/ext/rugged/rugged_revwalk.c +1 -1
  11. data/lib/rugged.rb +1 -0
  12. data/lib/rugged/branch.rb +28 -0
  13. data/lib/rugged/commit.rb +5 -5
  14. data/lib/rugged/repository.rb +32 -7
  15. data/lib/rugged/tag.rb +5 -1
  16. data/lib/rugged/version.rb +1 -1
  17. data/test/branch_test.rb +227 -0
  18. data/test/config_test.rb +1 -1
  19. data/test/fixtures/testrepo.git/objects/4b/825dc642cb6eb9a060e54bf8d69288fbee4904 +0 -0
  20. data/test/fixtures/testrepo.git/objects/a3/e05719b428a2d0ed7a55c4ce53dcc5768c6d5e +0 -0
  21. data/test/index_test.rb +31 -0
  22. data/test/index_test.rb~ +218 -0
  23. data/test/lib_test.rb +22 -0
  24. data/test/reference_test.rb +5 -3
  25. data/vendor/libgit2/Makefile.embed +1 -1
  26. data/vendor/libgit2/include/git2.h +1 -0
  27. data/vendor/libgit2/include/git2/branch.h +17 -13
  28. data/vendor/libgit2/include/git2/checkout.h +83 -22
  29. data/vendor/libgit2/include/git2/clone.h +6 -3
  30. data/vendor/libgit2/include/git2/common.h +1 -8
  31. data/vendor/libgit2/include/git2/config.h +185 -26
  32. data/vendor/libgit2/include/git2/diff.h +229 -17
  33. data/vendor/libgit2/include/git2/errors.h +39 -1
  34. data/vendor/libgit2/include/git2/ignore.h +6 -3
  35. data/vendor/libgit2/include/git2/indexer.h +1 -0
  36. data/vendor/libgit2/include/git2/merge.h +1 -1
  37. data/vendor/libgit2/include/git2/object.h +7 -4
  38. data/vendor/libgit2/include/git2/odb.h +4 -2
  39. data/vendor/libgit2/include/git2/odb_backend.h +6 -0
  40. data/vendor/libgit2/include/git2/oid.h +2 -0
  41. data/vendor/libgit2/include/git2/pack.h +89 -0
  42. data/vendor/libgit2/include/git2/refs.h +88 -0
  43. data/vendor/libgit2/include/git2/refspec.h +0 -8
  44. data/vendor/libgit2/include/git2/remote.h +34 -1
  45. data/vendor/libgit2/include/git2/repository.h +238 -6
  46. data/vendor/libgit2/include/git2/reset.h +4 -1
  47. data/vendor/libgit2/include/git2/revwalk.h +1 -1
  48. data/vendor/libgit2/include/git2/status.h +19 -14
  49. data/vendor/libgit2/include/git2/strarray.h +54 -0
  50. data/vendor/libgit2/include/git2/submodule.h +451 -45
  51. data/vendor/libgit2/include/git2/tag.h +16 -0
  52. data/vendor/libgit2/include/git2/tree.h +2 -2
  53. data/vendor/libgit2/include/git2/types.h +4 -0
  54. data/vendor/libgit2/src/amiga/map.c +4 -7
  55. data/vendor/libgit2/src/attr.c +21 -13
  56. data/vendor/libgit2/src/attr.h +3 -1
  57. data/vendor/libgit2/src/attr_file.c +14 -14
  58. data/vendor/libgit2/src/attr_file.h +6 -5
  59. data/vendor/libgit2/src/blob.c +22 -12
  60. data/vendor/libgit2/src/branch.c +62 -66
  61. data/vendor/libgit2/src/buffer.c +63 -14
  62. data/vendor/libgit2/src/buffer.h +4 -0
  63. data/vendor/libgit2/src/cache.c +5 -4
  64. data/vendor/libgit2/src/checkout.c +381 -159
  65. data/vendor/libgit2/src/clone.c +221 -94
  66. data/vendor/libgit2/src/common.h +13 -3
  67. data/vendor/libgit2/src/compress.c +53 -0
  68. data/vendor/libgit2/src/compress.h +16 -0
  69. data/vendor/libgit2/src/config.c +380 -175
  70. data/vendor/libgit2/src/config.h +2 -5
  71. data/vendor/libgit2/src/config_file.c +63 -46
  72. data/vendor/libgit2/src/config_file.h +16 -4
  73. data/vendor/libgit2/src/crlf.c +4 -3
  74. data/vendor/libgit2/src/delta.c +491 -0
  75. data/vendor/libgit2/src/delta.h +112 -0
  76. data/vendor/libgit2/src/diff.c +310 -67
  77. data/vendor/libgit2/src/diff.h +10 -1
  78. data/vendor/libgit2/src/diff_output.c +1030 -337
  79. data/vendor/libgit2/src/diff_output.h +86 -0
  80. data/vendor/libgit2/src/errors.c +10 -1
  81. data/vendor/libgit2/src/fetch.c +108 -24
  82. data/vendor/libgit2/src/filebuf.c +8 -2
  83. data/vendor/libgit2/src/fileops.c +342 -177
  84. data/vendor/libgit2/src/fileops.h +84 -7
  85. data/vendor/libgit2/src/filter.c +0 -35
  86. data/vendor/libgit2/src/filter.h +0 -12
  87. data/vendor/libgit2/src/{compat/fnmatch.c → fnmatch.c} +16 -4
  88. data/vendor/libgit2/src/{compat/fnmatch.h → fnmatch.h} +4 -3
  89. data/vendor/libgit2/src/global.c +4 -0
  90. data/vendor/libgit2/src/ignore.c +122 -23
  91. data/vendor/libgit2/src/ignore.h +1 -0
  92. data/vendor/libgit2/src/index.c +56 -10
  93. data/vendor/libgit2/src/index.h +2 -0
  94. data/vendor/libgit2/src/indexer.c +8 -9
  95. data/vendor/libgit2/src/iterator.c +244 -31
  96. data/vendor/libgit2/src/iterator.h +30 -1
  97. data/vendor/libgit2/src/message.c +1 -1
  98. data/vendor/libgit2/src/netops.c +44 -4
  99. data/vendor/libgit2/src/object.c +80 -69
  100. data/vendor/libgit2/src/object.h +39 -0
  101. data/vendor/libgit2/src/odb.c +79 -15
  102. data/vendor/libgit2/src/odb.h +20 -5
  103. data/vendor/libgit2/src/odb_pack.c +65 -33
  104. data/vendor/libgit2/src/oid.c +0 -3
  105. data/vendor/libgit2/src/pack-objects.c +1315 -0
  106. data/vendor/libgit2/src/pack-objects.h +87 -0
  107. data/vendor/libgit2/src/pack.c +36 -12
  108. data/vendor/libgit2/src/pack.h +1 -0
  109. data/vendor/libgit2/src/path.c +42 -9
  110. data/vendor/libgit2/src/path.h +14 -0
  111. data/vendor/libgit2/src/pkt.c +52 -2
  112. data/vendor/libgit2/src/pkt.h +10 -0
  113. data/vendor/libgit2/src/pool.h +11 -0
  114. data/vendor/libgit2/src/posix.h +8 -0
  115. data/vendor/libgit2/src/protocol.c +24 -2
  116. data/vendor/libgit2/src/protocol.h +4 -0
  117. data/vendor/libgit2/src/reflog.c +1 -1
  118. data/vendor/libgit2/src/refs.c +292 -124
  119. data/vendor/libgit2/src/refs.h +4 -2
  120. data/vendor/libgit2/src/refspec.c +117 -19
  121. data/vendor/libgit2/src/refspec.h +19 -0
  122. data/vendor/libgit2/src/remote.c +152 -48
  123. data/vendor/libgit2/src/remote.h +4 -1
  124. data/vendor/libgit2/src/repo_template.h +58 -0
  125. data/vendor/libgit2/src/repository.c +594 -179
  126. data/vendor/libgit2/src/repository.h +23 -22
  127. data/vendor/libgit2/src/reset.c +71 -29
  128. data/vendor/libgit2/src/revparse.c +26 -17
  129. data/vendor/libgit2/src/revwalk.c +36 -19
  130. data/vendor/libgit2/src/sha1.h +7 -0
  131. data/vendor/libgit2/src/{sha1.c → sha1/sha1.c} +0 -0
  132. data/vendor/libgit2/src/signature.c +12 -10
  133. data/vendor/libgit2/src/status.c +52 -6
  134. data/vendor/libgit2/src/submodule.c +1363 -255
  135. data/vendor/libgit2/src/submodule.h +102 -0
  136. data/vendor/libgit2/src/tag.c +42 -26
  137. data/vendor/libgit2/src/thread-utils.h +7 -7
  138. data/vendor/libgit2/src/transport.h +15 -1
  139. data/vendor/libgit2/src/transports/git.c +1 -1
  140. data/vendor/libgit2/src/transports/http.c +197 -36
  141. data/vendor/libgit2/src/tree.c +3 -3
  142. data/vendor/libgit2/src/unix/map.c +2 -0
  143. data/vendor/libgit2/src/unix/posix.h +1 -8
  144. data/vendor/libgit2/src/util.c +6 -1
  145. data/vendor/libgit2/src/util.h +7 -0
  146. data/vendor/libgit2/src/vector.c +16 -0
  147. data/vendor/libgit2/src/vector.h +1 -0
  148. data/vendor/libgit2/src/win32/dir.c +8 -21
  149. data/vendor/libgit2/src/win32/findfile.c +149 -0
  150. data/vendor/libgit2/src/win32/findfile.h +23 -0
  151. data/vendor/libgit2/src/win32/posix.h +3 -7
  152. data/vendor/libgit2/src/win32/posix_w32.c +44 -102
  153. data/vendor/libgit2/src/win32/pthread.c +68 -0
  154. data/vendor/libgit2/src/win32/pthread.h +7 -0
  155. data/vendor/libgit2/src/win32/utf-conv.c +60 -71
  156. data/vendor/libgit2/src/win32/utf-conv.h +4 -3
  157. metadata +70 -71
  158. data/vendor/libgit2/include/git2/windows.h +0 -59
@@ -0,0 +1,87 @@
1
+ /*
2
+ * Copyright (C) 2009-2012 the libgit2 contributors
3
+ *
4
+ * This file is part of libgit2, distributed under the GNU GPL v2 with
5
+ * a Linking Exception. For full terms see the included COPYING file.
6
+ */
7
+
8
+ #ifndef INCLUDE_pack_objects_h__
9
+ #define INCLUDE_pack_objects_h__
10
+
11
+ #include "common.h"
12
+
13
+ #include "buffer.h"
14
+ #include "hash.h"
15
+ #include "oidmap.h"
16
+
17
+ #include "git2/oid.h"
18
+
19
+ #define GIT_PACK_WINDOW 10 /* number of objects to possibly delta against */
20
+ #define GIT_PACK_DEPTH 50 /* max delta depth */
21
+ #define GIT_PACK_DELTA_CACHE_SIZE (256 * 1024 * 1024)
22
+ #define GIT_PACK_DELTA_CACHE_LIMIT 1000
23
+ #define GIT_PACK_BIG_FILE_THRESHOLD (512 * 1024 * 1024)
24
+
25
+ typedef struct git_pobject {
26
+ git_oid id;
27
+ git_otype type;
28
+ git_off_t offset;
29
+
30
+ size_t size;
31
+
32
+ unsigned int hash; /* name hint hash */
33
+
34
+ struct git_pobject *delta; /* delta base object */
35
+ struct git_pobject *delta_child; /* deltified objects who bases me */
36
+ struct git_pobject *delta_sibling; /* other deltified objects
37
+ * who uses the same base as
38
+ * me */
39
+
40
+ void *delta_data;
41
+ unsigned long delta_size;
42
+ unsigned long z_delta_size;
43
+
44
+ int written:1,
45
+ recursing:1,
46
+ tagged:1,
47
+ filled:1;
48
+ } git_pobject;
49
+
50
+ struct git_packbuilder {
51
+ git_repository *repo; /* associated repository */
52
+ git_odb *odb; /* associated object database */
53
+
54
+ git_hash_ctx *ctx;
55
+
56
+ uint32_t nr_objects,
57
+ nr_alloc,
58
+ nr_written,
59
+ nr_remaining;
60
+
61
+ git_pobject *object_list;
62
+
63
+ git_oidmap *object_ix;
64
+
65
+ git_oid pack_oid; /* hash of written pack */
66
+
67
+ /* synchronization objects */
68
+ git_mutex cache_mutex;
69
+ git_mutex progress_mutex;
70
+ git_cond progress_cond;
71
+
72
+ /* configs */
73
+ unsigned long delta_cache_size;
74
+ unsigned long max_delta_cache_size;
75
+ unsigned long cache_max_small_delta_size;
76
+ unsigned long big_file_threshold;
77
+ unsigned long window_memory_limit;
78
+
79
+ int nr_threads; /* nr of threads to use */
80
+
81
+ bool done;
82
+ };
83
+
84
+ int git_packbuilder_send(git_packbuilder *pb, git_transport *t);
85
+ int git_packbuilder_write_buf(git_buf *buf, git_packbuilder *pb);
86
+
87
+ #endif /* INCLUDE_pack_objects_h__ */
@@ -54,6 +54,10 @@ static int packfile_error(const char *message)
54
54
 
55
55
  static void pack_index_free(struct git_pack_file *p)
56
56
  {
57
+ if (p->oids) {
58
+ git__free(p->oids);
59
+ p->oids = NULL;
60
+ }
57
61
  if (p->index_map.data) {
58
62
  git_futils_mmap_free(&p->index_map);
59
63
  p->index_map.data = NULL;
@@ -686,13 +690,16 @@ static git_off_t nth_packed_object_offset(const struct git_pack_file *p, uint32_
686
690
  }
687
691
  }
688
692
 
693
+ static int git__memcmp4(const void *a, const void *b) {
694
+ return memcmp(a, b, 4);
695
+ }
696
+
689
697
  int git_pack_foreach_entry(
690
698
  struct git_pack_file *p,
691
699
  int (*cb)(git_oid *oid, void *data),
692
700
  void *data)
693
701
  {
694
702
  const unsigned char *index = p->index_map.data, *current;
695
- unsigned stride;
696
703
  uint32_t i;
697
704
 
698
705
  if (index == NULL) {
@@ -712,21 +719,38 @@ int git_pack_foreach_entry(
712
719
 
713
720
  index += 4 * 256;
714
721
 
715
- if (p->index_version > 1) {
716
- stride = 20;
717
- } else {
718
- stride = 24;
719
- index += 4;
720
- }
722
+ if (p->oids == NULL) {
723
+ git_vector offsets, oids;
724
+ int error;
721
725
 
722
- current = index;
723
- for (i = 0; i < p->num_objects; i++) {
724
- if (cb((git_oid *)current, data))
725
- return GIT_EUSER;
726
+ if ((error = git_vector_init(&oids, p->num_objects, NULL)))
727
+ return error;
728
+
729
+ if ((error = git_vector_init(&offsets, p->num_objects, git__memcmp4)))
730
+ return error;
726
731
 
727
- current += stride;
732
+ if (p->index_version > 1) {
733
+ const unsigned char *off = index + 24 * p->num_objects;
734
+ for (i = 0; i < p->num_objects; i++)
735
+ git_vector_insert(&offsets, (void*)&off[4 * i]);
736
+ git_vector_sort(&offsets);
737
+ git_vector_foreach(&offsets, i, current)
738
+ git_vector_insert(&oids, (void*)&index[5 * (current - off)]);
739
+ } else {
740
+ for (i = 0; i < p->num_objects; i++)
741
+ git_vector_insert(&offsets, (void*)&index[24 * i]);
742
+ git_vector_sort(&offsets);
743
+ git_vector_foreach(&offsets, i, current)
744
+ git_vector_insert(&oids, (void*)&current[4]);
745
+ }
746
+ git_vector_free(&offsets);
747
+ p->oids = (git_oid **)oids.contents;
728
748
  }
729
749
 
750
+ for (i = 0; i < p->num_objects; i++)
751
+ if (cb(p->oids[i], data))
752
+ return GIT_EUSER;
753
+
730
754
  return 0;
731
755
  }
732
756
 
@@ -64,6 +64,7 @@ struct git_pack_file {
64
64
  unsigned pack_local:1, pack_keep:1, has_cache:1;
65
65
  git_oid sha1;
66
66
  git_vector cache;
67
+ git_oid **oids;
67
68
 
68
69
  /* something like ".git/objects/pack/xxxxx.pack" */
69
70
  char pack_name[GIT_FLEX_ARRAY]; /* more */
@@ -147,6 +147,20 @@ char *git_path_basename(const char *path)
147
147
  return basename;
148
148
  }
149
149
 
150
+ size_t git_path_basename_offset(git_buf *buffer)
151
+ {
152
+ ssize_t slash;
153
+
154
+ if (!buffer || buffer->size <= 0)
155
+ return 0;
156
+
157
+ slash = git_buf_rfind_next(buffer, '/');
158
+
159
+ if (slash >= 0 && buffer->ptr[slash] == '/')
160
+ return (size_t)(slash + 1);
161
+
162
+ return 0;
163
+ }
150
164
 
151
165
  const char *git_path_topdir(const char *path)
152
166
  {
@@ -193,6 +207,31 @@ int git_path_root(const char *path)
193
207
  return -1; /* Not a real error - signals that path is not rooted */
194
208
  }
195
209
 
210
+ int git_path_join_unrooted(
211
+ git_buf *path_out, const char *path, const char *base, ssize_t *root_at)
212
+ {
213
+ int error, root;
214
+
215
+ assert(path && path_out);
216
+
217
+ root = git_path_root(path);
218
+
219
+ if (base != NULL && root < 0) {
220
+ error = git_buf_joinpath(path_out, base, path);
221
+
222
+ if (root_at)
223
+ *root_at = (ssize_t)strlen(base);
224
+ }
225
+ else {
226
+ error = git_buf_sets(path_out, path);
227
+
228
+ if (root_at)
229
+ *root_at = (root < 0) ? 0 : (ssize_t)root;
230
+ }
231
+
232
+ return error;
233
+ }
234
+
196
235
  int git_path_prettify(git_buf *path_out, const char *path, const char *base)
197
236
  {
198
237
  char buf[GIT_PATH_MAX];
@@ -393,14 +432,14 @@ bool git_path_is_empty_dir(const char *path)
393
432
  {
394
433
  git_buf pathbuf = GIT_BUF_INIT;
395
434
  HANDLE hFind = INVALID_HANDLE_VALUE;
396
- wchar_t *wbuf;
435
+ wchar_t wbuf[GIT_WIN_PATH];
397
436
  WIN32_FIND_DATAW ffd;
398
437
  bool retval = true;
399
438
 
400
439
  if (!git_path_isdir(path)) return false;
401
440
 
402
441
  git_buf_printf(&pathbuf, "%s\\*", path);
403
- wbuf = gitwin_to_utf16(git_buf_cstr(&pathbuf));
442
+ git__utf8_to_16(wbuf, GIT_WIN_PATH, git_buf_cstr(&pathbuf));
404
443
 
405
444
  hFind = FindFirstFileW(wbuf, &ffd);
406
445
  if (INVALID_HANDLE_VALUE == hFind) {
@@ -416,7 +455,6 @@ bool git_path_is_empty_dir(const char *path)
416
455
 
417
456
  FindClose(hFind);
418
457
  git_buf_free(&pathbuf);
419
- git__free(wbuf);
420
458
  return retval;
421
459
  }
422
460
 
@@ -502,12 +540,7 @@ bool git_path_contains_file(git_buf *base, const char *file)
502
540
 
503
541
  int git_path_find_dir(git_buf *dir, const char *path, const char *base)
504
542
  {
505
- int error;
506
-
507
- if (base != NULL && git_path_root(path) < 0)
508
- error = git_buf_joinpath(dir, base, path);
509
- else
510
- error = git_buf_sets(dir, path);
543
+ int error = git_path_join_unrooted(dir, path, base, NULL);
511
544
 
512
545
  if (!error) {
513
546
  char buf[GIT_PATH_MAX];
@@ -58,6 +58,11 @@ extern int git_path_dirname_r(git_buf *buffer, const char *path);
58
58
  extern char *git_path_basename(const char *path);
59
59
  extern int git_path_basename_r(git_buf *buffer, const char *path);
60
60
 
61
+ /* Return the offset of the start of the basename. Unlike the other
62
+ * basename functions, this returns 0 if the path is empty.
63
+ */
64
+ extern size_t git_path_basename_offset(git_buf *buffer);
65
+
61
66
  extern const char *git_path_topdir(const char *path);
62
67
 
63
68
  /**
@@ -185,6 +190,15 @@ extern bool git_path_contains_dir(git_buf *parent, const char *subdir);
185
190
  */
186
191
  extern bool git_path_contains_file(git_buf *dir, const char *file);
187
192
 
193
+ /**
194
+ * Prepend base to unrooted path or just copy path over.
195
+ *
196
+ * This will optionally return the index into the path where the "root"
197
+ * is, either the end of the base directory prefix or the path root.
198
+ */
199
+ extern int git_path_join_unrooted(
200
+ git_buf *path_out, const char *path, const char *base, ssize_t *root_at);
201
+
188
202
  /**
189
203
  * Clean up path, prepending base if it is not already rooted.
190
204
  */
@@ -17,6 +17,7 @@
17
17
  #include "netops.h"
18
18
  #include "posix.h"
19
19
  #include "buffer.h"
20
+ #include "protocol.h"
20
21
 
21
22
  #include <ctype.h>
22
23
 
@@ -130,6 +131,42 @@ static int err_pkt(git_pkt **out, const char *line, size_t len)
130
131
  return 0;
131
132
  }
132
133
 
134
+ static int data_pkt(git_pkt **out, const char *line, size_t len)
135
+ {
136
+ git_pkt_data *pkt;
137
+
138
+ line++;
139
+ len--;
140
+ pkt = git__malloc(sizeof(git_pkt_data) + len);
141
+ GITERR_CHECK_ALLOC(pkt);
142
+
143
+ pkt->type = GIT_PKT_DATA;
144
+ pkt->len = (int) len;
145
+ memcpy(pkt->data, line, len);
146
+
147
+ *out = (git_pkt *) pkt;
148
+
149
+ return 0;
150
+ }
151
+
152
+ static int progress_pkt(git_pkt **out, const char *line, size_t len)
153
+ {
154
+ git_pkt_progress *pkt;
155
+
156
+ line++;
157
+ len--;
158
+ pkt = git__malloc(sizeof(git_pkt_progress) + len);
159
+ GITERR_CHECK_ALLOC(pkt);
160
+
161
+ pkt->type = GIT_PKT_PROGRESS;
162
+ pkt->len = (int) len;
163
+ memcpy(pkt->data, line, len);
164
+
165
+ *out = (git_pkt *) pkt;
166
+
167
+ return 0;
168
+ }
169
+
133
170
  /*
134
171
  * Parse an other-ref line.
135
172
  */
@@ -263,8 +300,11 @@ int git_pkt_parse_line(
263
300
 
264
301
  len -= PKT_LEN_SIZE; /* the encoded length includes its own size */
265
302
 
266
- /* Assming the minimal size is actually 4 */
267
- if (!git__prefixcmp(line, "ACK"))
303
+ if (*line == GIT_SIDE_BAND_DATA)
304
+ ret = data_pkt(head, line, len);
305
+ else if (*line == GIT_SIDE_BAND_PROGRESS)
306
+ ret = progress_pkt(head, line, len);
307
+ else if (!git__prefixcmp(line, "ACK"))
268
308
  ret = ack_pkt(head, line, len);
269
309
  else if (!git__prefixcmp(line, "NAK"))
270
310
  ret = nak_pkt(head);
@@ -301,12 +341,22 @@ static int buffer_want_with_caps(git_remote_head *head, git_transport_caps *caps
301
341
  char oid[GIT_OID_HEXSZ +1] = {0};
302
342
  unsigned int len;
303
343
 
344
+ /* Prefer side-band-64k if the server supports both */
345
+ if (caps->side_band) {
346
+ if (caps->side_band_64k)
347
+ git_buf_printf(&str, "%s ", GIT_CAP_SIDE_BAND_64K);
348
+ else
349
+ git_buf_printf(&str, "%s ", GIT_CAP_SIDE_BAND);
350
+ }
304
351
  if (caps->ofs_delta)
305
352
  git_buf_puts(&str, GIT_CAP_OFS_DELTA " ");
306
353
 
307
354
  if (caps->multi_ack)
308
355
  git_buf_puts(&str, GIT_CAP_MULTI_ACK " ");
309
356
 
357
+ if (caps->include_tag)
358
+ git_buf_puts(&str, GIT_CAP_INCLUDE_TAG " ");
359
+
310
360
  if (git_buf_oom(&str))
311
361
  return -1;
312
362
 
@@ -24,6 +24,8 @@ enum git_pkt_type {
24
24
  GIT_PKT_PACK,
25
25
  GIT_PKT_COMMENT,
26
26
  GIT_PKT_ERR,
27
+ GIT_PKT_DATA,
28
+ GIT_PKT_PROGRESS,
27
29
  };
28
30
 
29
31
  /* Used for multi-ack */
@@ -65,6 +67,14 @@ typedef struct {
65
67
  char comment[GIT_FLEX_ARRAY];
66
68
  } git_pkt_comment;
67
69
 
70
+ typedef struct {
71
+ enum git_pkt_type type;
72
+ int len;
73
+ char data[GIT_FLEX_ARRAY];
74
+ } git_pkt_data;
75
+
76
+ typedef git_pkt_data git_pkt_progress;
77
+
68
78
  typedef struct {
69
79
  enum git_pkt_type type;
70
80
  char error[GIT_FLEX_ARRAY];
@@ -75,6 +75,17 @@ extern void git_pool_swap(git_pool *a, git_pool *b);
75
75
  */
76
76
  extern void *git_pool_malloc(git_pool *pool, uint32_t items);
77
77
 
78
+ /**
79
+ * Allocate space and zero it out.
80
+ */
81
+ GIT_INLINE(void *) git_pool_mallocz(git_pool *pool, uint32_t items)
82
+ {
83
+ void *ptr = git_pool_malloc(pool, items);
84
+ if (ptr)
85
+ memset(ptr, 0, (size_t)items * (size_t)pool->item_size);
86
+ return ptr;
87
+ }
88
+
78
89
  /**
79
90
  * Allocate space and duplicate string data into it.
80
91
  *
@@ -10,9 +10,17 @@
10
10
  #include "common.h"
11
11
  #include <fcntl.h>
12
12
  #include <time.h>
13
+ #include "fnmatch.h"
13
14
 
15
+ #ifndef S_IFGITLINK
14
16
  #define S_IFGITLINK 0160000
15
17
  #define S_ISGITLINK(m) (((m) & S_IFMT) == S_IFGITLINK)
18
+ #endif
19
+
20
+ /* if S_ISGID is not defined, then don't try to set it */
21
+ #ifndef S_ISGID
22
+ #define S_ISGID 0
23
+ #endif
16
24
 
17
25
  #if !defined(O_BINARY)
18
26
  #define O_BINARY 0
@@ -45,11 +45,13 @@ int git_protocol_store_refs(git_transport *t, int flushes)
45
45
  return -1;
46
46
  }
47
47
 
48
- if (git_vector_insert(refs, pkt) < 0)
48
+ if (pkt->type != GIT_PKT_FLUSH && git_vector_insert(refs, pkt) < 0)
49
49
  return -1;
50
50
 
51
- if (pkt->type == GIT_PKT_FLUSH)
51
+ if (pkt->type == GIT_PKT_FLUSH) {
52
52
  flush++;
53
+ git_pkt_free(pkt);
54
+ }
53
55
  } while (flush < flushes);
54
56
 
55
57
  return flush;
@@ -80,6 +82,26 @@ int git_protocol_detect_caps(git_pkt_ref *pkt, git_transport_caps *caps)
80
82
  continue;
81
83
  }
82
84
 
85
+ if(!git__prefixcmp(ptr, GIT_CAP_INCLUDE_TAG)) {
86
+ caps->common = caps->include_tag = 1;
87
+ ptr += strlen(GIT_CAP_INCLUDE_TAG);
88
+ continue;
89
+ }
90
+
91
+ /* Keep side-band check after side-band-64k */
92
+ if(!git__prefixcmp(ptr, GIT_CAP_SIDE_BAND_64K)) {
93
+ caps->common = caps->side_band_64k = 1;
94
+ ptr += strlen(GIT_CAP_SIDE_BAND_64K);
95
+ continue;
96
+ }
97
+
98
+ if(!git__prefixcmp(ptr, GIT_CAP_SIDE_BAND)) {
99
+ caps->common = caps->side_band = 1;
100
+ ptr += strlen(GIT_CAP_SIDE_BAND);
101
+ continue;
102
+ }
103
+
104
+
83
105
  /* We don't know this capability, so skip it */
84
106
  ptr = strchr(ptr, ' ');
85
107
  }