Merge branch 'ps/fetch-omit-formatting-under-quiet'

"git fetch --quiet" optimization to avoid useless computation of
info that will never be displayed.

* ps/fetch-omit-formatting-under-quiet:
  fetch: skip formatting updated refs with `--quiet`
maint
Junio C Hamano 2021-09-10 11:46:20 -07:00
commit 87d4aed743
1 changed files with 12 additions and 5 deletions

View File

@ -712,7 +712,7 @@ static void adjust_refcol_width(const struct ref *ref)
int max, rlen, llen, len; int max, rlen, llen, len;


/* uptodate lines are only shown on high verbosity level */ /* uptodate lines are only shown on high verbosity level */
if (!verbosity && oideq(&ref->peer_ref->old_oid, &ref->old_oid)) if (verbosity <= 0 && oideq(&ref->peer_ref->old_oid, &ref->old_oid))
return; return;


max = term_columns(); max = term_columns();
@ -748,6 +748,9 @@ static void prepare_format_display(struct ref *ref_map)
struct ref *rm; struct ref *rm;
const char *format = "full"; const char *format = "full";


if (verbosity < 0)
return;

git_config_get_string_tmp("fetch.output", &format); git_config_get_string_tmp("fetch.output", &format);
if (!strcasecmp(format, "full")) if (!strcasecmp(format, "full"))
compact_format = 0; compact_format = 0;
@ -827,7 +830,12 @@ static void format_display(struct strbuf *display, char code,
const char *remote, const char *local, const char *remote, const char *local,
int summary_width) int summary_width)
{ {
int width = (summary_width + strlen(summary) - gettext_width(summary)); int width;

if (verbosity < 0)
return;

width = (summary_width + strlen(summary) - gettext_width(summary));


strbuf_addf(display, "%c %-*s ", code, width, summary); strbuf_addf(display, "%c %-*s ", code, width, summary);
if (!compact_format) if (!compact_format)
@ -1202,12 +1210,11 @@ static int store_updated_refs(const char *raw_url, const char *remote_name,
"FETCH_HEAD", summary_width); "FETCH_HEAD", summary_width);
} }
if (note.len) { if (note.len) {
if (verbosity >= 0 && !shown_url) { if (!shown_url) {
fprintf(stderr, _("From %.*s\n"), fprintf(stderr, _("From %.*s\n"),
url_len, url); url_len, url);
shown_url = 1; shown_url = 1;
} }
if (verbosity >= 0)
fprintf(stderr, " %s\n", note.buf); fprintf(stderr, " %s\n", note.buf);
} }
} }