Skip to content

Commit 87d4aed

Browse files
committed
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`
2 parents 1ab13eb + f6bb64d commit 87d4aed

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

builtin/fetch.c

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -712,7 +712,7 @@ static void adjust_refcol_width(const struct ref *ref)
712712
int max, rlen, llen, len;
713713

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

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

751+
if (verbosity < 0)
752+
return;
753+
751754
git_config_get_string_tmp("fetch.output", &format);
752755
if (!strcasecmp(format, "full"))
753756
compact_format = 0;
@@ -827,7 +830,12 @@ static void format_display(struct strbuf *display, char code,
827830
const char *remote, const char *local,
828831
int summary_width)
829832
{
830-
int width = (summary_width + strlen(summary) - gettext_width(summary));
833+
int width;
834+
835+
if (verbosity < 0)
836+
return;
837+
838+
width = (summary_width + strlen(summary) - gettext_width(summary));
831839

832840
strbuf_addf(display, "%c %-*s ", code, width, summary);
833841
if (!compact_format)
@@ -1202,13 +1210,12 @@ static int store_updated_refs(const char *raw_url, const char *remote_name,
12021210
"FETCH_HEAD", summary_width);
12031211
}
12041212
if (note.len) {
1205-
if (verbosity >= 0 && !shown_url) {
1213+
if (!shown_url) {
12061214
fprintf(stderr, _("From %.*s\n"),
12071215
url_len, url);
12081216
shown_url = 1;
12091217
}
1210-
if (verbosity >= 0)
1211-
fprintf(stderr, " %s\n", note.buf);
1218+
fprintf(stderr, " %s\n", note.buf);
12121219
}
12131220
}
12141221
}

0 commit comments

Comments
 (0)