# [PATCH 5/6] Change output "error: " to "Error: " etc

19 messages from 2009-02-19 to 2009-03-22. Participants: John Tapsell, Thomas Rast, Jeff King, Miklos Vajna, Junio C Hamano.
Thread: https://gitlist.dev/t/17893

## John Tapsell, 2009-02-19 07:36

Subject: [PATCH 5/6] Change output "error: " to "Error: " etc
Message-ID: <200902190736.49161.johnflux@gmail.com>
URL: https://gitlist.dev/e/200902190736.49161.johnflux%40gmail.com

```
All the error messages starting "Error: " begin with a captial E, except
in one place.  This commit fixes this, making the output look more
consistent.  At the moment a failed push, say, looks like:

Error: cannot lock existing info/refs
error: failed to push some refs to 'some repository'

Signed-off-by: John Tapsell <johnflux@gmail.com>
---
 usage.c |    8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/usage.c b/usage.c
index 24f5fc0..acc4ee1 100644
--- a/usage.c
+++ b/usage.c
@@ -14,24 +14,24 @@ static void report(const char *prefix, const char *err, va_list params)
 
 static NORETURN void usage_builtin(const char *err)
 {
-	fprintf(stderr, "usage: %s\n", err);
+	fprintf(stderr, "Usage: %s\n", err);
 	exit(129);
 }
 
 static NORETURN void die_builtin(const char *err, va_list params)
 {
-	report("fatal: ", err, params);
+	report("Fatal: ", err, params);
 	exit(128);
 }
 
 static void error_builtin(const char *err, va_list params)
 {
-	report("error: ", err, params);
+	report("Error: ", err, params);
 }
 
 static void warn_builtin(const char *warn, va_list params)
 {
-	report("warning: ", warn, params);
+	report("Warning: ", warn, params);
 }
 
 /* If we are in a dlopen()ed .so write to a global variable would segfault
-- 
1.6.2.rc1.3.g7d31b.dirty

```

## Thomas Rast, 2009-02-19 08:14

Subject: Re: [PATCH 5/6] Change output "error: " to "Error: " etc
Message-ID: <200902190915.15227.trast@student.ethz.ch>
URL: https://gitlist.dev/e/200902190915.15227.trast%40student.ethz.ch
In-Reply-To: <200902190736.49161.johnflux@gmail.com>

```
John Tapsell wrote:
> All the error messages starting "Error: " begin with a captial E, except
> in one place.  This commit fixes this, making the output look more
> consistent.  At the moment a failed push, say, looks like:
> 
> Error: cannot lock existing info/refs
> error: failed to push some refs to 'some repository'
[...]
> -	report("fatal: ", err, params);
> +	report("Fatal: ", err, params);

A quick grep says this is going to break the tests:

  t/t1400-update-ref.sh:	 test "warning: Log for '\'master\'' only goes back to $ed." = "$(cat e)"'
  t/t1400-update-ref.sh:	 echo test "warning: Log for '\'master\'' only goes back to $ed." = "$(cat e)"'
  t/t1400-update-ref.sh:	 test "warning: Log for '\''master'\'' only goes back to $ed." = "$(cat e)"'
  t/t1400-update-ref.sh:	 test "warning: Log .git/logs/'"$m has gap after $gd"'." = "$(cat e)"'
  t/t1400-update-ref.sh:	 test "warning: Log .git/logs/'"$m unexpectedly ended on $ld"'." = "$(cat e)"'
  t/t4012-diff-binary.sh:	 detected=`expr "$detected" : "fatal.*at line \\([0-9]*\\)\$"` &&
  t/t4012-diff-binary.sh:	 detected=`expr "$detected" : "fatal.*at line \\([0-9]*\\)\$"` &&
  t/t4018-diff-funcname.sh:			grep "fatal" > /dev/null )
  t/t4018-diff-funcname.sh:	grep "fatal: Last expression must not be negated:"
  t/t5400-send-pack.sh:	grep "warning: to refuse deleting" child/errs &&
  t/t5510-fetch.sh:	grep "fatal: '\''a\\\\!'\''b'\''" result
  t/t5516-fetch-push.sh:	grep "warning: updating the current branch" stderr
  t/t5516-fetch-push.sh:	! grep "warning: updating the current branch" stderr
  t/t5516-fetch-push.sh:	! grep "warning: updating the current branch" stderr
  t/t6300-for-each-ref.sh:		\"error: more than one quoting style\"*) : happy;;
  t/test-lib.sh:	say_color error "error: $*"

That being said, I'm not sure we can change this at all since it's the
plumbing way of reporting errors/warnings.

-- 
Thomas Rast
trast@{inf,student}.ethz.ch

```

