git: 7a6309fdc794 - main - fetch(1): suppress "Not Modified" in quiet mode

From: Eugene Grosbein <eugen_at_FreeBSD.org>
Date: Sat, 07 Sep 2024 02:18:09 UTC
The branch main has been updated by eugen:

URL: https://cgit.FreeBSD.org/src/commit/?id=7a6309fdc79427b0a7a5c3876daba150d946ae22

commit 7a6309fdc79427b0a7a5c3876daba150d946ae22
Author:     Eugene Grosbein <eugen@FreeBSD.org>
AuthorDate: 2024-09-07 02:14:23 +0000
Commit:     Eugene Grosbein <eugen@FreeBSD.org>
CommitDate: 2024-09-07 02:14:23 +0000

    fetch(1): suppress "Not Modified" in quiet mode
    
    "fetch -qi" should skip printing "Not Modified" for successful
    http(s) request. Still print it by default (v_level == 1).
    
    MFC after:      1 week
---
 usr.bin/fetch/fetch.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/usr.bin/fetch/fetch.c b/usr.bin/fetch/fetch.c
index 05c0211ead49..8b3ccbd3ab98 100644
--- a/usr.bin/fetch/fetch.c
+++ b/usr.bin/fetch/fetch.c
@@ -582,16 +582,17 @@ again:
 	if (sigalrm || sigint)
 		goto signal;
 	if (f == NULL) {
-		warnx("%s: %s", URL, fetchLastErrString);
-		if (i_flag && (strcmp(url->scheme, SCHEME_HTTP) == 0 ||
-		    strcmp(url->scheme, SCHEME_HTTPS) == 0) &&
-		    fetchLastErrCode == FETCH_OK &&
+		if (i_flag && *is_http && fetchLastErrCode == FETCH_OK &&
 		    strcmp(fetchLastErrString, "Not Modified") == 0) {
 			/* HTTP Not Modified Response, return OK. */
+			if (v_level > 0)
+				warnx("%s: %s", URL, fetchLastErrString);
 			r = 0;
 			goto done;
-		} else
+		} else {
+			warnx("%s: %s", URL, fetchLastErrString);
 			goto failure;
+		}
 	}
 	if (sigint)
 		goto signal;