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
@@ -119,6 +119,19 @@ GIT_EXTERN(void) git_repository_set_refdb(git_repository *repo, git_refdb *refdb
119
119
  */
120
120
  GIT_EXTERN(void) git_repository_set_index(git_repository *repo, git_index *index);
121
121
 
122
+ /**
123
+ * Set a repository to be bare.
124
+ *
125
+ * Clear the working directory and set core.bare to true. You may also
126
+ * want to call `git_repository_set_index(repo, NULL)` since a bare repo
127
+ * typically does not have an index, but this function will not do that
128
+ * for you.
129
+ *
130
+ * @param repo Repo to make bare
131
+ * @return 0 on success, <0 on failure
132
+ */
133
+ GIT_EXTERN(int) git_repository_set_bare(git_repository *repo);
134
+
122
135
  /** @} */
123
136
  GIT_END_DECL
124
137
  #endif
@@ -0,0 +1,352 @@
1
+ /*
2
+ * Copyright (C) the libgit2 contributors. All rights reserved.
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_sys_git_transport_h
9
+ #define INCLUDE_sys_git_transport_h
10
+
11
+ #include "git2/net.h"
12
+ #include "git2/types.h"
13
+
14
+ /**
15
+ * @file git2/sys/transport.h
16
+ * @brief Git custom transport registration interfaces and functions
17
+ * @defgroup git_transport Git custom transport registration
18
+ * @ingroup Git
19
+ * @{
20
+ */
21
+
22
+ GIT_BEGIN_DECL
23
+
24
+ typedef enum {
25
+ GIT_TRANSPORTFLAGS_NONE = 0,
26
+ } git_transport_flags_t;
27
+
28
+ typedef struct git_transport git_transport;
29
+
30
+ struct git_transport {
31
+ unsigned int version;
32
+ /* Set progress and error callbacks */
33
+ int (*set_callbacks)(
34
+ git_transport *transport,
35
+ git_transport_message_cb progress_cb,
36
+ git_transport_message_cb error_cb,
37
+ git_transport_certificate_check_cb certificate_check_cb,
38
+ void *payload);
39
+
40
+ /* Connect the transport to the remote repository, using the given
41
+ * direction. */
42
+ int (*connect)(
43
+ git_transport *transport,
44
+ const char *url,
45
+ git_cred_acquire_cb cred_acquire_cb,
46
+ void *cred_acquire_payload,
47
+ int direction,
48
+ int flags);
49
+
50
+ /* This function may be called after a successful call to
51
+ * connect(). The array returned is owned by the transport and
52
+ * is guranteed until the next call of a transport function. */
53
+ int (*ls)(
54
+ const git_remote_head ***out,
55
+ size_t *size,
56
+ git_transport *transport);
57
+
58
+ /* Executes the push whose context is in the git_push object. */
59
+ int (*push)(git_transport *transport, git_push *push);
60
+
61
+ /* This function may be called after a successful call to connect(), when
62
+ * the direction is FETCH. The function performs a negotiation to calculate
63
+ * the wants list for the fetch. */
64
+ int (*negotiate_fetch)(
65
+ git_transport *transport,
66
+ git_repository *repo,
67
+ const git_remote_head * const *refs,
68
+ size_t count);
69
+
70
+ /* This function may be called after a successful call to negotiate_fetch(),
71
+ * when the direction is FETCH. This function retrieves the pack file for
72
+ * the fetch from the remote end. */
73
+ int (*download_pack)(
74
+ git_transport *transport,
75
+ git_repository *repo,
76
+ git_transfer_progress *stats,
77
+ git_transfer_progress_cb progress_cb,
78
+ void *progress_payload);
79
+
80
+ /* Checks to see if the transport is connected */
81
+ int (*is_connected)(git_transport *transport);
82
+
83
+ /* Reads the flags value previously passed into connect() */
84
+ int (*read_flags)(git_transport *transport, int *flags);
85
+
86
+ /* Cancels any outstanding transport operation */
87
+ void (*cancel)(git_transport *transport);
88
+
89
+ /* This function is the reverse of connect() -- it terminates the
90
+ * connection to the remote end. */
91
+ int (*close)(git_transport *transport);
92
+
93
+ /* Frees/destructs the git_transport object. */
94
+ void (*free)(git_transport *transport);
95
+ };
96
+
97
+ #define GIT_TRANSPORT_VERSION 1
98
+ #define GIT_TRANSPORT_INIT {GIT_TRANSPORT_VERSION}
99
+
100
+ /**
101
+ * Initializes a `git_transport` with default values. Equivalent to
102
+ * creating an instance with GIT_TRANSPORT_INIT.
103
+ *
104
+ * @param opts the `git_transport` struct to initialize
105
+ * @param version Version of struct; pass `GIT_TRANSPORT_VERSION`
106
+ * @return Zero on success; -1 on failure.
107
+ */
108
+ GIT_EXTERN(int) git_transport_init(
109
+ git_transport *opts,
110
+ unsigned int version);
111
+
112
+ /**
113
+ * Function to use to create a transport from a URL. The transport database
114
+ * is scanned to find a transport that implements the scheme of the URI (i.e.
115
+ * git:// or http://) and a transport object is returned to the caller.
116
+ *
117
+ * @param out The newly created transport (out)
118
+ * @param owner The git_remote which will own this transport
119
+ * @param url The URL to connect to
120
+ * @return 0 or an error code
121
+ */
122
+ GIT_EXTERN(int) git_transport_new(git_transport **out, git_remote *owner, const char *url);
123
+
124
+ /**
125
+ * Create an ssh transport with custom git command paths
126
+ *
127
+ * This is a factory function suitable for setting as the transport
128
+ * callback in a remote (or for a clone in the options).
129
+ *
130
+ * The payload argument must be a strarray pointer with the paths for
131
+ * the `git-upload-pack` and `git-receive-pack` at index 0 and 1.
132
+ *
133
+ * @param out the resulting transport
134
+ * @param owner the owning remote
135
+ * @param payload a strarray with the paths
136
+ * @return 0 or an error code
137
+ */
138
+ GIT_EXTERN(int) git_transport_ssh_with_paths(git_transport **out, git_remote *owner, void *payload);
139
+
140
+ /* Signature of a function which creates a transport */
141
+ typedef int (*git_transport_cb)(git_transport **out, git_remote *owner, void *param);
142
+
143
+ /**
144
+ * Add a custom transport definition, to be used in addition to the built-in
145
+ * set of transports that come with libgit2.
146
+ *
147
+ * The caller is responsible for synchronizing calls to git_transport_register
148
+ * and git_transport_unregister with other calls to the library that
149
+ * instantiate transports.
150
+ *
151
+ * @param prefix The scheme (ending in "://") to match, i.e. "git://"
152
+ * @param cb The callback used to create an instance of the transport
153
+ * @param param A fixed parameter to pass to cb at creation time
154
+ * @return 0 or an error code
155
+ */
156
+ GIT_EXTERN(int) git_transport_register(
157
+ const char *prefix,
158
+ git_transport_cb cb,
159
+ void *param);
160
+
161
+ /**
162
+ *
163
+ * Unregister a custom transport definition which was previously registered
164
+ * with git_transport_register.
165
+ *
166
+ * @param prefix From the previous call to git_transport_register
167
+ * @return 0 or an error code
168
+ */
169
+ GIT_EXTERN(int) git_transport_unregister(
170
+ const char *prefix);
171
+
172
+ /* Transports which come with libgit2 (match git_transport_cb). The expected
173
+ * value for "param" is listed in-line below. */
174
+
175
+ /**
176
+ * Create an instance of the dummy transport.
177
+ *
178
+ * @param out The newly created transport (out)
179
+ * @param owner The git_remote which will own this transport
180
+ * @param payload You must pass NULL for this parameter.
181
+ * @return 0 or an error code
182
+ */
183
+ GIT_EXTERN(int) git_transport_dummy(
184
+ git_transport **out,
185
+ git_remote *owner,
186
+ /* NULL */ void *payload);
187
+
188
+ /**
189
+ * Create an instance of the local transport.
190
+ *
191
+ * @param out The newly created transport (out)
192
+ * @param owner The git_remote which will own this transport
193
+ * @param payload You must pass NULL for this parameter.
194
+ * @return 0 or an error code
195
+ */
196
+ GIT_EXTERN(int) git_transport_local(
197
+ git_transport **out,
198
+ git_remote *owner,
199
+ /* NULL */ void *payload);
200
+
201
+ /**
202
+ * Create an instance of the smart transport.
203
+ *
204
+ * @param out The newly created transport (out)
205
+ * @param owner The git_remote which will own this transport
206
+ * @param payload A pointer to a git_smart_subtransport_definition
207
+ * @return 0 or an error code
208
+ */
209
+ GIT_EXTERN(int) git_transport_smart(
210
+ git_transport **out,
211
+ git_remote *owner,
212
+ /* (git_smart_subtransport_definition *) */ void *payload);
213
+
214
+ /*
215
+ *** End of base transport interface ***
216
+ *** Begin interface for subtransports for the smart transport ***
217
+ */
218
+
219
+ /* The smart transport knows how to speak the git protocol, but it has no
220
+ * knowledge of how to establish a connection between it and another endpoint,
221
+ * or how to move data back and forth. For this, a subtransport interface is
222
+ * declared, and the smart transport delegates this work to the subtransports.
223
+ * Three subtransports are implemented: git, http, and winhttp. (The http and
224
+ * winhttp transports each implement both http and https.) */
225
+
226
+ /* Subtransports can either be RPC = 0 (persistent connection) or RPC = 1
227
+ * (request/response). The smart transport handles the differences in its own
228
+ * logic. The git subtransport is RPC = 0, while http and winhttp are both
229
+ * RPC = 1. */
230
+
231
+ /* Actions that the smart transport can ask
232
+ * a subtransport to perform */
233
+ typedef enum {
234
+ GIT_SERVICE_UPLOADPACK_LS = 1,
235
+ GIT_SERVICE_UPLOADPACK = 2,
236
+ GIT_SERVICE_RECEIVEPACK_LS = 3,
237
+ GIT_SERVICE_RECEIVEPACK = 4,
238
+ } git_smart_service_t;
239
+
240
+ typedef struct git_smart_subtransport git_smart_subtransport;
241
+ typedef struct git_smart_subtransport_stream git_smart_subtransport_stream;
242
+
243
+ /* A stream used by the smart transport to read and write data
244
+ * from a subtransport */
245
+ struct git_smart_subtransport_stream {
246
+ /* The owning subtransport */
247
+ git_smart_subtransport *subtransport;
248
+
249
+ int (*read)(
250
+ git_smart_subtransport_stream *stream,
251
+ char *buffer,
252
+ size_t buf_size,
253
+ size_t *bytes_read);
254
+
255
+ int (*write)(
256
+ git_smart_subtransport_stream *stream,
257
+ const char *buffer,
258
+ size_t len);
259
+
260
+ void (*free)(
261
+ git_smart_subtransport_stream *stream);
262
+ };
263
+
264
+ /* An implementation of a subtransport which carries data for the
265
+ * smart transport */
266
+ struct git_smart_subtransport {
267
+ int (* action)(
268
+ git_smart_subtransport_stream **out,
269
+ git_smart_subtransport *transport,
270
+ const char *url,
271
+ git_smart_service_t action);
272
+
273
+ /* Subtransports are guaranteed a call to close() between
274
+ * calls to action(), except for the following two "natural" progressions
275
+ * of actions against a constant URL.
276
+ *
277
+ * 1. UPLOADPACK_LS -> UPLOADPACK
278
+ * 2. RECEIVEPACK_LS -> RECEIVEPACK */
279
+ int (*close)(git_smart_subtransport *transport);
280
+
281
+ void (*free)(git_smart_subtransport *transport);
282
+ };
283
+
284
+ /* A function which creates a new subtransport for the smart transport */
285
+ typedef int (*git_smart_subtransport_cb)(
286
+ git_smart_subtransport **out,
287
+ git_transport* owner);
288
+
289
+ typedef struct git_smart_subtransport_definition {
290
+ /* The function to use to create the git_smart_subtransport */
291
+ git_smart_subtransport_cb callback;
292
+
293
+ /* True if the protocol is stateless; false otherwise. For example,
294
+ * http:// is stateless, but git:// is not. */
295
+ unsigned rpc;
296
+ } git_smart_subtransport_definition;
297
+
298
+ /* Smart transport subtransports that come with libgit2 */
299
+
300
+ /**
301
+ * Create an instance of the http subtransport. This subtransport
302
+ * also supports https. On Win32, this subtransport may be implemented
303
+ * using the WinHTTP library.
304
+ *
305
+ * @param out The newly created subtransport
306
+ * @param owner The smart transport to own this subtransport
307
+ * @return 0 or an error code
308
+ */
309
+ GIT_EXTERN(int) git_smart_subtransport_http(
310
+ git_smart_subtransport **out,
311
+ git_transport* owner);
312
+
313
+ /**
314
+ * Create an instance of the git subtransport.
315
+ *
316
+ * @param out The newly created subtransport
317
+ * @param owner The smart transport to own this subtransport
318
+ * @return 0 or an error code
319
+ */
320
+ GIT_EXTERN(int) git_smart_subtransport_git(
321
+ git_smart_subtransport **out,
322
+ git_transport* owner);
323
+
324
+ /**
325
+ * Create an instance of the ssh subtransport.
326
+ *
327
+ * @param out The newly created subtransport
328
+ * @param owner The smart transport to own this subtransport
329
+ * @return 0 or an error code
330
+ */
331
+ GIT_EXTERN(int) git_smart_subtransport_ssh(
332
+ git_smart_subtransport **out,
333
+ git_transport* owner);
334
+
335
+ /**
336
+ * Sets a custom transport factory for the remote. The caller can use this
337
+ * function to override the transport used for this remote when performing
338
+ * network operations.
339
+ *
340
+ * @param remote the remote to configure
341
+ * @param transport_cb the function to use to create a transport
342
+ * @param payload opaque parameter passed to transport_cb
343
+ * @return 0 or an error code
344
+ */
345
+ GIT_EXTERN(int) git_remote_set_transport(
346
+ git_remote *remote,
347
+ git_transport_cb transport_cb,
348
+ void *payload);
349
+
350
+ /** @} */
351
+ GIT_END_DECL
352
+ #endif
@@ -19,30 +19,20 @@
19
19
  GIT_BEGIN_DECL
20
20
 
21
21
  /**
22
- * Init the threading system.
22
+ * Initialize the OpenSSL locks
23
23
  *
24
- * If libgit2 has been built with GIT_THREADS
25
- * on, this function must be called once before
26
- * any other library functions.
24
+ * OpenSSL requires the application to determine how it performs
25
+ * locking. This is a convenience function which libgit2 provides for
26
+ * allocating and initializing the locks as well as setting the
27
+ * locking function to use the system's native locking functions.
27
28
  *
28
- * If libgit2 has been built without GIT_THREADS
29
- * support, this function is a no-op.
29
+ * The locking function will be cleared and the memory will be freed
30
+ * when you call git_threads_sutdown().
30
31
  *
31
- * @return 0 or an error code
32
+ * @return 0 on success, -1 if there are errors or if libgit2 was not
33
+ * built with OpenSSL and threading support.
32
34
  */
33
- GIT_EXTERN(int) git_threads_init(void);
34
-
35
- /**
36
- * Shutdown the threading system.
37
- *
38
- * If libgit2 has been built with GIT_THREADS
39
- * on, this function must be called before shutting
40
- * down the library.
41
- *
42
- * If libgit2 has been built without GIT_THREADS
43
- * support, this function is a no-op.
44
- */
45
- GIT_EXTERN(void) git_threads_shutdown(void);
35
+ GIT_EXTERN(int) git_openssl_set_locking(void);
46
36
 
47
37
  /** @} */
48
38
  GIT_END_DECL
@@ -0,0 +1,111 @@
1
+ /*
2
+ * Copyright (C) the libgit2 contributors. All rights reserved.
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
+ #ifndef INCLUDE_git_transaction_h__
8
+ #define INCLUDE_git_transaction_h__
9
+
10
+ #include "common.h"
11
+ GIT_BEGIN_DECL
12
+
13
+ /**
14
+ * Create a new transaction object
15
+ *
16
+ * This does not lock anything, but sets up the transaction object to
17
+ * know from which repository to lock.
18
+ *
19
+ * @param out the resulting transaction
20
+ * @param repo the repository in which to lock
21
+ * @return 0 or an error code
22
+ */
23
+ GIT_EXTERN(int) git_transaction_new(git_transaction **out, git_repository *repo);
24
+
25
+ /**
26
+ * Lock a reference
27
+ *
28
+ * Lock the specified reference. This is the first step to updating a
29
+ * reference.
30
+ *
31
+ * @param tx the transaction
32
+ * @param refname the reference to lock
33
+ * @return 0 or an error message
34
+ */
35
+ GIT_EXTERN(int) git_transaction_lock_ref(git_transaction *tx, const char *refname);
36
+
37
+ /**
38
+ * Set the target of a reference
39
+ *
40
+ * Set the target of the specified reference. This reference must be
41
+ * locked.
42
+ *
43
+ * @param tx the transaction
44
+ * @param refname reference to update
45
+ * @param target target to set the reference to
46
+ * @param sig signature to use in the reflog; pass NULL to read the identity from the config
47
+ * @param msg message to use in the reflog
48
+ * @return 0, GIT_ENOTFOUND if the reference is not among the locked ones, or an error code
49
+ */
50
+ GIT_EXTERN(int) git_transaction_set_target(git_transaction *tx, const char *refname, const git_oid *target, const git_signature *sig, const char *msg);
51
+
52
+ /**
53
+ * Set the target of a reference
54
+ *
55
+ * Set the target of the specified reference. This reference must be
56
+ * locked.
57
+ *
58
+ * @param tx the transaction
59
+ * @param refname reference to update
60
+ * @param target target to set the reference to
61
+ * @param sig signature to use in the reflog; pass NULL to read the identity from the config
62
+ * @param msg message to use in the reflog
63
+ * @return 0, GIT_ENOTFOUND if the reference is not among the locked ones, or an error code
64
+ */
65
+ GIT_EXTERN(int) git_transaction_set_symbolic_target(git_transaction *tx, const char *refname, const char *target, const git_signature *sig, const char *msg);
66
+
67
+ /**
68
+ * Set the reflog of a reference
69
+ *
70
+ * Set the specified reference's reflog. If this is combined with
71
+ * setting the target, that update won't be written to the reflog.
72
+ *
73
+ * @param tx the transaction
74
+ * @param refname the reference whose reflog to set
75
+ * @param reflog the reflog as it should be written out
76
+ * @return 0, GIT_ENOTFOUND if the reference is not among the locked ones, or an error code
77
+ */
78
+ GIT_EXTERN(int) git_transaction_set_reflog(git_transaction *tx, const char *refname, const git_reflog *reflog);
79
+
80
+ /**
81
+ * Remove a reference
82
+ *
83
+ * @param tx the transaction
84
+ * @param refname the reference to remove
85
+ * @return 0, GIT_ENOTFOUND if the reference is not among the locked ones, or an error code
86
+ */
87
+ GIT_EXTERN(int) git_transaction_remove(git_transaction *tx, const char *refname);
88
+
89
+ /**
90
+ * Commit the changes from the transaction
91
+ *
92
+ * Perform the changes that have been queued. The updates will be made
93
+ * one by one, and the first failure will stop the processing.
94
+ *
95
+ * @param tx the transaction
96
+ * @return 0 or an error code
97
+ */
98
+ GIT_EXTERN(int) git_transaction_commit(git_transaction *tx);
99
+
100
+ /**
101
+ * Free the resources allocated by this transaction
102
+ *
103
+ * If any references remain locked, they will be unlocked without any
104
+ * changes made to them.
105
+ *
106
+ * @param tx the transaction
107
+ */
108
+ GIT_EXTERN(void) git_transaction_free(git_transaction *tx);
109
+
110
+ GIT_END_DECL
111
+ #endif