## Jeff King, 2009-02-19 08:17

Subject: Re: [PATCH 5/6] Change output "error: " to "Error: " etc
Message-ID: <20090219081725.GB7774@coredump.intra.peff.net>
URL: https://gitlist.dev/e/20090219081725.GB7774%40coredump.intra.peff.net
In-Reply-To: <200902190736.49161.johnflux@gmail.com>

```
On Thu, Feb 19, 2009 at 07:36:49AM +0000, John Tapsell wrote:

> All the error messages starting "Error: " begin with a captial E, except
> in one place.  This commit fixes this, making the output look more
> consistent.  At the moment a failed push, say, looks like:
> 
> Error: cannot lock existing info/refs
> error: failed to push some refs to 'some repository'

I think this commit message is a little misleading. True, there is only
one place where "error:" appears, but it is the place that is called by
almost every piece of code. So by far the majority of errors are "error:
".

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.

That will make things consistent, which addresses your complaint.  And
then there can be a discussion if people want about whether "Error:" or
"error:" is better (personally I like lowercase).

-Peff

```

## Miklos Vajna, 2009-02-19 12:07

Subject: [PATCH] http-push: using error() and warning() as appropriate
Message-ID: <20090219120708.GM4371@genesis.frugalware.org>
URL: https://gitlist.dev/e/20090219120708.GM4371%40genesis.frugalware.org
In-Reply-To: <20090219081725.GB7774@coredump.intra.peff.net>

```
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.

 http-push.c |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/http-push.c b/http-push.c
index 30d2d34..3a41d36 100644
--- a/http-push.c
+++ b/http-push.c
@@ -759,7 +759,7 @@ static void finish_request(struct transfer_request *request)
 			}
 		} else {
 			if (request->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.");
 
 			git_inflate_end(&request->stream);
 			git_SHA1_Final(request->real_sha1, &request->c);
@@ -1616,7 +1616,7 @@ static int locking_available(void)
 			}
 			XML_ParserFree(parser);
 			if (!lock_flags)
-				error("Error: no DAV locking support on %s",
+				error("no DAV locking support on %s",
 				      remote->url);
 
 		} else {
@@ -2293,7 +2293,7 @@ int main(int argc, char **argv)
 		if (info_ref_lock)
 			remote->can_update_info_refs = 1;
 		else {
-			fprintf(stderr, "Error: cannot lock existing info/refs\n");
+			error("cannot lock existing info/refs");
 			rc = 1;
 			goto cleanup;
 		}
-- 
1.6.1

```

## Jeff King, 2009-02-19 12:21

Subject: Re: [PATCH] http-push: using error() and warning() as appropriate
Message-ID: <20090219122104.GA4602@sigill.intra.peff.net>
URL: https://gitlist.dev/e/20090219122104.GA4602%40sigill.intra.peff.net
In-Reply-To: <20090219120708.GM4371@genesis.frugalware.org>

```
On Thu, Feb 19, 2009 at 01:07:08PM +0100, Miklos Vajna wrote:

> 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)

```

## Miklos Vajna, 2009-02-19 12:52

Subject: [PATCH 0/8] fprintf(stderr, "warning: ") -> warning() patches
Message-ID: <cover.1235047192.git.vmiklos@frugalware.org>
URL: https://gitlist.dev/e/cover.1235047192.git.vmiklos%40frugalware.org
In-Reply-To: <20090219122104.GA4602@sigill.intra.peff.net>

