commit - 3af5bc7c0bbac60aae03923bb2b0e1f80909016b
commit + 68999b92f2fcbce1a9247328552d8d1bdfc45785
blob - 1808e18cf7f0bbbdfffd9f908325141afd14fdeb
blob + 1e1b77c6cf533bbe40050e6b6b163c8f9fc7ce76
--- got/got.1
+++ got/got.1
.It Cm co
Short alias for
.Cm checkout .
-.It Cm clone Ar repository-URL Op Ar target-directory
+.It Cm clone Oo Fl q Oc Oo Fl v Oc Ar repository-URL Op Ar target-directory
Clone a Git repository at the specified
.Ar repository-URL
into the specified
.Mt user@hostname
.It ssh
Short alias for git+ssh.
+.El
+.Pp
+The options for
+.Cm got clone
+are as follows:
+.Bl -tag -width Ds
+.It Fl q
+Suppress progress reporting output.
+The same option will be passed to
+.Xr ssh 1
+if applicable.
+.It Fl v
+Increase the verbosity of progress reporting output.
+The same option will be passed to
+.Xr ssh 1
+if applicable.
+Multiple -v options increase the verbosity.
+The maximum is 3.
.El
.It Cm update Oo Fl b Ar branch Oc Oo Fl c Ar commit Oc Op Ar path ...
Update an existing work tree to a different commit.
blob - ed5822f45aca5f087b8ce22dde1ffe5c20e024bf
blob + 799c85e6a9ac36118f5cf224443e1b34e1334500
--- got/got.c
+++ got/got.c
__dead static void
usage_clone(void)
{
- fprintf(stderr, "usage: %s clone repository-url [target-directory]\n",
+ fprintf(stderr, "usage: %s clone [-q] [-v] repository-url [target-directory]\n",
getprogname());
exit(1);
}
char last_scaled_size[FMT_SCALED_STRSIZE];
int last_p_indexed;
int last_p_resolved;
+ int verbosity;
};
static const struct got_error *
int p_indexed, p_resolved;
int print_size = 0, print_indexed = 0, print_resolved = 0;
+ if (a->verbosity < 0)
+ return NULL;
+
if (message && message[0] != '\0' && message[0] != '\n') {
printf("\rserver: %s", message);
if (strchr(message, '\n') == 0)
printf("\r");
if (print_size)
printf("%*s fetched", FMT_SCALED_STRSIZE, scaled_size);
- if (print_indexed)
+ if (print_indexed) {
printf("; indexing %d%%", p_indexed);
- if (print_resolved)
+ if (a->verbosity > 0)
+ printf(" (%d/%d)", nobj_indexed, nobj_total);
+ }
+ if (print_resolved) {
printf("; resolving deltas %d%%", p_resolved);
+ if (a->verbosity > 0)
+ printf(" (%d/%d)", nobj_resolved,
+ nobj_total - nobj_loose);
+ }
if (print_size || print_indexed || print_resolved)
fflush(stdout);
char *gitconfig = NULL;
FILE *gitconfig_file = NULL;
ssize_t n;
+ int verbosity = 0;
TAILQ_INIT(&refs);
TAILQ_INIT(&symrefs);
- while ((ch = getopt(argc, argv, "")) != -1) {
+ while ((ch = getopt(argc, argv, "vq")) != -1) {
switch (ch) {
+ case 'v':
+ if (verbosity < 0)
+ verbosity = 0;
+ else if (verbosity < 3)
+ verbosity++;
+ break;
+ case 'q':
+ verbosity = -1;
+ break;
default:
usage_clone();
break;
if (error)
goto done;
- error = got_fetch_connect(&fetchfd, proto, host, port, server_path);
+ error = got_fetch_connect(&fetchfd, proto, host, port, server_path,
+ verbosity);
if (error)
goto done;
- printf("Connected to %s:%s\n", host, port);
+ if (verbosity >= 0)
+ printf("Connected to %s:%s\n", host, port);
fpa.last_scaled_size[0] = '\0';
fpa.last_p_indexed = -1;
fpa.last_p_resolved = -1;
+ fpa.verbosity = verbosity;
error = got_fetch_pack(&pack_hash, &refs, &symrefs, fetchfd,
repo, fetch_progress, &fpa);
if (error)
error = got_object_id_str(&id_str, pack_hash);
if (error)
goto done;
- printf("Fetched %s.pack\n", id_str);
+ if (verbosity >= 0)
+ printf("Fetched %s.pack\n", id_str);
free(id_str);
/* Set up references provided with the pack file. */
if (error)
goto done;
- printf("Setting %s to %s\n", GOT_REF_HEAD,
- got_ref_get_symref_target(symref));
+ if (verbosity > 1) {
+ printf("Setting %s to %s\n", GOT_REF_HEAD,
+ got_ref_get_symref_target(symref));
+ }
error = got_ref_write(symref, repo);
got_ref_close(symref);
blob - f0f4c2b70f5e2d9ddf539d255377ca4dfe299dea
blob + d7b583b6dcab6977ecda8490496bbba79462bc20
--- include/got_fetch.h
+++ include/got_fetch.h
/*
* Attempt to open a connection to a server using the provided protocol
* scheme, hostname port number (as a string) and server-side path.
+ * A verbosity level can be specified; it currently controls the amount
+ * of -v options passed to ssh(1). If the level is -1 ssh(1) will be run
+ * with the -q option.
* If successful return an open file descriptor for the connection which can
* be passed to other functions below, and must be disposed of with close(2).
*/
const struct got_error *got_fetch_connect(int *, const char *, const char *,
- const char *, const char *);
+ const char *, const char *, int);
/* A callback function which gets invoked with progress information to print. */
typedef const struct got_error *(*got_fetch_progress_cb)(void *,
blob - 4a328e642feaf96554b13d853b193a2d4213fbef
blob + c82af734662e46f71c8f251dae7e1932a3a1ce57
--- lib/fetch.c
+++ lib/fetch.c
#define nitems(_a) (sizeof((_a)) / sizeof((_a)[0]))
#endif
+#ifndef MIN
+#define MIN(_a,_b) ((_a) < (_b) ? (_a) : (_b))
+#endif
+
static int
hassuffix(char *base, char *suf)
{
static const struct got_error *
dial_ssh(int *fetchfd, const char *host, const char *port, const char *path,
- const char *direction)
+ const char *direction, int verbosity)
{
const struct got_error *error = NULL;
int pid, pfd[2];
char cmd[64];
+ char *argv[9];
+ int i = 0;
*fetchfd = -1;
+
+ argv[0] = GOT_FETCH_PATH_SSH;
+ if (verbosity == -1) {
+ argv[1 + i++] = "-q";
+ } else {
+ /* ssh(1) allows up to 3 "-v" options. */
+ for (i = 0; i < MIN(3, verbosity); i++)
+ argv[1 + i] = "-v";
+ }
+ argv[1 + i] = "--";
+ argv[2 + i] = (char *)host;
+ argv[3 + i] = (char *)cmd;
+ argv[4 + i] = (char *)path;
+ argv[5 + i] = NULL;
if (pipe(pfd) == -1)
return got_error_from_errno("pipe");
n = snprintf(cmd, sizeof(cmd), "git-%s-pack", direction);
if (n < 0 || n >= sizeof(cmd))
err(1, "snprintf");
- if (execl(GOT_FETCH_PATH_SSH, GOT_FETCH_PATH_SSH, "--",
- host, cmd, path, NULL) == -1)
+ if (execv(GOT_FETCH_PATH_SSH, argv) == -1)
err(1, "execl");
abort(); /* not reached */
} else {
const struct got_error *
got_fetch_connect(int *fetchfd, const char *proto, const char *host,
- const char *port, const char *server_path)
+ const char *port, const char *server_path, int verbosity)
{
const struct got_error *err = NULL;
*fetchfd = -1;
if (strcmp(proto, "ssh") == 0 || strcmp(proto, "git+ssh") == 0)
- err = dial_ssh(fetchfd, host, port, server_path, "upload");
+ err = dial_ssh(fetchfd, host, port, server_path, "upload",
+ verbosity);
else if (strcmp(proto, "git") == 0)
err = dial_git(fetchfd, host, port, server_path, "upload");
else if (strcmp(proto, "http") == 0 || strcmp(proto, "git+http") == 0)