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
@@ -110,16 +110,6 @@ typedef struct {
110
110
  int binary:1;
111
111
  } git_merge_diff;
112
112
 
113
- /** Internal structure for merge inputs */
114
- struct git_merge_head {
115
- char *ref_name;
116
- char *remote_url;
117
-
118
- git_oid oid;
119
- char oid_str[GIT_OID_HEXSZ+1];
120
- git_commit *commit;
121
- };
122
-
123
113
  int git_merge__bases_many(
124
114
  git_commit_list **out,
125
115
  git_revwalk *walk,
@@ -145,11 +135,11 @@ void git_merge_diff_list__free(git_merge_diff_list *diff_list);
145
135
 
146
136
  int git_merge__setup(
147
137
  git_repository *repo,
148
- const git_merge_head *our_head,
149
- const git_merge_head *heads[],
138
+ const git_annotated_commit *our_head,
139
+ const git_annotated_commit *heads[],
150
140
  size_t heads_len);
151
141
 
152
- int git_merge__indexes(git_repository *repo, git_index *index_new);
142
+ int git_merge__check_result(git_repository *repo, git_index *index_new);
153
143
 
154
144
  int git_merge__append_conflicts_to_merge_msg(git_repository *repo, git_index *index);
155
145
 
@@ -11,6 +11,10 @@
11
11
  #include "fileops.h"
12
12
  #include "map.h"
13
13
  #include "global.h"
14
+ #include "strmap.h"
15
+ #include "pack.h"
16
+
17
+ GIT__USE_STRMAP;
14
18
 
15
19
  #define DEFAULT_WINDOW_SIZE \
16
20
  (sizeof(void*) >= 8 \
@@ -26,20 +30,129 @@ size_t git_mwindow__mapped_limit = DEFAULT_MAPPED_LIMIT;
26
30
  /* Whenever you want to read or modify this, grab git__mwindow_mutex */
27
31
  static git_mwindow_ctl mem_ctl;
28
32
 
29
- /*
30
- * Free all the windows in a sequence, typically because we're done
31
- * with the file
33
+ /* Global list of mwindow files, to open packs once across repos */
34
+ git_strmap *git__pack_cache = NULL;
35
+
36
+ /**
37
+ * Run under mwindow lock
32
38
  */
33
- void git_mwindow_free_all(git_mwindow_file *mwf)
39
+ int git_mwindow_files_init(void)
34
40
  {
35
- git_mwindow_ctl *ctl = &mem_ctl;
36
- size_t i;
41
+ if (git__pack_cache)
42
+ return 0;
43
+
44
+ git__on_shutdown(git_mwindow_files_free);
45
+
46
+ return git_strmap_alloc(&git__pack_cache);
47
+ }
48
+
49
+ void git_mwindow_files_free(void)
50
+ {
51
+ git_strmap *tmp = git__pack_cache;
52
+
53
+ git__pack_cache = NULL;
54
+ git_strmap_free(tmp);
55
+ }
56
+
57
+ int git_mwindow_get_pack(struct git_pack_file **out, const char *path)
58
+ {
59
+ int error;
60
+ char *packname;
61
+ git_strmap_iter pos;
62
+ struct git_pack_file *pack;
63
+
64
+ if ((error = git_packfile__name(&packname, path)) < 0)
65
+ return error;
37
66
 
67
+ if (git_mutex_lock(&git__mwindow_mutex) < 0) {
68
+ giterr_set(GITERR_OS, "failed to lock mwindow mutex");
69
+ return -1;
70
+ }
71
+
72
+ if (git_mwindow_files_init() < 0) {
73
+ git_mutex_unlock(&git__mwindow_mutex);
74
+ git__free(packname);
75
+ return -1;
76
+ }
77
+
78
+ pos = git_strmap_lookup_index(git__pack_cache, packname);
79
+ git__free(packname);
80
+
81
+ if (git_strmap_valid_index(git__pack_cache, pos)) {
82
+ pack = git_strmap_value_at(git__pack_cache, pos);
83
+ git_atomic_inc(&pack->refcount);
84
+
85
+ git_mutex_unlock(&git__mwindow_mutex);
86
+ *out = pack;
87
+ return 0;
88
+ }
89
+
90
+ /* If we didn't find it, we need to create it */
91
+ if ((error = git_packfile_alloc(&pack, path)) < 0) {
92
+ git_mutex_unlock(&git__mwindow_mutex);
93
+ return error;
94
+ }
95
+
96
+ git_atomic_inc(&pack->refcount);
97
+
98
+ git_strmap_insert(git__pack_cache, pack->pack_name, pack, error);
99
+ git_mutex_unlock(&git__mwindow_mutex);
100
+
101
+ if (error < 0) {
102
+ git_packfile_free(pack);
103
+ return -1;
104
+ }
105
+
106
+ *out = pack;
107
+ return 0;
108
+ }
109
+
110
+ void git_mwindow_put_pack(struct git_pack_file *pack)
111
+ {
112
+ int count;
113
+ git_strmap_iter pos;
114
+
115
+ if (git_mutex_lock(&git__mwindow_mutex) < 0)
116
+ return;
117
+
118
+ /* put before get would be a corrupted state */
119
+ assert(git__pack_cache);
120
+
121
+ pos = git_strmap_lookup_index(git__pack_cache, pack->pack_name);
122
+ /* if we cannot find it, the state is corrupted */
123
+ assert(git_strmap_valid_index(git__pack_cache, pos));
124
+
125
+ count = git_atomic_dec(&pack->refcount);
126
+ if (count == 0) {
127
+ git_strmap_delete_at(git__pack_cache, pos);
128
+ git_packfile_free(pack);
129
+ }
130
+
131
+ git_mutex_unlock(&git__mwindow_mutex);
132
+ return;
133
+ }
134
+
135
+ void git_mwindow_free_all(git_mwindow_file *mwf)
136
+ {
38
137
  if (git_mutex_lock(&git__mwindow_mutex)) {
39
138
  giterr_set(GITERR_THREAD, "unable to lock mwindow mutex");
40
139
  return;
41
140
  }
42
141
 
142
+ git_mwindow_free_all_locked(mwf);
143
+
144
+ git_mutex_unlock(&git__mwindow_mutex);
145
+ }
146
+
147
+ /*
148
+ * Free all the windows in a sequence, typically because we're done
149
+ * with the file
150
+ */
151
+ void git_mwindow_free_all_locked(git_mwindow_file *mwf)
152
+ {
153
+ git_mwindow_ctl *ctl = &mem_ctl;
154
+ size_t i;
155
+
43
156
  /*
44
157
  * Remove these windows from the global list
45
158
  */
@@ -67,8 +180,6 @@ void git_mwindow_free_all(git_mwindow_file *mwf)
67
180
  mwf->windows = w->next;
68
181
  git__free(w);
69
182
  }
70
-
71
- git_mutex_unlock(&git__mwindow_mutex);
72
183
  }
73
184
 
74
185
  /*
@@ -36,10 +36,18 @@ typedef struct git_mwindow_ctl {
36
36
  } git_mwindow_ctl;
37
37
 
38
38
  int git_mwindow_contains(git_mwindow *win, git_off_t offset);
39
- void git_mwindow_free_all(git_mwindow_file *mwf);
39
+ void git_mwindow_free_all(git_mwindow_file *mwf); /* locks */
40
+ void git_mwindow_free_all_locked(git_mwindow_file *mwf); /* run under lock */
40
41
  unsigned char *git_mwindow_open(git_mwindow_file *mwf, git_mwindow **cursor, git_off_t offset, size_t extra, unsigned int *left);
41
42
  int git_mwindow_file_register(git_mwindow_file *mwf);
42
43
  void git_mwindow_file_deregister(git_mwindow_file *mwf);
43
44
  void git_mwindow_close(git_mwindow **w_cursor);
44
45
 
46
+ int git_mwindow_files_init(void);
47
+ void git_mwindow_files_free(void);
48
+
49
+ struct git_pack_file; /* just declaration to avoid cyclical includes */
50
+ int git_mwindow_get_pack(struct git_pack_file **out, const char *path);
51
+ void git_mwindow_put_pack(struct git_pack_file *pack);
52
+
45
53
  #endif
@@ -13,6 +13,7 @@
13
13
  # include <netinet/in.h>
14
14
  # include <arpa/inet.h>
15
15
  #else
16
+ # include <winsock2.h>
16
17
  # include <ws2tcpip.h>
17
18
  # ifdef _MSC_VER
18
19
  # pragma comment(lib, "ws2_32")
@@ -275,7 +276,7 @@ static int verify_server_cert(gitno_ssl *ssl, const char *host)
275
276
 
276
277
  if (SSL_get_verify_result(ssl->ssl) != X509_V_OK) {
277
278
  giterr_set(GITERR_SSL, "The SSL certificate is invalid");
278
- return -1;
279
+ return GIT_ECERTIFICATE;
279
280
  }
280
281
 
281
282
  /* Try to parse the host as an IP address to see if it is */
@@ -383,10 +384,10 @@ on_error:
383
384
  cert_fail_name:
384
385
  OPENSSL_free(peer_cn);
385
386
  giterr_set(GITERR_SSL, "hostname does not match certificate");
386
- return -1;
387
+ return GIT_ECERTIFICATE;
387
388
  }
