]> git.proxmox.com Git - libgit2.git/blame - src/transport.h
Merge pull request #392 from sschuberth/development
[libgit2.git] / src / transport.h
CommitLineData
bb742ede
VM
1/*
2 * Copyright (C) 2009-2011 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 */
8f866dae
CMN
7#ifndef INCLUDE_transport_h__
8#define INCLUDE_transport_h__
9
10#include "git2/transport.h"
11#include "git2/net.h"
12#include "vector.h"
13
0437d991
CMN
14#define GIT_CAP_OFS_DELTA "ofs-delta"
15
16typedef struct git_transport_caps {
17 int common:1,
87d9869f 18 ofs_delta:1;
0437d991
CMN
19} git_transport_caps;
20
8f866dae
CMN
21/*
22 * A day in the life of a network operation
23 * ========================================
24 *
25 * The library gets told to ls-remote/push/fetch on/to/from some
26 * remote. We look at the URL of the remote and fill the function
27 * table with whatever is appropriate (the remote may be git over git,
28 * ssh or http(s). It may even be an hg or svn repository, the library
29 * at this level doesn't care, it just calls the helpers.
30 *
31 * The first call is to ->connect() which connects to the remote,
32 * making use of the direction if necessary. This function must also
33 * store the remote heads and any other information it needs.
34 *
79e9c3ec
CMN
35 * The next useful step is to call ->ls() to get the list of
36 * references available to the remote. These references may have been
37 * collected on connect, or we may build them now. For ls-remote,
38 * nothing else is needed other than closing the connection.
39 * Otherwise, the higher leves decide which objects we want to
40 * have. ->send_have() is used to tell the other end what we have. If
41 * we do need to download a pack, ->download_pack() is called.
42 *
43 * When we're done, we call ->close() to close the
44 * connection. ->free() takes care of freeing all the resources.
8f866dae
CMN
45 */
46
47struct git_transport {
48 /**
49 * Where the repo lives
50 */
51 char *url;
8f866dae
CMN
52 /**
53 * Whether we want to push or fetch
54 */
a7e34e3c
VM
55 int direction : 1, /* 0 fetch, 1 push */
56 connected : 1;
8f866dae
CMN
57 /**
58 * Connect and store the remote heads
59 */
0ac2726f 60 int (*connect)(struct git_transport *transport, int dir);
8f866dae
CMN
61 /**
62 * Give a list of references, useful for ls-remote
63 */
64 int (*ls)(struct git_transport *transport, git_headarray *headarray);
8f866dae
CMN
65 /**
66 * Push the changes over
67 */
68 int (*push)(struct git_transport *transport);
0e20ba60
CMN
69 /**
70 * Send the list of 'want' refs
71 */
72 int (*send_wants)(struct git_transport *transport, git_headarray *list);
b4c90630
CMN
73 /**
74 * Send the list of 'have' refs
75 */
7e1a94db 76 int (*send_have)(struct git_transport *transport, git_oid *oid);
da290220
CMN
77 /**
78 * Send a 'done' message
79 */
80 int (*send_done)(struct git_transport *transport);
22f65b9e
CMN
81 /**
82 * Negotiate the minimal amount of objects that need to be
83 * retrieved
84 */
85 int (*negotiate_fetch)(struct git_transport *transport, git_repository *repo, git_headarray *list);
da290220
CMN
86 /**
87 * Send a flush
88 */
89 int (*send_flush)(struct git_transport *transport);
90 /**
91 * Download the packfile
92 */
9cf0f287 93 int (*download_pack)(char **out, struct git_transport *transport, git_repository *repo);
8f866dae
CMN
94 /**
95 * Fetch the changes
96 */
97 int (*fetch)(struct git_transport *transport);
98 /**
99 * Close the connection
100 */
101 int (*close)(struct git_transport *transport);
d6258deb
CMN
102 /**
103 * Free the associated resources
104 */
105 void (*free)(struct git_transport *transport);
8f866dae
CMN
106};
107
4e913309
CMN
108int git_transport_local(struct git_transport **transport);
109int git_transport_git(struct git_transport **transport);
110int git_transport_dummy(struct git_transport **transport);
8f866dae
CMN
111
112#endif