```
On Thu, Feb 19, 2009 at 07:21:05AM -0500, Jeff King <peff@peff.net> wrote:
>   - there are several places that manually print "warning: " via
>     fprintf. I suppose those can be cleaned up to use warning(), too.

Here are 8 patches to do so. This does not contain the http-push patch I
send already in this thread, nor your patch.

Miklos Vajna (8):
  builtin-apply: use warning() instead of fprintf(stderr, "warning: ")
  builtin-checkout: use warning() instead of fprintf(stderr, "warning:
    ")
  builtin-fetch-pack: use warning() instead of fprintf(stderr,
    "warning: ")
  builtin-init-db: use warning() instead of fprintf(stderr, "warning:
    ")
  builtin-rm: use warning() instead of fprintf(stderr, "warning: ")
  builtin-show-branch: use warning() instead of fprintf(stderr,
    "warning: ")
  builtin-show-ref: use warning() instead of fprintf(stderr, "warning:
    ")
  refs: use warning() instead of fprintf(stderr, "warning: ")

 builtin-apply.c       |   15 +++++++--------
 builtin-checkout.c    |    4 ++--
 builtin-fetch-pack.c  |    2 +-
 builtin-init-db.c     |    7 +++----
 builtin-rm.c          |    3 +--
 builtin-show-branch.c |    3 +--
 builtin-show-ref.c    |    2 +-
 refs.c                |    8 +++-----
 8 files changed, 19 insertions(+), 25 deletions(-)

```

## Miklos Vajna, 2009-02-19 12:53

Subject: [PATCH 1/8] builtin-apply: use warning() instead of fprintf(stderr, "warning: ")
Message-ID: <4f61642d10063adbff86094e91b1b6e90efabe8e.1235047192.git.vmiklos@frugalware.org>
URL: https://gitlist.dev/e/4f61642d10063adbff86094e91b1b6e90efabe8e.1235047192.git.vmiklos%40frugalware.org
In-Reply-To: <cover.1235047192.git.vmiklos@frugalware.org>

```
Signed-off-by: Miklos Vajna <vmiklos@frugalware.org>
---
 builtin-apply.c |   15 +++++++--------
 1 files changed, 7 insertions(+), 8 deletions(-)

diff --git a/builtin-apply.c b/builtin-apply.c
index f312798..f668825 100644
--- a/builtin-apply.c
+++ b/builtin-apply.c
@@ -2451,7 +2451,7 @@ static int check_preimage(struct patch *patch, struct cache_entry **ce, struct s
 	if ((st_mode ^ patch->old_mode) & S_IFMT)
 		return error("%s: wrong type", old_name);
 	if (st_mode != patch->old_mode)
-		fprintf(stderr, "warning: %s has type %o, expected %o\n",
+		warning("%s has type %o, expected %o",
 			old_name, st_mode, patch->old_mode);
 	if (!patch->new_mode && !patch->is_delete)
 		patch->new_mode = st_mode;
@@ -2932,8 +2932,7 @@ static int write_out_one_reject(struct patch *patch)
 	cnt = strlen(patch->new_name);
 	if (ARRAY_SIZE(namebuf) <= cnt + 5) {
 		cnt = ARRAY_SIZE(namebuf) - 5;
-		fprintf(stderr,
-			"warning: truncating .rej filename to %.*s.rej",
+		warning("truncating .rej filename to %.*s.rej",
 			cnt - 1, patch->new_name);
 	}
 	memcpy(namebuf, patch->new_name, cnt);
@@ -3315,8 +3314,8 @@ int cmd_apply(int argc, const char **argv, const char *unused_prefix)
 		    squelch_whitespace_errors < whitespace_error) {
 			int squelched =
 				whitespace_error - squelch_whitespace_errors;
-			fprintf(stderr, "warning: squelched %d "
-				"whitespace error%s\n",
+			warning("squelched %d "
+				"whitespace error%s",
 				squelched,
 				squelched == 1 ? "" : "s");
 		}
@@ -3326,12 +3325,12 @@ int cmd_apply(int argc, const char **argv, const char *unused_prefix)
 			    whitespace_error == 1 ? "" : "s",
 			    whitespace_error == 1 ? "s" : "");
 		if (applied_after_fixing_ws && apply)
-			fprintf(stderr, "warning: %d line%s applied after"
-				" fixing whitespace errors.\n",
+			warning("%d line%s applied after"
+				" fixing whitespace errors.",
 				applied_after_fixing_ws,
 				applied_after_fixing_ws == 1 ? "" : "s");
 		else if (whitespace_error)
-			fprintf(stderr, "warning: %d line%s add%s whitespace errors.\n",
+			warning("%d line%s add%s whitespace errors.",
 				whitespace_error,
 				whitespace_error == 1 ? "" : "s",
 				whitespace_error == 1 ? "s" : "");
-- 
1.6.1

```