388
389
 
389
- static int ssl_setup(gitno_socket *socket, const char *host, int flags)
390
+ static int ssl_setup(gitno_socket *socket, const char *host)
390
391
  {
391
392
  int ret;
392
393
 
@@ -405,9 +406,6 @@ static int ssl_setup(gitno_socket *socket, const char *host, int flags)
405
406
  if ((ret = SSL_connect(socket->ssl.ssl)) <= 0)
406
407
  return ssl_set_error(&socket->ssl, ret);
407
408
 
408
- if (GITNO_CONNECT_SSL_NO_CHECK_CERT & flags)
409
- return 0;
410
-
411
409
  return verify_server_cert(&socket->ssl, host);
412
410
  }
413
411
  #endif
@@ -493,8 +491,9 @@ int gitno_connect(gitno_socket *s_out, const char *host, const char *port, int f
493
491
  p_freeaddrinfo(info);
494
492
 
495
493
  #ifdef GIT_SSL
496
- if ((flags & GITNO_CONNECT_SSL) && ssl_setup(s_out, host, flags) < 0)
497
- return -1;
494
+ if ((flags & GITNO_CONNECT_SSL) &&
495
+ (ret = ssl_setup(s_out, host)) < 0)
496
+ return ret;
498
497
  #else
499
498
  /* SSL is not supported */
500
499
  if (flags & GITNO_CONNECT_SSL) {
@@ -14,43 +14,33 @@
14
14
  # include <openssl/ssl.h>
15
15
  #endif
16
16
 
17
- struct gitno_ssl {
17
+ typedef struct gitno_ssl {
18
18
  #ifdef GIT_SSL
19
19
  SSL *ssl;
20
20
  #else
21
21
  size_t dummy;
22
22
  #endif
23
- };
24
-
25
- typedef struct gitno_ssl gitno_ssl;
23
+ } gitno_ssl;
26
24
 
27
25
  /* Represents a socket that may or may not be using SSL */
28
- struct gitno_socket {
26
+ typedef struct gitno_socket {
29
27
  GIT_SOCKET socket;
30
28
  gitno_ssl ssl;
31
- };
32
-
33
- typedef struct gitno_socket gitno_socket;
29
+ } gitno_socket;
34
30
 
35
- struct gitno_buffer {
31
+ typedef struct gitno_buffer {
36
32
  char *data;
37
33
  size_t len;
38
34
  size_t offset;
39
35
  gitno_socket *socket;
40
36
  int (*recv)(struct gitno_buffer *buffer);
41
37
  void *cb_data;
42
- };
43
-
44
- typedef struct gitno_buffer gitno_buffer;
38
+ } gitno_buffer;
45
39
 
46
40
  /* Flags to gitno_connect */
47
41
  enum {
48
42
  /* Attempt to create an SSL connection. */
49
43
  GITNO_CONNECT_SSL = 1,
50
-
51
- /* Valid only when GITNO_CONNECT_SSL is also specified.
52
- * Indicates that the server certificate should not be validated. */
53
- GITNO_CONNECT_SSL_NO_CHECK_CERT = 2,
54
44
  };
55
45
 
56
46
  /**
@@ -306,7 +306,11 @@ cleanup:
306
306
  return error;
307
307
  }
308
308
 
309
- static int note_new(git_note **out, git_oid *note_oid, git_blob *blob)
309
+ static int note_new(
310
+ git_note **out,
311
+ git_oid *note_oid,
312
+ git_commit *commit,
313
+ git_blob *blob)
310
314
  {
311
315
  git_note *note = NULL;
312
316
 
@@ -314,6 +318,11 @@ static int note_new(git_note **out, git_oid *note_oid, git_blob *blob)
314
318
  GITERR_CHECK_ALLOC(note);
315
319
 
316
320
  git_oid_cpy(&note->id, note_oid);
321
+
322
+ if (git_signature_dup(&note->author, git_commit_author(commit)) < 0 ||
323
+ git_signature_dup(&note->committer, git_commit_committer(commit)) < 0)
324
+ return -1;
325
+
317
326
  note->message = git__strdup((char *)git_blob_rawcontent(blob));
318
327
  GITERR_CHECK_ALLOC(note->message);
319
328
 
@@ -323,7 +332,11 @@ static int note_new(git_note **out, git_oid *note_oid, git_blob *blob)
323
332
  }
324
333
 
325
334
  static int note_lookup(
326
- git_note **out, git_repository *repo, git_tree *tree, const char *target)
335
+ git_note **out,
336
+ git_repository *repo,
337
+ git_commit *commit,
338
+ git_tree *tree,
339
+ const char *target)
327
340
  {
328
341
  int error, fanout = 0;
329
342
  git_oid oid;
@@ -340,7 +353,7 @@ static int note_lookup(
340
353
  if ((error = git_blob_lookup(&blob, repo, &oid)) < 0)
341
354
  goto cleanup;
342
355
 
343
- if ((error = note_new(&note, &oid, blob)) < 0)
356
+ if ((error = note_new(&note, &oid, commit, blob)) < 0)
344
357
  goto cleanup;
345
358
 
346
359
  *out = note;
@@ -432,7 +445,7 @@ int git_note_read(git_note **out, git_repository *repo,
432
445
 
433
446
  if (!(error = retrieve_note_tree_and_commit(
434
447
  &tree, &commit, repo, &notes_ref)))
435
- error = note_lookup(out, repo, tree, target);
448
+ error = note_lookup(out, repo, commit, tree, target);
436
449
 
437
450
  git__free(target);
438
451
  git_tree_free(tree);
@@ -502,6 +515,18 @@ int git_note_default_ref(const char **out, git_repository *repo)
502
515
  return note_get_default_ref(out, repo);
503
516
  }
504
517
 
518
+ const git_signature *git_note_committer(const git_note *note)
519
+ {
520
+ assert(note);
521
+ return note->committer;
522
+ }
523
+
524
+ const git_signature *git_note_author(const git_note *note)
525
+ {
526
+ assert(note);
527
+ return note->author;
528
+ }
529
+
505
530
  const char * git_note_message(const git_note *note)
506
531
  {
507
532
  assert(note);
@@ -519,6 +544,8 @@ void git_note_free(git_note *note)
519
544
  if (note == NULL)
520
545
  return;
521
546
 
547
+ git_signature_free(note->committer);
548
+ git_signature_free(note->author);
522
549
  git__free(note->message);
523
550
  git__free(note);
524
551
  }
@@ -23,6 +23,9 @@
23
23
  struct git_note {
24
24
  git_oid id;
25
25
 
26
+ git_signature *author;
27
+ git_signature *committer;
28
+
26
29
  char *message;
27
30
  };
28
31
 
@@ -752,6 +752,28 @@ int git_odb__read_header_or_object(
752
752
  return 0;
753
753
  }
754
754
 
755
+ static git_oid empty_blob = {{ 0xe6, 0x9d, 0xe2, 0x9b, 0xb2, 0xd1, 0xd6, 0x43, 0x4b, 0x8b,
756
+ 0x29, 0xae, 0x77, 0x5a, 0xd8, 0xc2, 0xe4, 0x8c, 0x53, 0x91 }};
757
+ static git_oid empty_tree = {{ 0x4b, 0x82, 0x5d, 0xc6, 0x42, 0xcb, 0x6e, 0xb9, 0xa0, 0x60,
758
+ 0xe5, 0x4b, 0xf8, 0xd6, 0x92, 0x88, 0xfb, 0xee, 0x49, 0x04 }};
759
+
760
+ static int hardcoded_objects(git_rawobj *raw, const git_oid *id)
761
+ {
762
+ if (!git_oid_cmp(id, &empty_blob)) {
763
+ raw->type = GIT_OBJ_BLOB;
764
+ raw->len = 0;
765
+ raw->data = NULL;
766
+ return 0;
767
+ } else if (!git_oid_cmp(id, &empty_tree)) {
768
+ raw->type = GIT_OBJ_TREE;
769
+ raw->len = 0;
770
+ raw->data = NULL;
771
+ return 0;
772
+ } else {
773
+ return GIT_ENOTFOUND;
774
+ }
775
+ }
776
+
755
777
  int git_odb_read(git_odb_object **out, git_odb *db, const git_oid *id)
756
778
  {
757
779
  size_t i, reads = 0;
@@ -765,7 +787,7 @@ int git_odb_read(git_odb_object **out, git_odb *db, const git_oid *id)
765
787
  if (*out != NULL)
766
788
  return 0;
767
789
 
768
- error = GIT_ENOTFOUND;
790
+ error = hardcoded_objects(&raw, id);
769
791
 
770
792
  for (i = 0; i < db->backends.length && error < 0; ++i) {
771
793
  backend_internal *internal = git_vector_get(&db->backends, i);
@@ -714,7 +714,7 @@ struct foreach_state {
714
714
  GIT_INLINE(int) filename_to_oid(git_oid *oid, const char *ptr)
715
715
  {
716
716
  int v, i = 0;
717
- if (strlen(ptr) != 41)
717
+ if (strlen(ptr) != GIT_OID_HEXSZ+1)
718
718
  return -1;
719
719
 
720
720
  if (ptr[2] != '/') {