git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] http-push: using error() and warning() as appropriate

From
Jeff King <peff@peff.net>
Date
Feb 19, 2009, 12:21 UTC
Message-ID
<20090219122104.GA4602@sigill.intra.peff.net>
In-Reply-To
<20090219120708.GM4371@genesis.frugalware.org>
On Thu, Feb 19, 2009 at 01:07:08PM +0100, Miklos Vajna wrote:
Show 14 quoted lines
> Change three occurrences of using inconsistent error/warning reporting
> by using the relevant error() / warning() calls to be consistent with
> the rest of the code.
> 
> Signed-off-by: Miklos Vajna <vmiklos@frugalware.org>
> ---
> 
> On Thu, Feb 19, 2009 at 03:17:25AM -0500, Jeff King <peff@peff.net> wrote:
> > http-push seems to be the odd man out. It contains one fprintf(stderr,
> > "Error: ...") and one totally bogus error("Error: ..."), which will
> > print "error: Error: ...". Perhaps it would be better to scan through
> > the code and switch to using error() and warning() as appropriate.
> 
> I found these 3 occurrences.
A few more are in the diff below. But there are even more:
  - several "Warning: " lines in *.sh
  - some warnings actually come with "WARNING:" on every line. I don't
    think those should be changed, as they are obviously a more
    strenuous warning.
  - there are several places that manually print "warning: " via
    fprintf. I suppose those can be cleaned up to use warning(), too.
-Peff
---
diff --git a/builtin-mv.c b/builtin-mv.c
index 01270fe..fc6bd82 100644
--- a/builtin-mv.c
+++ b/builtin-mv.c
@@ -172,9 +172,7 @@ int cmd_mv(int argc, const char **argv, const char *prefix)
 				 * check both source and destination
 				 */
 				if (S_ISREG(st.st_mode) || S_ISLNK(st.st_mode)) {
-					fprintf(stderr, "Warning: %s;"
-							" will overwrite!\n",
-							bad);
+					warning("%s; will overwrite!", bad);
 					bad = NULL;
 				} else
 					bad = "Cannot overwrite";
diff --git a/http-walker.c b/http-walker.c
index 0dbad3c..91abea7 100644
--- a/http-walker.c
+++ b/http-walker.c
@@ -235,7 +235,7 @@ static void finish_object_request(struct object_request *obj_req)
 	close(obj_req->local); obj_req->local = -1;
 
 	if (obj_req->http_code == 416) {
-		fprintf(stderr, "Warning: requested range invalid; we may already have all the data.\n");
+		warning("requested range invalid; we may already have all the data.");
 	} else if (obj_req->curl_result != CURLE_OK) {
 		if (stat(obj_req->tmpfile, &st) == 0)
 			if (st.st_size == 0)
Previous: Miklos VajnaNext: Miklos Vajna
Message 5 of 19 in “Change output "error: " to "Error: " etc”
  1. 5/6 Change output "error: " to "Error: " etcJohn Tapsell, Feb 19, 2009
  2. Thomas RastFeb 19, 2009
  3. Jeff KingFeb 19, 2009
  4. http-push: using error() and warning() as appropriateMiklos Vajna, Feb 19, 2009
  5. Jeff KingFeb 19, 2009
  6. 0/8 fprintf(stderr, "warning: ") -> warning() patchesMiklos Vajna, Feb 19, 2009
  7. 1/8 builtin-apply: use warning() instead of fprintf(stderr, "warning: ")Miklos Vajna, Feb 19, 2009
  8. Jeff KingFeb 20, 2009
  9. Junio C HamanoFeb 20, 2009
  10. Miklos VajnaMar 22, 2009
  11. Junio C HamanoMar 22, 2009
  12. Miklos VajnaFeb 20, 2009
  13. 2/8 builtin-checkout: use warning() instead of fprintf(stderr, "warning: ")Miklos Vajna, Feb 19, 2009
  14. 3/8 builtin-fetch-pack: use warning() instead of fprintf(stderr, "warning: ")Miklos Vajna, Feb 19, 2009
  15. 4/8 builtin-init-db: use warning() instead of fprintf(stderr, "warning: ")Miklos Vajna, Feb 19, 2009
  16. 5/8 builtin-rm: use warning() instead of fprintf(stderr, "warning: ")Miklos Vajna, Feb 19, 2009
  17. 6/8 builtin-show-branch: use warning() instead of fprintf(stderr, "warning: ")Miklos Vajna, Feb 19, 2009
  18. 7/8 builtin-show-ref: use warning() instead of fprintf(stderr, "warning: ")Miklos Vajna, Feb 19, 2009
  19. 8/8 refs: use warning() instead of fprintf(stderr, "warning: ")Miklos Vajna, Feb 19, 2009

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.