Blob


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