rugged 0.21.0 → 0.21.1b0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +12 -5
- data/ext/rugged/extconf.rb +8 -8
- data/ext/rugged/rugged.h +1 -1
- data/ext/rugged/rugged_cred.c +23 -0
- data/ext/rugged/rugged_index.c +5 -1
- data/ext/rugged/rugged_remote.c +68 -0
- data/ext/rugged/rugged_repo.c +287 -5
- data/ext/rugged/rugged_tag_collection.c +70 -2
- data/ext/rugged/rugged_tree.c +29 -10
- data/lib/rugged.rb +1 -0
- data/lib/rugged/attributes.rb +41 -0
- data/lib/rugged/diff.rb +0 -1
- data/lib/rugged/diff/line.rb +1 -3
- data/lib/rugged/patch.rb +12 -2
- data/lib/rugged/version.rb +1 -1
- data/vendor/libgit2/CMakeLists.txt +11 -0
- data/vendor/libgit2/cmake/Modules/FindGSSAPI.cmake +324 -0
- data/vendor/libgit2/deps/http-parser/http_parser.h +2 -0
- data/vendor/libgit2/deps/zlib/adler32.c +39 -29
- data/vendor/libgit2/deps/zlib/crc32.c +33 -50
- data/vendor/libgit2/deps/zlib/crc32.h +1 -1
- data/vendor/libgit2/deps/zlib/deflate.c +198 -65
- data/vendor/libgit2/deps/zlib/deflate.h +8 -4
- data/vendor/libgit2/deps/zlib/infback.c +640 -0
- data/vendor/libgit2/deps/zlib/inffast.c +3 -3
- data/vendor/libgit2/deps/zlib/inffixed.h +3 -3
- data/vendor/libgit2/deps/zlib/inflate.c +84 -52
- data/vendor/libgit2/deps/zlib/inftrees.c +15 -39
- data/vendor/libgit2/deps/zlib/trees.c +18 -36
- data/vendor/libgit2/deps/zlib/zconf.h +4 -0
- data/vendor/libgit2/deps/zlib/zlib.h +250 -95
- data/vendor/libgit2/deps/zlib/zutil.c +13 -10
- data/vendor/libgit2/deps/zlib/zutil.h +41 -62
- data/vendor/libgit2/include/git2/attr.h +16 -13
- data/vendor/libgit2/include/git2/buffer.h +16 -0
- data/vendor/libgit2/include/git2/checkout.h +12 -12
- data/vendor/libgit2/include/git2/cherrypick.h +15 -15
- data/vendor/libgit2/include/git2/clone.h +77 -69
- data/vendor/libgit2/include/git2/diff.h +7 -0
- data/vendor/libgit2/include/git2/errors.h +1 -0
- data/vendor/libgit2/include/git2/merge.h +16 -0
- data/vendor/libgit2/include/git2/oid.h +8 -4
- data/vendor/libgit2/include/git2/oidarray.h +40 -0
- data/vendor/libgit2/include/git2/remote.h +5 -24
- data/vendor/libgit2/include/git2/repository.h +4 -1
- data/vendor/libgit2/include/git2/reset.h +4 -0
- data/vendor/libgit2/include/git2/status.h +17 -14
- data/vendor/libgit2/include/git2/submodule.h +18 -0
- data/vendor/libgit2/include/git2/sys/transport.h +354 -0
- data/vendor/libgit2/include/git2/transport.h +34 -327
- data/vendor/libgit2/include/git2/types.h +16 -6
- data/vendor/libgit2/src/array.h +1 -1
- data/vendor/libgit2/src/attr_file.c +14 -1
- data/vendor/libgit2/src/blame.c +0 -1
- data/vendor/libgit2/src/buffer.c +67 -10
- data/vendor/libgit2/src/buffer.h +4 -2
- data/vendor/libgit2/src/cache.c +9 -9
- data/vendor/libgit2/src/cache.h +1 -1
- data/vendor/libgit2/src/checkout.c +118 -23
- data/vendor/libgit2/src/cherrypick.c +41 -44
- data/vendor/libgit2/src/clone.c +94 -56
- data/vendor/libgit2/src/config_file.c +4 -4
- data/vendor/libgit2/src/diff.c +21 -0
- data/vendor/libgit2/src/diff_file.c +1 -0
- data/vendor/libgit2/src/diff_print.c +11 -9
- data/vendor/libgit2/src/diff_tform.c +3 -1
- data/vendor/libgit2/src/errors.c +9 -7
- data/vendor/libgit2/src/fileops.c +5 -3
- data/vendor/libgit2/src/global.c +9 -1
- data/vendor/libgit2/src/global.h +1 -0
- data/vendor/libgit2/src/graph.c +2 -2
- data/vendor/libgit2/src/indexer.c +6 -1
- data/vendor/libgit2/src/merge.c +98 -144
- data/vendor/libgit2/src/merge.h +1 -1
- data/vendor/libgit2/src/netops.c +4 -0
- data/vendor/libgit2/src/oid.c +8 -0
- data/vendor/libgit2/src/oid.h +11 -0
- data/vendor/libgit2/src/oidarray.c +21 -0
- data/vendor/libgit2/src/oidarray.h +18 -0
- data/vendor/libgit2/src/pack.c +1 -4
- data/vendor/libgit2/src/path.c +93 -33
- data/vendor/libgit2/src/path.h +21 -0
- data/vendor/libgit2/src/pool.c +1 -1
- data/vendor/libgit2/src/posix.h +46 -28
- data/vendor/libgit2/src/refs.h +2 -2
- data/vendor/libgit2/src/refspec.c +54 -18
- data/vendor/libgit2/src/remote.c +31 -8
- data/vendor/libgit2/src/remote.h +3 -0
- data/vendor/libgit2/src/repository.c +27 -11
- data/vendor/libgit2/src/revert.c +4 -6
- data/vendor/libgit2/src/revparse.c +15 -18
- data/vendor/libgit2/src/revwalk.c +0 -3
- data/vendor/libgit2/src/signature.c +2 -2
- data/vendor/libgit2/src/stash.c +2 -1
- data/vendor/libgit2/src/status.c +11 -2
- data/vendor/libgit2/src/strnlen.h +2 -1
- data/vendor/libgit2/src/submodule.c +73 -33
- data/vendor/libgit2/src/thread-utils.h +0 -7
- data/vendor/libgit2/src/trace.h +9 -1
- data/vendor/libgit2/src/transport.c +93 -90
- data/vendor/libgit2/src/transports/auth.c +71 -0
- data/vendor/libgit2/src/transports/auth.h +63 -0
- data/vendor/libgit2/src/transports/auth_negotiate.c +275 -0
- data/vendor/libgit2/src/transports/auth_negotiate.h +27 -0
- data/vendor/libgit2/src/transports/cred.c +58 -0
- data/vendor/libgit2/src/transports/cred.h +14 -0
- data/vendor/libgit2/src/transports/cred_helpers.c +3 -0
- data/vendor/libgit2/src/transports/git.c +1 -0
- data/vendor/libgit2/src/transports/http.c +168 -76
- data/vendor/libgit2/src/transports/smart.h +1 -0
- data/vendor/libgit2/src/transports/smart_protocol.c +4 -2
- data/vendor/libgit2/src/transports/ssh.c +214 -38
- data/vendor/libgit2/src/transports/winhttp.c +26 -6
- data/vendor/libgit2/src/unix/posix.h +23 -9
- data/vendor/libgit2/src/unix/realpath.c +8 -7
- data/vendor/libgit2/src/util.c +2 -1
- data/vendor/libgit2/src/util.h +3 -3
- data/vendor/libgit2/src/win32/mingw-compat.h +5 -12
- data/vendor/libgit2/src/win32/msvc-compat.h +3 -32
- data/vendor/libgit2/src/win32/posix.h +20 -31
- data/vendor/libgit2/src/win32/posix_w32.c +33 -4
- metadata +81 -69
@@ -152,6 +152,12 @@ typedef enum {
|
|
152
152
|
*/
|
153
153
|
GIT_DIFF_UPDATE_INDEX = (1u << 15),
|
154
154
|
|
155
|
+
/** Include unreadable files in the diff */
|
156
|
+
GIT_DIFF_INCLUDE_UNREADABLE = (1u << 16),
|
157
|
+
|
158
|
+
/** Include unreadable files in the diff */
|
159
|
+
GIT_DIFF_INCLUDE_UNREADABLE_AS_UNTRACKED = (1u << 17),
|
160
|
+
|
155
161
|
/*
|
156
162
|
* Options controlling how output will be generated
|
157
163
|
*/
|
@@ -237,6 +243,7 @@ typedef enum {
|
|
237
243
|
GIT_DELTA_IGNORED = 6, /**< entry is ignored item in workdir */
|
238
244
|
GIT_DELTA_UNTRACKED = 7, /**< entry is untracked item in workdir */
|
239
245
|
GIT_DELTA_TYPECHANGE = 8, /**< type of entry changed between old and new */
|
246
|
+
GIT_DELTA_UNREADABLE = 9, /**< entry is unreadable */
|
240
247
|
} git_delta_t;
|
241
248
|
|
242
249
|
/**
|
@@ -41,6 +41,7 @@ typedef enum {
|
|
41
41
|
GIT_EMERGECONFLICT = -13, /**< Merge conflicts prevented operation */
|
42
42
|
GIT_ELOCKED = -14, /**< Lock file prevented operation */
|
43
43
|
GIT_EMODIFIED = -15, /**< Reference value does not match expected */
|
44
|
+
GIT_EAUTH = -16, /**< Authentication error */
|
44
45
|
|
45
46
|
GIT_PASSTHROUGH = -30, /**< Internal only */
|
46
47
|
GIT_ITEROVER = -31, /**< Signals end of iteration with iterator */
|
@@ -10,6 +10,7 @@
|
|
10
10
|
#include "common.h"
|
11
11
|
#include "types.h"
|
12
12
|
#include "oid.h"
|
13
|
+
#include "oidarray.h"
|
13
14
|
#include "checkout.h"
|
14
15
|
#include "index.h"
|
15
16
|
|
@@ -320,6 +321,21 @@ GIT_EXTERN(int) git_merge_base(
|
|
320
321
|
const git_oid *one,
|
321
322
|
const git_oid *two);
|
322
323
|
|
324
|
+
/**
|
325
|
+
* Find merge bases between two commits
|
326
|
+
*
|
327
|
+
* @param out array in which to store the resulting ids
|
328
|
+
* @param repo the repository where the commits exist
|
329
|
+
* @param one one of the commits
|
330
|
+
* @param two the other commit
|
331
|
+
* @return 0 on success, GIT_ENOTFOUND if not found or error code
|
332
|
+
*/
|
333
|
+
GIT_EXTERN(int) git_merge_bases(
|
334
|
+
git_oidarray *out,
|
335
|
+
git_repository *repo,
|
336
|
+
const git_oid *one,
|
337
|
+
const git_oid *two);
|
338
|
+
|
323
339
|
/**
|
324
340
|
* Find a merge base given a list of commits
|
325
341
|
*
|
@@ -116,13 +116,17 @@ GIT_EXTERN(void) git_oid_nfmt(char *out, size_t n, const git_oid *id);
|
|
116
116
|
GIT_EXTERN(void) git_oid_pathfmt(char *out, const git_oid *id);
|
117
117
|
|
118
118
|
/**
|
119
|
-
* Format a git_oid into a
|
119
|
+
* Format a git_oid into a statically allocated c-string.
|
120
|
+
*
|
121
|
+
* The c-string is owned by the library and should not be freed
|
122
|
+
* by the user. If libgit2 is built with thread support, the string
|
123
|
+
* will be stored in TLS (i.e. one buffer per thread) to allow for
|
124
|
+
* concurrent calls of the function.
|
120
125
|
*
|
121
126
|
* @param id the oid structure to format
|
122
|
-
* @return the c-string
|
123
|
-
* deallocate the string with git__free().
|
127
|
+
* @return the c-string
|
124
128
|
*/
|
125
|
-
GIT_EXTERN(char *)
|
129
|
+
GIT_EXTERN(char *) git_oid_tostr_s(const git_oid *oid);
|
126
130
|
|
127
131
|
/**
|
128
132
|
* Format a git_oid into a buffer as a hex format c-string.
|
@@ -0,0 +1,40 @@
|
|
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_oidarray_h__
|
8
|
+
#define INCLUDE_git_oidarray_h__
|
9
|
+
|
10
|
+
#include "common.h"
|
11
|
+
#include "oid.h"
|
12
|
+
|
13
|
+
GIT_BEGIN_DECL
|
14
|
+
|
15
|
+
/** Array of object ids */
|
16
|
+
typedef struct git_oidarray {
|
17
|
+
git_oid *ids;
|
18
|
+
size_t count;
|
19
|
+
} git_oidarray;
|
20
|
+
|
21
|
+
/**
|
22
|
+
* Free the OID array
|
23
|
+
*
|
24
|
+
* This method must (and must only) be called on `git_oidarray`
|
25
|
+
* objects where the array is allocated by the library. Not doing so,
|
26
|
+
* will result in a memory leak.
|
27
|
+
*
|
28
|
+
* This does not free the `git_oidarray` itself, since the library will
|
29
|
+
* never allocate that object directly itself (it is more commonly embedded
|
30
|
+
* inside another struct or created on the stack).
|
31
|
+
*
|
32
|
+
* @param array git_oidarray from which to free oid data
|
33
|
+
*/
|
34
|
+
GIT_EXTERN(void) git_oidarray_free(git_oidarray *array);
|
35
|
+
|
36
|
+
/** @} */
|
37
|
+
GIT_END_DECL
|
38
|
+
|
39
|
+
#endif
|
40
|
+
|
@@ -384,15 +384,12 @@ GIT_EXTERN(int) git_remote_fetch(
|
|
384
384
|
const char *reflog_message);
|
385
385
|
|
386
386
|
/**
|
387
|
-
* Return whether a string is a valid remote URL
|
388
387
|
*
|
389
|
-
*
|
390
|
-
*
|
391
|
-
|
392
|
-
|
393
|
-
|
394
|
-
/**
|
395
|
-
* Return whether the passed URL is supported by this version of the library.
|
388
|
+
* Return whether the library supports a particular URL scheme
|
389
|
+
*
|
390
|
+
* Both the built-in and externally-registered transport lists are
|
391
|
+
* searched for a transport which supports the scheme of the given
|
392
|
+
* URL.
|
396
393
|
*
|
397
394
|
* @param url the url to check
|
398
395
|
* @return 1 if the url is supported, 0 otherwise
|
@@ -418,22 +415,6 @@ GIT_EXTERN(int) git_remote_list(git_strarray *out, git_repository *repo);
|
|
418
415
|
*/
|
419
416
|
GIT_EXTERN(void) git_remote_check_cert(git_remote *remote, int check);
|
420
417
|
|
421
|
-
/**
|
422
|
-
* Sets a custom transport for the remote. The caller can use this function
|
423
|
-
* to bypass the automatic discovery of a transport by URL scheme (i.e.
|
424
|
-
* http://, https://, git://) and supply their own transport to be used
|
425
|
-
* instead. After providing the transport to a remote using this function,
|
426
|
-
* the transport object belongs exclusively to that remote, and the remote will
|
427
|
-
* free it when it is freed with git_remote_free.
|
428
|
-
*
|
429
|
-
* @param remote the remote to configure
|
430
|
-
* @param transport the transport object for the remote to use
|
431
|
-
* @return 0 or an error code
|
432
|
-
*/
|
433
|
-
GIT_EXTERN(int) git_remote_set_transport(
|
434
|
-
git_remote *remote,
|
435
|
-
git_transport *transport);
|
436
|
-
|
437
418
|
/**
|
438
419
|
* Argument to the completion callback which tells it which operation
|
439
420
|
* finished.
|
@@ -196,6 +196,8 @@ GIT_EXTERN(int) git_repository_init(
|
|
196
196
|
* looking the "template_path" from the options if set, or the
|
197
197
|
* `init.templatedir` global config if not, or falling back on
|
198
198
|
* "/usr/share/git-core/templates" if it exists.
|
199
|
+
* * GIT_REPOSITORY_INIT_RELATIVE_GITLINK - If an alternate workdir is
|
200
|
+
* specified, use relative paths for the gitdir and core.worktree.
|
199
201
|
*/
|
200
202
|
typedef enum {
|
201
203
|
GIT_REPOSITORY_INIT_BARE = (1u << 0),
|
@@ -204,6 +206,7 @@ typedef enum {
|
|
204
206
|
GIT_REPOSITORY_INIT_MKDIR = (1u << 3),
|
205
207
|
GIT_REPOSITORY_INIT_MKPATH = (1u << 4),
|
206
208
|
GIT_REPOSITORY_INIT_EXTERNAL_TEMPLATE = (1u << 5),
|
209
|
+
GIT_REPOSITORY_INIT_RELATIVE_GITLINK = (1u << 6),
|
207
210
|
} git_repository_init_flag_t;
|
208
211
|
|
209
212
|
/**
|
@@ -662,7 +665,7 @@ typedef enum {
|
|
662
665
|
GIT_REPOSITORY_STATE_NONE,
|
663
666
|
GIT_REPOSITORY_STATE_MERGE,
|
664
667
|
GIT_REPOSITORY_STATE_REVERT,
|
665
|
-
|
668
|
+
GIT_REPOSITORY_STATE_CHERRYPICK,
|
666
669
|
GIT_REPOSITORY_STATE_BISECT,
|
667
670
|
GIT_REPOSITORY_STATE_REBASE,
|
668
671
|
GIT_REPOSITORY_STATE_REBASE_INTERACTIVE,
|
@@ -43,6 +43,7 @@ typedef enum {
|
|
43
43
|
GIT_STATUS_WT_DELETED = (1u << 9),
|
44
44
|
GIT_STATUS_WT_TYPECHANGE = (1u << 10),
|
45
45
|
GIT_STATUS_WT_RENAMED = (1u << 11),
|
46
|
+
GIT_STATUS_WT_UNREADABLE = (1u << 12),
|
46
47
|
|
47
48
|
GIT_STATUS_IGNORED = (1u << 14),
|
48
49
|
} git_status_t;
|
@@ -133,20 +134,22 @@ typedef enum {
|
|
133
134
|
* together as `GIT_STATUS_OPT_DEFAULTS` if you want them as a baseline.
|
134
135
|
*/
|
135
136
|
typedef enum {
|
136
|
-
GIT_STATUS_OPT_INCLUDE_UNTRACKED
|
137
|
-
GIT_STATUS_OPT_INCLUDE_IGNORED
|
138
|
-
GIT_STATUS_OPT_INCLUDE_UNMODIFIED
|
139
|
-
GIT_STATUS_OPT_EXCLUDE_SUBMODULES
|
140
|
-
GIT_STATUS_OPT_RECURSE_UNTRACKED_DIRS
|
141
|
-
GIT_STATUS_OPT_DISABLE_PATHSPEC_MATCH
|
142
|
-
GIT_STATUS_OPT_RECURSE_IGNORED_DIRS
|
143
|
-
GIT_STATUS_OPT_RENAMES_HEAD_TO_INDEX
|
144
|
-
GIT_STATUS_OPT_RENAMES_INDEX_TO_WORKDIR
|
145
|
-
GIT_STATUS_OPT_SORT_CASE_SENSITIVELY
|
146
|
-
GIT_STATUS_OPT_SORT_CASE_INSENSITIVELY
|
147
|
-
GIT_STATUS_OPT_RENAMES_FROM_REWRITES
|
148
|
-
GIT_STATUS_OPT_NO_REFRESH
|
149
|
-
GIT_STATUS_OPT_UPDATE_INDEX
|
137
|
+
GIT_STATUS_OPT_INCLUDE_UNTRACKED = (1u << 0),
|
138
|
+
GIT_STATUS_OPT_INCLUDE_IGNORED = (1u << 1),
|
139
|
+
GIT_STATUS_OPT_INCLUDE_UNMODIFIED = (1u << 2),
|
140
|
+
GIT_STATUS_OPT_EXCLUDE_SUBMODULES = (1u << 3),
|
141
|
+
GIT_STATUS_OPT_RECURSE_UNTRACKED_DIRS = (1u << 4),
|
142
|
+
GIT_STATUS_OPT_DISABLE_PATHSPEC_MATCH = (1u << 5),
|
143
|
+
GIT_STATUS_OPT_RECURSE_IGNORED_DIRS = (1u << 6),
|
144
|
+
GIT_STATUS_OPT_RENAMES_HEAD_TO_INDEX = (1u << 7),
|
145
|
+
GIT_STATUS_OPT_RENAMES_INDEX_TO_WORKDIR = (1u << 8),
|
146
|
+
GIT_STATUS_OPT_SORT_CASE_SENSITIVELY = (1u << 9),
|
147
|
+
GIT_STATUS_OPT_SORT_CASE_INSENSITIVELY = (1u << 10),
|
148
|
+
GIT_STATUS_OPT_RENAMES_FROM_REWRITES = (1u << 11),
|
149
|
+
GIT_STATUS_OPT_NO_REFRESH = (1u << 12),
|
150
|
+
GIT_STATUS_OPT_UPDATE_INDEX = (1u << 13),
|
151
|
+
GIT_STATUS_OPT_INCLUDE_UNREADABLE = (1u << 14),
|
152
|
+
GIT_STATUS_OPT_INCLUDE_UNREADABLE_AS_UNTRACKED = (1u << 15),
|
150
153
|
} git_status_opt_t;
|
151
154
|
|
152
155
|
#define GIT_STATUS_OPT_DEFAULTS \
|
@@ -470,6 +470,24 @@ GIT_EXTERN(git_submodule_recurse_t) git_submodule_set_fetch_recurse_submodules(
|
|
470
470
|
*/
|
471
471
|
GIT_EXTERN(int) git_submodule_init(git_submodule *submodule, int overwrite);
|
472
472
|
|
473
|
+
/**
|
474
|
+
* Set up the subrepository for a submodule in preparation for clone.
|
475
|
+
*
|
476
|
+
* This function can be called to init and set up a submodule
|
477
|
+
* repository from a submodule in preparation to clone it from
|
478
|
+
* its remote.
|
479
|
+
*
|
480
|
+
* @param out Output pointer to the created git repository.
|
481
|
+
* @param sm The submodule to create a new subrepository from.
|
482
|
+
* @param use_gitlink Should the workdir contain a gitlink to
|
483
|
+
* the repo in .git/modules vs. repo directly in workdir.
|
484
|
+
* @return 0 on success, <0 on failure.
|
485
|
+
*/
|
486
|
+
GIT_EXTERN(int) git_submodule_repo_init(
|
487
|
+
git_repository **out,
|
488
|
+
const git_submodule *sm,
|
489
|
+
int use_gitlink);
|
490
|
+
|
473
491
|
/**
|
474
492
|
* Copy submodule remote info into submodule repo.
|
475
493
|
*
|
@@ -0,0 +1,354 @@
|
|
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
|
+
/* If the connection is secured with SSL/TLS, the authenticity
|
27
|
+
* of the server certificate should not be verified. */
|
28
|
+
GIT_TRANSPORTFLAGS_NO_CHECK_CERT = 1
|
29
|
+
} git_transport_flags_t;
|
30
|
+
|
31
|
+
typedef struct git_transport git_transport;
|
32
|
+
|
33
|
+
struct git_transport {
|
34
|
+
unsigned int version;
|
35
|
+
/* Set progress and error callbacks */
|
36
|
+
int (*set_callbacks)(
|
37
|
+
git_transport *transport,
|
38
|
+
git_transport_message_cb progress_cb,
|
39
|
+
git_transport_message_cb error_cb,
|
40
|
+
void *payload);
|
41
|
+
|
42
|
+
/* Connect the transport to the remote repository, using the given
|
43
|
+
* direction. */
|
44
|
+
int (*connect)(
|
45
|
+
git_transport *transport,
|
46
|
+
const char *url,
|
47
|
+
git_cred_acquire_cb cred_acquire_cb,
|
48
|
+
void *cred_acquire_payload,
|
49
|
+
int direction,
|
50
|
+
int flags);
|
51
|
+
|
52
|
+
/* This function may be called after a successful call to
|
53
|
+
* connect(). The array returned is owned by the transport and
|
54
|
+
* is guranteed until the next call of a transport function. */
|
55
|
+
int (*ls)(
|
56
|
+
const git_remote_head ***out,
|
57
|
+
size_t *size,
|
58
|
+
git_transport *transport);
|
59
|
+
|
60
|
+
/* Executes the push whose context is in the git_push object. */
|
61
|
+
int (*push)(git_transport *transport, git_push *push);
|
62
|
+
|
63
|
+
/* This function may be called after a successful call to connect(), when
|
64
|
+
* the direction is FETCH. The function performs a negotiation to calculate
|
65
|
+
* the wants list for the fetch. */
|
66
|
+
int (*negotiate_fetch)(
|
67
|
+
git_transport *transport,
|
68
|
+
git_repository *repo,
|
69
|
+
const git_remote_head * const *refs,
|
70
|
+
size_t count);
|
71
|
+
|
72
|
+
/* This function may be called after a successful call to negotiate_fetch(),
|
73
|
+
* when the direction is FETCH. This function retrieves the pack file for
|
74
|
+
* the fetch from the remote end. */
|
75
|
+
int (*download_pack)(
|
76
|
+
git_transport *transport,
|
77
|
+
git_repository *repo,
|
78
|
+
git_transfer_progress *stats,
|
79
|
+
git_transfer_progress_cb progress_cb,
|
80
|
+
void *progress_payload);
|
81
|
+
|
82
|
+
/* Checks to see if the transport is connected */
|
83
|
+
int (*is_connected)(git_transport *transport);
|
84
|
+
|
85
|
+
/* Reads the flags value previously passed into connect() */
|
86
|
+
int (*read_flags)(git_transport *transport, int *flags);
|
87
|
+
|
88
|
+
/* Cancels any outstanding transport operation */
|
89
|
+
void (*cancel)(git_transport *transport);
|
90
|
+
|
91
|
+
/* This function is the reverse of connect() -- it terminates the
|
92
|
+
* connection to the remote end. */
|
93
|
+
int (*close)(git_transport *transport);
|
94
|
+
|
95
|
+
/* Frees/destructs the git_transport object. */
|
96
|
+
void (*free)(git_transport *transport);
|
97
|
+
};
|
98
|
+
|
99
|
+
#define GIT_TRANSPORT_VERSION 1
|
100
|
+
#define GIT_TRANSPORT_INIT {GIT_TRANSPORT_VERSION}
|
101
|
+
|
102
|
+
/**
|
103
|
+
* Initializes a `git_transport` with default values. Equivalent to
|
104
|
+
* creating an instance with GIT_TRANSPORT_INIT.
|
105
|
+
*
|
106
|
+
* @param opts the `git_transport` struct to initialize
|
107
|
+
* @param version Version of struct; pass `GIT_TRANSPORT_VERSION`
|
108
|
+
* @return Zero on success; -1 on failure.
|
109
|
+
*/
|
110
|
+
GIT_EXTERN(int) git_transport_init(
|
111
|
+
git_transport *opts,
|
112
|
+
unsigned int version);
|
113
|
+
|
114
|
+
/**
|
115
|
+
* Function to use to create a transport from a URL. The transport database
|
116
|
+
* is scanned to find a transport that implements the scheme of the URI (i.e.
|
117
|
+
* git:// or http://) and a transport object is returned to the caller.
|
118
|
+
*
|
119
|
+
* @param out The newly created transport (out)
|
120
|
+
* @param owner The git_remote which will own this transport
|
121
|
+
* @param url The URL to connect to
|
122
|
+
* @return 0 or an error code
|
123
|
+
*/
|
124
|
+
GIT_EXTERN(int) git_transport_new(git_transport **out, git_remote *owner, const char *url);
|
125
|
+
|
126
|
+
/**
|
127
|
+
* Create an ssh transport with custom git command paths
|
128
|
+
*
|
129
|
+
* This is a factory function suitable for setting as the transport
|
130
|
+
* callback in a remote (or for a clone in the options).
|
131
|
+
*
|
132
|
+
* The payload argument must be a strarray pointer with the paths for
|
133
|
+
* the `git-upload-pack` and `git-receive-pack` at index 0 and 1.
|
134
|
+
*
|
135
|
+
* @param out the resulting transport
|
136
|
+
* @param owner the owning remote
|
137
|
+
* @param payload a strarray with the paths
|
138
|
+
* @return 0 or an error code
|
139
|
+
*/
|
140
|
+
GIT_EXTERN(int) git_transport_ssh_with_paths(git_transport **out, git_remote *owner, void *payload);
|
141
|
+
|
142
|
+
/* Signature of a function which creates a transport */
|
143
|
+
typedef int (*git_transport_cb)(git_transport **out, git_remote *owner, void *param);
|
144
|
+
|
145
|
+
/**
|
146
|
+
* Add a custom transport definition, to be used in addition to the built-in
|
147
|
+
* set of transports that come with libgit2.
|
148
|
+
*
|
149
|
+
* The caller is responsible for synchronizing calls to git_transport_register
|
150
|
+
* and git_transport_unregister with other calls to the library that
|
151
|
+
* instantiate transports.
|
152
|
+
*
|
153
|
+
* @param prefix The scheme (ending in "://") to match, i.e. "git://"
|
154
|
+
* @param cb The callback used to create an instance of the transport
|
155
|
+
* @param param A fixed parameter to pass to cb at creation time
|
156
|
+
* @return 0 or an error code
|
157
|
+
*/
|
158
|
+
GIT_EXTERN(int) git_transport_register(
|
159
|
+
const char *prefix,
|
160
|
+
git_transport_cb cb,
|
161
|
+
void *param);
|
162
|
+
|
163
|
+
/**
|
164
|
+
*
|
165
|
+
* Unregister a custom transport definition which was previously registered
|
166
|
+
* with git_transport_register.
|
167
|
+
*
|
168
|
+
* @param prefix From the previous call to git_transport_register
|
169
|
+
* @return 0 or an error code
|
170
|
+
*/
|
171
|
+
GIT_EXTERN(int) git_transport_unregister(
|
172
|
+
const char *prefix);
|
173
|
+
|
174
|
+
/* Transports which come with libgit2 (match git_transport_cb). The expected
|
175
|
+
* value for "param" is listed in-line below. */
|
176
|
+
|
177
|
+
/**
|
178
|
+
* Create an instance of the dummy transport.
|
179
|
+
*
|
180
|
+
* @param out The newly created transport (out)
|
181
|
+
* @param owner The git_remote which will own this transport
|
182
|
+
* @param payload You must pass NULL for this parameter.
|
183
|
+
* @return 0 or an error code
|
184
|
+
*/
|
185
|
+
GIT_EXTERN(int) git_transport_dummy(
|
186
|
+
git_transport **out,
|
187
|
+
git_remote *owner,
|
188
|
+
/* NULL */ void *payload);
|
189
|
+
|
190
|
+
/**
|
191
|
+
* Create an instance of the local transport.
|
192
|
+
*
|
193
|
+
* @param out The newly created transport (out)
|
194
|
+
* @param owner The git_remote which will own this transport
|
195
|
+
* @param payload You must pass NULL for this parameter.
|
196
|
+
* @return 0 or an error code
|
197
|
+
*/
|
198
|
+
GIT_EXTERN(int) git_transport_local(
|
199
|
+
git_transport **out,
|
200
|
+
git_remote *owner,
|
201
|
+
/* NULL */ void *payload);
|
202
|
+
|
203
|
+
/**
|
204
|
+
* Create an instance of the smart transport.
|
205
|
+
*
|
206
|
+
* @param out The newly created transport (out)
|
207
|
+
* @param owner The git_remote which will own this transport
|
208
|
+
* @param payload A pointer to a git_smart_subtransport_definition
|
209
|
+
* @return 0 or an error code
|
210
|
+
*/
|
211
|
+
GIT_EXTERN(int) git_transport_smart(
|
212
|
+
git_transport **out,
|
213
|
+
git_remote *owner,
|
214
|
+
/* (git_smart_subtransport_definition *) */ void *payload);
|
215
|
+
|
216
|
+
/*
|
217
|
+
*** End of base transport interface ***
|
218
|
+
*** Begin interface for subtransports for the smart transport ***
|
219
|
+
*/
|
220
|
+
|
221
|
+
/* The smart transport knows how to speak the git protocol, but it has no
|
222
|
+
* knowledge of how to establish a connection between it and another endpoint,
|
223
|
+
* or how to move data back and forth. For this, a subtransport interface is
|
224
|
+
* declared, and the smart transport delegates this work to the subtransports.
|
225
|
+
* Three subtransports are implemented: git, http, and winhttp. (The http and
|
226
|
+
* winhttp transports each implement both http and https.) */
|
227
|
+
|
228
|
+
/* Subtransports can either be RPC = 0 (persistent connection) or RPC = 1
|
229
|
+
* (request/response). The smart transport handles the differences in its own
|
230
|
+
* logic. The git subtransport is RPC = 0, while http and winhttp are both
|
231
|
+
* RPC = 1. */
|
232
|
+
|
233
|
+
/* Actions that the smart transport can ask
|
234
|
+
* a subtransport to perform */
|
235
|
+
typedef enum {
|
236
|
+
GIT_SERVICE_UPLOADPACK_LS = 1,
|
237
|
+
GIT_SERVICE_UPLOADPACK = 2,
|
238
|
+
GIT_SERVICE_RECEIVEPACK_LS = 3,
|
239
|
+
GIT_SERVICE_RECEIVEPACK = 4,
|
240
|
+
} git_smart_service_t;
|
241
|
+
|
242
|
+
typedef struct git_smart_subtransport git_smart_subtransport;
|
243
|
+
typedef struct git_smart_subtransport_stream git_smart_subtransport_stream;
|
244
|
+
|
245
|
+
/* A stream used by the smart transport to read and write data
|
246
|
+
* from a subtransport */
|
247
|
+
struct git_smart_subtransport_stream {
|
248
|
+
/* The owning subtransport */
|
249
|
+
git_smart_subtransport *subtransport;
|
250
|
+
|
251
|
+
int (*read)(
|
252
|
+
git_smart_subtransport_stream *stream,
|
253
|
+
char *buffer,
|
254
|
+
size_t buf_size,
|
255
|
+
size_t *bytes_read);
|
256
|
+
|
257
|
+
int (*write)(
|
258
|
+
git_smart_subtransport_stream *stream,
|
259
|
+
const char *buffer,
|
260
|
+
size_t len);
|
261
|
+
|
262
|
+
void (*free)(
|
263
|
+
git_smart_subtransport_stream *stream);
|
264
|
+
};
|
265
|
+
|
266
|
+
/* An implementation of a subtransport which carries data for the
|
267
|
+
* smart transport */
|
268
|
+
struct git_smart_subtransport {
|
269
|
+
int (* action)(
|
270
|
+
git_smart_subtransport_stream **out,
|
271
|
+
git_smart_subtransport *transport,
|
272
|
+
const char *url,
|
273
|
+
git_smart_service_t action);
|
274
|
+
|
275
|
+
/* Subtransports are guaranteed a call to close() between
|
276
|
+
* calls to action(), except for the following two "natural" progressions
|
277
|
+
* of actions against a constant URL.
|
278
|
+
*
|
279
|
+
* 1. UPLOADPACK_LS -> UPLOADPACK
|
280
|
+
* 2. RECEIVEPACK_LS -> RECEIVEPACK */
|
281
|
+
int (*close)(git_smart_subtransport *transport);
|
282
|
+
|
283
|
+
void (*free)(git_smart_subtransport *transport);
|
284
|
+
};
|
285
|
+
|
286
|
+
/* A function which creates a new subtransport for the smart transport */
|
287
|
+
typedef int (*git_smart_subtransport_cb)(
|
288
|
+
git_smart_subtransport **out,
|
289
|
+
git_transport* owner);
|
290
|
+
|
291
|
+
typedef struct git_smart_subtransport_definition {
|
292
|
+
/* The function to use to create the git_smart_subtransport */
|
293
|
+
git_smart_subtransport_cb callback;
|
294
|
+
|
295
|
+
/* True if the protocol is stateless; false otherwise. For example,
|
296
|
+
* http:// is stateless, but git:// is not. */
|
297
|
+
unsigned rpc;
|
298
|
+
} git_smart_subtransport_definition;
|
299
|
+
|
300
|
+
/* Smart transport subtransports that come with libgit2 */
|
301
|
+
|
302
|
+
/**
|
303
|
+
* Create an instance of the http subtransport. This subtransport
|
304
|
+
* also supports https. On Win32, this subtransport may be implemented
|
305
|
+
* using the WinHTTP library.
|
306
|
+
*
|
307
|
+
* @param out The newly created subtransport
|
308
|
+
* @param owner The smart transport to own this subtransport
|
309
|
+
* @return 0 or an error code
|
310
|
+
*/
|
311
|
+
GIT_EXTERN(int) git_smart_subtransport_http(
|
312
|
+
git_smart_subtransport **out,
|
313
|
+
git_transport* owner);
|
314
|
+
|
315
|
+
/**
|
316
|
+
* Create an instance of the git subtransport.
|
317
|
+
*
|
318
|
+
* @param out The newly created subtransport
|
319
|
+
* @param owner The smart transport to own this subtransport
|
320
|
+
* @return 0 or an error code
|
321
|
+
*/
|
322
|
+
GIT_EXTERN(int) git_smart_subtransport_git(
|
323
|
+
git_smart_subtransport **out,
|
324
|
+
git_transport* owner);
|
325
|
+
|
326
|
+
/**
|
327
|
+
* Create an instance of the ssh subtransport.
|
328
|
+
*
|
329
|
+
* @param out The newly created subtransport
|
330
|
+
* @param owner The smart transport to own this subtransport
|
331
|
+
* @return 0 or an error code
|
332
|
+
*/
|
333
|
+
GIT_EXTERN(int) git_smart_subtransport_ssh(
|
334
|
+
git_smart_subtransport **out,
|
335
|
+
git_transport* owner);
|
336
|
+
|
337
|
+
/**
|
338
|
+
* Sets a custom transport factory for the remote. The caller can use this
|
339
|
+
* function to override the transport used for this remote when performing
|
340
|
+
* network operations.
|
341
|
+
*
|
342
|
+
* @param remote the remote to configure
|
343
|
+
* @param transport_cb the function to use to create a transport
|
344
|
+
* @param payload opaque parameter passed to transport_cb
|
345
|
+
* @return 0 or an error code
|
346
|
+
*/
|
347
|
+
GIT_EXTERN(int) git_remote_set_transport(
|
348
|
+
git_remote *remote,
|
349
|
+
git_transport_cb transport_cb,
|
350
|
+
void *payload);
|
351
|
+
|
352
|
+
/** @} */
|
353
|
+
GIT_END_DECL
|
354
|
+
#endif
|