## Miklos Vajna, 2009-02-19 12:53

Subject: [PATCH 2/8] builtin-checkout: use warning() instead of fprintf(stderr, "warning: ")
Message-ID: <85cc0cd257f02379985aca3cb20263a8f3c61486.1235047192.git.vmiklos@frugalware.org>
URL: https://gitlist.dev/e/85cc0cd257f02379985aca3cb20263a8f3c61486.1235047192.git.vmiklos%40frugalware.org
In-Reply-To: <cover.1235047192.git.vmiklos@frugalware.org>

```
Signed-off-by: Miklos Vajna <vmiklos@frugalware.org>
---
 builtin-checkout.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/builtin-checkout.c b/builtin-checkout.c
index 20b34ce..0ddd34b 100644
--- a/builtin-checkout.c
+++ b/builtin-checkout.c
@@ -556,8 +556,8 @@ static int switch_branches(struct checkout_opts *opts, struct branch_info *new)
 
 	if (!old.commit && !opts->force) {
 		if (!opts->quiet) {
-			fprintf(stderr, "warning: You appear to be on a branch yet to be born.\n");
-			fprintf(stderr, "warning: Forcing checkout of %s.\n", new->name);
+			warning("You appear to be on a branch yet to be born.");
+			warning("Forcing checkout of %s.", new->name);
 		}
 		opts->force = 1;
 	}
-- 
1.6.1

```

## Miklos Vajna, 2009-02-19 12:53

Subject: [PATCH 3/8] builtin-fetch-pack: use warning() instead of fprintf(stderr, "warning: ")
Message-ID: <842406ced89cabde4bd59150834ce08d88afb461.1235047192.git.vmiklos@frugalware.org>
URL: https://gitlist.dev/e/842406ced89cabde4bd59150834ce08d88afb461.1235047192.git.vmiklos%40frugalware.org
In-Reply-To: <cover.1235047192.git.vmiklos@frugalware.org>

```
---
 builtin-fetch-pack.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/builtin-fetch-pack.c b/builtin-fetch-pack.c
index 67fb80e..85de2ba 100644
--- a/builtin-fetch-pack.c
+++ b/builtin-fetch-pack.c
@@ -606,7 +606,7 @@ static struct ref *do_fetch_pack(int fd[2],
 			/* When cloning, it is not unusual to have
 			 * no common commit.
 			 */
-			fprintf(stderr, "warning: no common commits\n");
+			warning("no common commits");
 
 	if (get_pack(fd, pack_lockfile))
 		die("git fetch-pack: fetch failed.");
-- 
1.6.1

```

## Miklos Vajna, 2009-02-19 12:54

Subject: [PATCH 4/8] builtin-init-db: use warning() instead of fprintf(stderr, "warning: ")
Message-ID: <70fd98a12f76097ba152bc3f1bc929a3b19ec8dd.1235047192.git.vmiklos@frugalware.org>
URL: https://gitlist.dev/e/70fd98a12f76097ba152bc3f1bc929a3b19ec8dd.1235047192.git.vmiklos%40frugalware.org
In-Reply-To: <cover.1235047192.git.vmiklos@frugalware.org>

```
---
 builtin-init-db.c |    7 +++----
 1 files changed, 3 insertions(+), 4 deletions(-)

diff --git a/builtin-init-db.c b/builtin-init-db.c
index ee3911f..fc63d0f 100644
--- a/builtin-init-db.c
+++ b/builtin-init-db.c
@@ -130,8 +130,7 @@ static void copy_templates(const char *template_dir)
 	}
 	dir = opendir(template_path);
 	if (!dir) {
-		fprintf(stderr, "warning: templates not found %s\n",
-			template_dir);
+		warning("templates not found %s", template_dir);
 		return;
 	}
 
@@ -144,8 +143,8 @@ static void copy_templates(const char *template_dir)
 
 	if (repository_format_version &&
 	    repository_format_version != GIT_REPO_VERSION) {
-		fprintf(stderr, "warning: not copying templates of "
-			"a wrong format version %d from '%s'\n",
+		warning("not copying templates of "
+			"a wrong format version %d from '%s'",
 			repository_format_version,
 			template_dir);
 		closedir(dir);
-- 
1.6.1

```

