git: 251d93eda084 - stable/13 - MFC: fetch(1): suppress "Not Modified" in quiet mode

From: Eugene Grosbein <eugen_at_FreeBSD.org>
Date: Sat, 14 Sep 2024 07:36:39 UTC
The branch stable/13 has been updated by eugen:

URL: https://cgit.FreeBSD.org/src/commit/?id=251d93eda084cbae31cb89b42a0a11d4a3121d81

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

    MFC: 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).
    
    (cherry picked from commit 7a6309fdc79427b0a7a5c3876daba150d946ae22)
---
 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 8be5742386e7..bb7d27d896b6 100644
--- a/usr.bin/fetch/fetch.c
+++ b/usr.bin/fetch/fetch.c
@@ -583,16 +583,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;