Blame


1 f8a36e22 2021-08-26 stsp /*
2 f8a36e22 2021-08-26 stsp * Copyright (c) 2018, 2019 Ori Bernstein <ori@openbsd.org>
3 f8a36e22 2021-08-26 stsp * Copyright (c) 2021 Stefan Sperling <stsp@openbsd.org>
4 f8a36e22 2021-08-26 stsp *
5 f8a36e22 2021-08-26 stsp * Permission to use, copy, modify, and distribute this software for any
6 f8a36e22 2021-08-26 stsp * purpose with or without fee is hereby granted, provided that the above
7 f8a36e22 2021-08-26 stsp * copyright notice and this permission notice appear in all copies.
8 f8a36e22 2021-08-26 stsp *
9 f8a36e22 2021-08-26 stsp * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10 f8a36e22 2021-08-26 stsp * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11 f8a36e22 2021-08-26 stsp * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12 f8a36e22 2021-08-26 stsp * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13 f8a36e22 2021-08-26 stsp * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14 f8a36e22 2021-08-26 stsp * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15 f8a36e22 2021-08-26 stsp * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16 f8a36e22 2021-08-26 stsp */
17 f8a36e22 2021-08-26 stsp
18 f8a36e22 2021-08-26 stsp /* IANA assigned */
19 f8a36e22 2021-08-26 stsp #define GOT_DEFAULT_GIT_PORT 9418
20 f8a36e22 2021-08-26 stsp #define GOT_DEFAULT_GIT_PORT_STR "9418"
21 f8a36e22 2021-08-26 stsp
22 f8a36e22 2021-08-26 stsp #ifndef GOT_SEND_PATH_SSH
23 f8a36e22 2021-08-26 stsp #define GOT_SEND_PATH_SSH "/usr/bin/ssh"
24 f8a36e22 2021-08-26 stsp #endif
25 f8a36e22 2021-08-26 stsp
26 f8a36e22 2021-08-26 stsp #define GOT_SEND_DEFAULT_REMOTE_NAME "origin"
27 f8a36e22 2021-08-26 stsp
28 f8a36e22 2021-08-26 stsp #define GOT_SEND_PKTMAX 65536
29 f8a36e22 2021-08-26 stsp
30 f8a36e22 2021-08-26 stsp /*
31 f8a36e22 2021-08-26 stsp * Attempt to open a connection to a server using the provided protocol
32 f8a36e22 2021-08-26 stsp * scheme, hostname port number (as a string) and server-side path.
33 f8a36e22 2021-08-26 stsp * A verbosity level can be specified; it currently controls the amount
34 f8a36e22 2021-08-26 stsp * of -v options passed to ssh(1). If the level is -1 ssh(1) will be run
35 f8a36e22 2021-08-26 stsp * with the -q option.
36 f8a36e22 2021-08-26 stsp *
37 f8a36e22 2021-08-26 stsp * If successful return an open file descriptor for the connection which can
38 f8a36e22 2021-08-26 stsp * be passed to other functions below, and must be disposed of with close(2).
39 f8a36e22 2021-08-26 stsp *
40 f8a36e22 2021-08-26 stsp * If an ssh(1) process was started return its PID as well, in which case
41 f8a36e22 2021-08-26 stsp * the caller should eventually send SIGTERM to the procress and wait for
42 f8a36e22 2021-08-26 stsp * the process to exit with waitpid(2). Otherwise, return PID -1.
43 f8a36e22 2021-08-26 stsp */
44 f8a36e22 2021-08-26 stsp const struct got_error *got_send_connect(pid_t *, int *, const char *,
45 f8a36e22 2021-08-26 stsp const char *, const char *, const char *, int);
46 f8a36e22 2021-08-26 stsp
47 f8a36e22 2021-08-26 stsp /* A callback function which gets invoked with progress information to print. */
48 f8a36e22 2021-08-26 stsp typedef const struct got_error *(*got_send_progress_cb)(void *,
49 f8a36e22 2021-08-26 stsp off_t packfile_size, int ncommits, int nobj_total,
50 f8a36e22 2021-08-26 stsp int nobj_deltify, int nobj_written, off_t bytes_sent,
51 f8a36e22 2021-08-26 stsp const char *refname, int success);
52 f8a36e22 2021-08-26 stsp
53 f8a36e22 2021-08-26 stsp /*
54 f8a36e22 2021-08-26 stsp * Attempt to generate a pack file and sent it to a server.
55 f8a36e22 2021-08-26 stsp * This pack file will contain objects which are reachable in the local
56 f8a36e22 2021-08-26 stsp * repository via the specified branches and tags. Any objects which are
57 f8a36e22 2021-08-26 stsp * already present in the remote repository will be omitted from the
58 f8a36e22 2021-08-26 stsp * pack file.
59 f8a36e22 2021-08-26 stsp *
60 f8a36e22 2021-08-26 stsp * If the server supports deletion of references, attempt to delete
61 f8a36e22 2021-08-26 stsp * branches on the specified delete_branches list from the server.
62 f8a36e22 2021-08-26 stsp * Such branches are not required to exist in the local repository.
63 f8a36e22 2021-08-26 stsp * Requesting deletion of branches results in an error if the server
64 f8a36e22 2021-08-26 stsp * does not support this feature.
65 f8a36e22 2021-08-26 stsp */
66 f8a36e22 2021-08-26 stsp const struct got_error *got_send_pack(const char *remote_name,
67 f8a36e22 2021-08-26 stsp struct got_pathlist_head *branch_names,
68 f8a36e22 2021-08-26 stsp struct got_pathlist_head *tag_names,
69 f8a36e22 2021-08-26 stsp struct got_pathlist_head *delete_branches, int verbosity,
70 f8a36e22 2021-08-26 stsp int overwrite_refs, int sendfd, struct got_repository *repo,
71 f8a36e22 2021-08-26 stsp got_send_progress_cb progress_cb, void *progress_arg,
72 f8a36e22 2021-08-26 stsp got_cancel_cb cancel_cb, void *cancel_arg);