## Miklos Vajna, 2009-02-19 12:54

Subject: [PATCH 5/8] builtin-rm: use warning() instead of fprintf(stderr, "warning: ")
Message-ID: <dde5b527fe5d5dc668ce65c46713a3abdd33ea20.1235047192.git.vmiklos@frugalware.org>
URL: https://gitlist.dev/e/dde5b527fe5d5dc668ce65c46713a3abdd33ea20.1235047192.git.vmiklos%40frugalware.org
In-Reply-To: <cover.1235047192.git.vmiklos@frugalware.org>

```
Signed-off-by: Miklos Vajna <vmiklos@frugalware.org>
---
 builtin-rm.c |    3 +--
 1 files changed, 1 insertions(+), 2 deletions(-)

diff --git a/builtin-rm.c b/builtin-rm.c
index c11f455..269d608 100644
--- a/builtin-rm.c
+++ b/builtin-rm.c
@@ -59,8 +59,7 @@ static int check_local_mod(unsigned char *head, int index_only)
 
 		if (lstat(ce->name, &st) < 0) {
 			if (errno != ENOENT)
-				fprintf(stderr, "warning: '%s': %s",
-					ce->name, strerror(errno));
+				warning("'%s': %s", ce->name, strerror(errno));
 			/* It already vanished from the working tree */
 			continue;
 		}
-- 
1.6.1

```

## Miklos Vajna, 2009-02-19 12:54

Subject: [PATCH 6/8] builtin-show-branch: use warning() instead of fprintf(stderr, "warning: ")
Message-ID: <8095a2134bdbd7edbdeee730ae06d785401c9540.1235047192.git.vmiklos@frugalware.org>
URL: https://gitlist.dev/e/8095a2134bdbd7edbdeee730ae06d785401c9540.1235047192.git.vmiklos%40frugalware.org
In-Reply-To: <cover.1235047192.git.vmiklos@frugalware.org>

```
Signed-off-by: Miklos Vajna <vmiklos@frugalware.org>
---
 builtin-show-branch.c |    3 +--
 1 files changed, 1 insertions(+), 2 deletions(-)

diff --git a/builtin-show-branch.c b/builtin-show-branch.c
index 306b850..828e6f8 100644
--- a/builtin-show-branch.c
+++ b/builtin-show-branch.c
@@ -365,8 +365,7 @@ static int append_ref(const char *refname, const unsigned char *sha1,
 				return 0;
 	}
 	if (MAX_REVS <= ref_name_cnt) {
-		fprintf(stderr, "warning: ignoring %s; "
-			"cannot handle more than %d refs\n",
+		warning("ignoring %s; cannot handle more than %d refs",
 			refname, MAX_REVS);
 		return 0;
 	}
-- 
1.6.1

```

## Miklos Vajna, 2009-02-19 12:55

Subject: [PATCH 7/8] builtin-show-ref: use warning() instead of fprintf(stderr, "warning: ")
Message-ID: <3fb08b8fb972b27d2a75f6cf24de757dd7dcd7a6.1235047192.git.vmiklos@frugalware.org>
URL: https://gitlist.dev/e/3fb08b8fb972b27d2a75f6cf24de757dd7dcd7a6.1235047192.git.vmiklos%40frugalware.org
In-Reply-To: <cover.1235047192.git.vmiklos@frugalware.org>

```
Signed-off-by: Miklos Vajna <vmiklos@frugalware.org>
---
 builtin-show-ref.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/builtin-show-ref.c b/builtin-show-ref.c
index 572b114..dc76c50 100644
--- a/builtin-show-ref.c
+++ b/builtin-show-ref.c
@@ -140,7 +140,7 @@ static int exclude_existing(const char *match)
 				continue;
 		}
 		if (check_ref_format(ref)) {
-			fprintf(stderr, "warning: ref '%s' ignored\n", ref);
+			warning("ref '%s' ignored", ref);
 			continue;
 		}
 		if (!string_list_has_string(&existing_refs, ref)) {
-- 
1.6.1

```

