commit 2690194b1af694bf2b56ac50c859ac6439dd6a7a from: Stefan Sperling date: Sat Mar 21 18:17:12 2020 UTC remove GOT_FETCH_DEBUG and toggle fetch debug output with -v option instead commit - 3ef2e71acce6453e0bbb111f8c055c960107dbe9 commit + 2690194b1af694bf2b56ac50c859ac6439dd6a7a blob - 36ad40d7a329ebda0af78195f82299a49ddbbe20 blob + a9c53ae132abc93ff9fc4fcabe4b86fdee16f8d9 --- got/got.1 +++ got/got.1 @@ -262,8 +262,11 @@ 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 +Verbose mode. +Causes +.Cm got clone +to print debugging messages to standard error output. +This option will be passed to .Xr ssh 1 if applicable. Multiple -v options increase the verbosity. @@ -360,7 +363,10 @@ The same option will be passed to .Xr ssh 1 if applicable. .It Fl v -Increase the verbosity of progress reporting output. +Verbose mode. +Causes +.Cm got fetch +to print debugging messages to standard error output. The same option will be passed to .Xr ssh 1 if applicable. @@ -1716,11 +1722,6 @@ The default limit on the number of commits traversed b .Cm got log . If set to zero, the limit is unbounded. This variable will be silently ignored if it is set to a non-numeric value. -.It Ev GOT_FETCH_DEBUG -Enables protocol tracing on standard error output during -.Cm got clone -and -.Cm got fetch . .El .Sh EXIT STATUS .Ex -std got blob - fa79b127c5d4b1291ac080e092e8833d7ad42d60 blob + 81dc494dc6f7fd82e2c94990e8f7b04d2f727eec --- got/got.c +++ got/got.c @@ -1094,7 +1094,7 @@ cmd_clone(int argc, char *argv[]) error = got_fetch_pack(&pack_hash, &refs, &symrefs, GOT_FETCH_DEFAULT_REMOTE_NAME, mirror_references, fetch_all_branches, &wanted_branches, list_refs_only, - fetchfd, repo, fetch_progress, &fpa); + verbosity, fetchfd, repo, fetch_progress, &fpa); if (error) goto done; @@ -1622,7 +1622,7 @@ cmd_fetch(int argc, char *argv[]) fpa.verbosity = verbosity; error = got_fetch_pack(&pack_hash, &refs, &symrefs, remote->name, remote->mirror_references, fetch_all_branches, &wanted_branches, - list_refs_only, fetchfd, repo, fetch_progress, &fpa); + list_refs_only, verbosity, fetchfd, repo, fetch_progress, &fpa); if (error) goto done; blob - a44351f480e1428d56be5b712a963cf8137f1686 blob + 42a3f6350fdf629aaf696b69bd8d27386e5ef3fa --- include/got_fetch.h +++ include/got_fetch.h @@ -66,5 +66,5 @@ typedef const struct got_error *(*got_fetch_progress_c */ const struct got_error *got_fetch_pack(struct got_object_id **, struct got_pathlist_head *, struct got_pathlist_head *, const char *, - int, int, struct got_pathlist_head *, int, int, struct got_repository *, - got_fetch_progress_cb, void *); + int, int, struct got_pathlist_head *, int, int, int, + struct got_repository *, got_fetch_progress_cb, void *); blob - 30d3009ca35c6738728ca92a15e5b4854bfd053f blob + 4442a20cef8658f67a2edc55456e82264944e572 --- lib/fetch.c +++ lib/fetch.c @@ -392,7 +392,7 @@ got_fetch_pack(struct got_object_id **pack_hash, struc struct got_pathlist_head *symrefs, const char *remote_name, int mirror_references, int fetch_all_branches, struct got_pathlist_head *wanted_branches, int list_refs_only, - int fetchfd, struct got_repository *repo, + int verbosity, int fetchfd, struct got_repository *repo, got_fetch_progress_cb progress_cb, void *progress_arg) { int imsg_fetchfds[2], imsg_idxfds[2]; @@ -577,7 +577,7 @@ got_fetch_pack(struct got_object_id **pack_hash, struc goto done; } err = got_privsep_send_fetch_req(&fetchibuf, nfetchfd, &have_refs, - fetch_all_branches, wanted_branches, list_refs_only); + fetch_all_branches, wanted_branches, list_refs_only, verbosity); if (err != NULL) goto done; nfetchfd = -1; blob - b542cec86ba90e8bd23eabe37271fc2faf08ce72 blob + 8c31f36d79e4b53047ca02d2b0f280b70f84eaa9 --- lib/got_lib_privsep.h +++ lib/got_lib_privsep.h @@ -258,6 +258,7 @@ struct got_imsg_fetch_wanted_branch { struct got_imsg_fetch_request { int fetch_all_branches; int list_refs_only; + int verbosity; size_t n_have_refs; size_t n_wanted_branches; /* Followed by n_have_refs GOT_IMSG_FETCH_HAVE_REF messages. */ @@ -402,7 +403,7 @@ const struct got_error *got_privsep_send_index_pack_do const struct got_error *got_privsep_recv_index_progress(int *, int *, int *, int *, int *, struct imsgbuf *ibuf); const struct got_error *got_privsep_send_fetch_req(struct imsgbuf *, int, - struct got_pathlist_head *, int, struct got_pathlist_head *, int); + struct got_pathlist_head *, int, struct got_pathlist_head *, int, int); const struct got_error *got_privsep_send_fetch_outfd(struct imsgbuf *, int); const struct got_error *got_privsep_send_fetch_symrefs(struct imsgbuf *, struct got_pathlist_head *); blob - 2baa585778c31396c55ca867abadd1baae6a09a8 blob + 8c47b66e6079d8494ada12b05443c7d960089ae5 --- lib/privsep.c +++ lib/privsep.c @@ -413,7 +413,8 @@ got_privsep_send_obj(struct imsgbuf *ibuf, struct got_ const struct got_error * got_privsep_send_fetch_req(struct imsgbuf *ibuf, int fd, struct got_pathlist_head *have_refs, int fetch_all_branches, - struct got_pathlist_head *wanted_branches, int list_refs_only) + struct got_pathlist_head *wanted_branches, int list_refs_only, + int verbosity) { const struct got_error *err = NULL; struct ibuf *wbuf; @@ -424,6 +425,7 @@ got_privsep_send_fetch_req(struct imsgbuf *ibuf, int f memset(&fetchreq, 0, sizeof(fetchreq)); fetchreq.fetch_all_branches = fetch_all_branches; fetchreq.list_refs_only = list_refs_only; + fetchreq.verbosity = verbosity; TAILQ_FOREACH(pe, have_refs, entry) fetchreq.n_have_refs++; TAILQ_FOREACH(pe, wanted_branches, entry) blob - 7b8e07cdc8c638e560961994f6c434c45e9a1beb blob + 70f8e799b2fd3c6d65ef1ffdb6df9a97c48d9579 --- libexec/got-fetch-pack/got-fetch-pack.c +++ libexec/got-fetch-pack/got-fetch-pack.c @@ -79,7 +79,7 @@ flushpkt(int fd) { ssize_t w; - if (chattygot) + if (chattygot > 1) fprintf(stderr, "%s: writepkt: 0000\n", getprogname()); w = write(fd, "0000", 4); @@ -111,7 +111,7 @@ read_pkthdr(int *datalen, int fd) return err; if (r == 0) { /* implicit "0000" */ - if (chattygot) + if (chattygot > 1) fprintf(stderr, "%s: readpkt: 0000\n", getprogname()); return NULL; } @@ -173,7 +173,7 @@ readpkt(int *outlen, int fd, char *buf, int buflen) if (n != datalen) return got_error_msg(GOT_ERR_BAD_PACKET, "short packet"); - if (chattygot) { + if (chattygot > 1) { fprintf(stderr, "%s: readpkt: %zd:\t", getprogname(), n); for (i = 0; i < n; i++) { if (isprint(buf[i])) @@ -207,7 +207,7 @@ writepkt(int fd, char *buf, int nbuf) return got_error_from_errno("write"); if (w != nbuf) return got_error(GOT_ERR_IO); - if (chattygot) { + if (chattygot > 1) { fprintf(stderr, "%s: writepkt: %s:\t", getprogname(), len); for (i = 0; i < nbuf; i++) { if (isprint(buf[i])) @@ -310,8 +310,13 @@ parse_refline(char **id_str, char **refname, char **se *id_str = tokens[0]; if (tokens[1]) *refname = tokens[1]; - if (tokens[2]) + if (tokens[2]) { + char *p; *server_capabilities = tokens[2]; + p = strrchr(*server_capabilities, '\n'); + if (p) + *p = '\0'; + } return NULL; } @@ -511,8 +516,6 @@ fetch_pack(int fd, int packfd, struct got_object_id *p err = got_error_from_errno("malloc"); goto done; } - if (chattygot) - fprintf(stderr, "%s: starting fetch\n", getprogname()); while (1) { err = readpkt(&n, fd, buf, sizeof(buf)); if (err) @@ -536,7 +539,7 @@ fetch_pack(int fd, int packfd, struct got_object_id *p if (err) goto done; if (chattygot) - fprintf(stderr, "%s: my capabilities: %s\n", + fprintf(stderr, "%s: my capabilities:%s\n", getprogname(), my_capabilities); err = got_privsep_send_fetch_symrefs(ibuf, &symrefs); if (err) @@ -554,13 +557,14 @@ fetch_pack(int fd, int packfd, struct got_object_id *p } continue; } - if (strstr(refname, "^{}")) + if (strstr(refname, "^{}")) { + if (chattygot) { + fprintf(stderr, "%s: ignoring %s\n", + getprogname(), refname); + } continue; + } - if (chattygot) - fprintf(stderr, "%s: discovered remote ref %s\n", - getprogname(), refname); - if (strncmp(refname, "refs/heads/", 11) == 0) { if (fetch_all_branches || list_refs_only) { found_branch = 1; @@ -569,22 +573,34 @@ fetch_pack(int fd, int packfd, struct got_object_id *p if (match_branch(refname, pe->path)) break; } - if (pe == NULL) + if (pe == NULL) { + if (chattygot) { + fprintf(stderr, + "%s: ignoring %s\n", + getprogname(), refname); + } continue; + } found_branch = 1; } else if (default_branch != NULL) { - if (!match_branch(refname, default_branch)) + if (!match_branch(refname, default_branch)) { + if (chattygot) { + fprintf(stderr, + "%s: ignoring %s\n", + getprogname(), refname); + } continue; + } found_branch = 1; } } else if (strncmp(refname, "refs/tags/", 10) != 0) { - if (chattygot) { - fprintf(stderr, "%s: ignoring '%s' which is " - "neither a branch nor a tag\n", - getprogname(), refname); - } - if (!list_refs_only) + if (!list_refs_only) { + if (chattygot) { + fprintf(stderr, "%s: ignoring %s\n", + getprogname(), refname); + } continue; + } } if (refsz == nref + 1) { @@ -610,7 +626,10 @@ fetch_pack(int fd, int packfd, struct got_object_id *p if (err) goto done; - if (chattygot) { + if (chattygot) + fprintf(stderr, "%s: %s will be fetched\n", + getprogname(), refname); + if (chattygot > 1) { char *theirs, *mine; err = got_object_id_str(&theirs, &want[nref]); if (err) @@ -620,9 +639,7 @@ fetch_pack(int fd, int packfd, struct got_object_id *p free(theirs); goto done; } - fprintf(stderr, "%s: %s will be fetched\n", - getprogname(), refname); - fprintf(stderr, "%s: theirs=%s\n%s: mine=%s\n", + fprintf(stderr, "%s: remote: %s\n%s: local: %s\n", getprogname(), theirs, getprogname(), mine); free(theirs); free(mine); @@ -867,11 +884,6 @@ main(int argc, char **argv) TAILQ_INIT(&have_refs); TAILQ_INIT(&wanted_branches); - - if (getenv("GOT_FETCH_DEBUG") != NULL) { - fprintf(stderr, "%s being chatty!\n", getprogname()); - chattygot = 1; - } imsg_init(&ibuf, GOT_IMSG_FD_CHILD); #ifndef PROFILE @@ -902,6 +914,9 @@ main(int argc, char **argv) fetchfd = imsg.fd; imsg_free(&imsg); + if (fetch_req.verbosity > 0) + chattygot += fetch_req.verbosity; + for (i = 0; i < fetch_req.n_have_refs; i++) { struct got_object_id *id; char *refname;