## Miklos Vajna, 2009-02-19 12:55

Subject: [PATCH 8/8] refs: use warning() instead of fprintf(stderr, "warning: ")
Message-ID: <628e1950be4069a614567fd4fc06aa2ce95a1004.1235047192.git.vmiklos@frugalware.org>
URL: https://gitlist.dev/e/628e1950be4069a614567fd4fc06aa2ce95a1004.1235047192.git.vmiklos%40frugalware.org
In-Reply-To: <cover.1235047192.git.vmiklos@frugalware.org>

```
Signed-off-by: Miklos Vajna <vmiklos@frugalware.org>
---
 refs.c |    8 +++-----
 1 files changed, 3 insertions(+), 5 deletions(-)

diff --git a/refs.c b/refs.c
index 6eb5f53..fd96824 100644
--- a/refs.c
+++ b/refs.c
@@ -995,7 +995,7 @@ int delete_ref(const char *refname, const unsigned char *sha1, int delopt)
 
 	err = unlink(git_path("logs/%s", lock->ref_name));
 	if (err && errno != ENOENT)
-		fprintf(stderr, "warning: unlink(%s) failed: %s",
+		warning("unlink(%s) failed: %s",
 			git_path("logs/%s", lock->ref_name), strerror(errno));
 	invalidate_cached_refs();
 	unlock_ref(lock);
@@ -1437,8 +1437,7 @@ int read_ref_at(const char *ref, unsigned long at_time, int cnt, unsigned char *
 				if (get_sha1_hex(rec + 41, sha1))
 					die("Log %s is corrupt.", logfile);
 				if (hashcmp(logged_sha1, sha1)) {
-					fprintf(stderr,
-						"warning: Log %s has gap after %s.\n",
+					warning("Log %s has gap after %s.",
 						logfile, show_date(date, tz, DATE_RFC2822));
 				}
 			}
@@ -1450,8 +1449,7 @@ int read_ref_at(const char *ref, unsigned long at_time, int cnt, unsigned char *
 				if (get_sha1_hex(rec + 41, logged_sha1))
 					die("Log %s is corrupt.", logfile);
 				if (hashcmp(logged_sha1, sha1)) {
-					fprintf(stderr,
-						"warning: Log %s unexpectedly ended on %s.\n",
+					warning("Log %s unexpectedly ended on %s.",
 						logfile, show_date(date, tz, DATE_RFC2822));
 				}
 			}
-- 
1.6.1

```

## Jeff King, 2009-02-20 03:02

Subject: Re: [PATCH 1/8] builtin-apply: use warning() instead of fprintf(stderr, "warning: ")
Message-ID: <20090220030245.GC22419@coredump.intra.peff.net>
URL: https://gitlist.dev/e/20090220030245.GC22419%40coredump.intra.peff.net
In-Reply-To: <4f61642d10063adbff86094e91b1b6e90efabe8e.1235047192.git.vmiklos@frugalware.org>

```
On Thu, Feb 19, 2009 at 01:53:10PM +0100, Miklos Vajna wrote:

> @@ -2932,8 +2932,7 @@ static int write_out_one_reject(struct patch *patch)
>  	cnt = strlen(patch->new_name);
>  	if (ARRAY_SIZE(namebuf) <= cnt + 5) {
>  		cnt = ARRAY_SIZE(namebuf) - 5;
> -		fprintf(stderr,
> -			"warning: truncating .rej filename to %.*s.rej",
> +		warning("truncating .rej filename to %.*s.rej",
>  			cnt - 1, patch->new_name);
>  	}

Hmm. This hunk is actually changing behavior, as the original didn't
have a newline. It looks like a bug in the original, though.

Other than that, these all look pretty straightforward. Probably the
shell scripts should be switched to match, too. But it would be nice to
hear from Junio first that this cleanup is even desired (so you don't
waste time).

-Peff

```

## Junio C Hamano, 2009-02-20 06:11

Subject: Re: [PATCH 1/8] builtin-apply: use warning() instead of fprintf(stderr, "warning: ")
Message-ID: <7viqn5iqnn.fsf@gitster.siamese.dyndns.org>
URL: https://gitlist.dev/e/7viqn5iqnn.fsf%40gitster.siamese.dyndns.org
In-Reply-To: <20090220030245.GC22419@coredump.intra.peff.net>

```
Jeff King <peff@peff.net> writes:

> Other than that, these all look pretty straightforward. Probably the
> shell scripts should be switched to match, too. But it would be nice to
> hear from Junio first that this cleanup is even desired (so you don't
> waste time).

I think it is a good thing to do.  If the pre-release-freeze is a good
time to do so it is a different matter.  A good way to judge would be 
how much of these overlap with "git diff master next" (smaller the better,
obviously).

```

## Miklos Vajna, 2009-02-20 09:41

Subject: Re: [PATCH 1/8] builtin-apply: use warning() instead of fprintf(stderr, "warning: ")
Message-ID: <20090220094103.GY4371@genesis.frugalware.org>
URL: https://gitlist.dev/e/20090220094103.GY4371%40genesis.frugalware.org
In-Reply-To: <20090220030245.GC22419@coredump.intra.peff.net>

```
On Thu, Feb 19, 2009 at 10:02:45PM -0500, Jeff King <peff@peff.net> wrote:
> On Thu, Feb 19, 2009 at 01:53:10PM +0100, Miklos Vajna wrote:
> 
> > @@ -2932,8 +2932,7 @@ static int write_out_one_reject(struct patch *patch)
> >  	cnt = strlen(patch->new_name);
> >  	if (ARRAY_SIZE(namebuf) <= cnt + 5) {
> >  		cnt = ARRAY_SIZE(namebuf) - 5;
> > -		fprintf(stderr,
> > -			"warning: truncating .rej filename to %.*s.rej",
> > +		warning("truncating .rej filename to %.*s.rej",
> >  			cnt - 1, patch->new_name);
> >  	}
> 
> Hmm. This hunk is actually changing behavior, as the original didn't
> have a newline. It looks like a bug in the original, though.

I think so. The change in 5/8 (git-rm) is a similar one.

```

## Miklos Vajna, 2009-03-22 11:36

Subject: Re: [PATCH 1/8] builtin-apply: use warning() instead of fprintf(stderr, "warning: ")
Message-ID: <20090322113646.GL27459@genesis.frugalware.org>
URL: https://gitlist.dev/e/20090322113646.GL27459%40genesis.frugalware.org
In-Reply-To: <7viqn5iqnn.fsf@gitster.siamese.dyndns.org>

```
On Thu, Feb 19, 2009 at 10:11:24PM -0800, Junio C Hamano <gitster@pobox.com> wrote:
> Jeff King <peff@peff.net> writes:
> 
> > Other than that, these all look pretty straightforward. Probably the
> > shell scripts should be switched to match, too. But it would be nice to
> > hear from Junio first that this cleanup is even desired (so you don't
> > waste time).
> 
> I think it is a good thing to do.  If the pre-release-freeze is a good
> time to do so it is a different matter.  A good way to judge would be 
> how much of these overlap with "git diff master next" (smaller the better,
> obviously).

Should I rebase the series against current master and resend?

```

## Junio C Hamano, 2009-03-22 21:58

Subject: Re: [PATCH 1/8] builtin-apply: use warning() instead of fprintf(stderr, "warning: ")
Message-ID: <7v3ad5dxt5.fsf@gitster.siamese.dyndns.org>
URL: https://gitlist.dev/e/7v3ad5dxt5.fsf%40gitster.siamese.dyndns.org
In-Reply-To: <20090322113646.GL27459@genesis.frugalware.org>

```
Miklos Vajna <vmiklos@frugalware.org> writes:

> On Thu, Feb 19, 2009 at 10:11:24PM -0800, Junio C Hamano <gitster@pobox.com> wrote:
>> Jeff King <peff@peff.net> writes:
>> 
>> > Other than that, these all look pretty straightforward. Probably the
>> > shell scripts should be switched to match, too. But it would be nice to
>> > hear from Junio first that this cleanup is even desired (so you don't
>> > waste time).
>> 
>> I think it is a good thing to do.  If the pre-release-freeze is a good
>> time to do so it is a different matter.  A good way to judge would be 
>> how much of these overlap with "git diff master next" (smaller the better,
>> obviously).
>
> Should I rebase the series against current master and resend?

Yes, please, if the overlap with "diff master next" is small enough.

```
