Skip to contentSkip to conversation

Change output "error: " to "Error: " etc

PATCH In review John Tapsell 6 participants 35 messages Jun 15, 2016

lore
Share & tools
lore
#0 lore raw

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

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'

---
 usage.c |    8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)
usage.c +4 -4
index 24f5fc0..acc4ee1 100644
@@ -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
Signature · 1 line
1.6.2.rc1.3.g7d31b.dirty
#1 lore raw
Quoted 6 lines · John Tapsell

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

#2 lore raw

PATCH 1/1 http-push: using error() and warning() as appropriate

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.

---

Quoted 4 lines · Jeff King

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(-)
http-push.c +3 -3
index 30d2d34..3a41d36 100644
@@ -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;
 		}
Signature · 1 line
1.6.1
#3 lore raw

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

Quoted 7 lines · Miklos Vajna

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.

---

Quoted 7 lines
Quoted 4 lines · Jeff King

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

---

builtin-mv.c +1 -3
index 01270fe..fc6bd82 100644
@@ -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";
http-walker.c +1 -1
index 0dbad3c..91abea7 100644
@@ -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)
#4 lore raw

cover fprintf(stderr, "warning: ") -> warning() patches

Quoted 2 lines · Jeff King

- 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(-)
#5 lore raw

PATCH 1/8 builtin-apply: use warning() instead of fprintf(stderr, "warning: ")

---
 builtin-apply.c |   15 +++++++--------
 1 files changed, 7 insertions(+), 8 deletions(-)
builtin-apply.c +7 -8
index f312798..f668825 100644
@@ -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" : "");
Signature · 1 line
1.6.1
#6 lore raw

Re: [PATCH 1/8] builtin-apply: use warning() instead of fprintf(stderr, "warning: ")

builtin-apply.c static int write_out_one_reject(struct patch *patch) · line 2937

Quoted 9 lines · Miklos Vajna
builtin-apply.c +1 -2
@@ -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

#7 lore raw

Re: [PATCH 1/8] builtin-apply: use warning() instead of fprintf(stderr, "warning: ")

Quoted 14 lines · Jeff King

builtin-apply.c static int write_out_one_reject(struct patch *patch) · line 2937

Quoted 9 lines · Miklos Vajna
builtin-apply.c +1 -2
@@ -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.

#8 lore raw

Re: [PATCH 1/8] builtin-apply: use warning() instead of fprintf(stderr, "warning: ")

In reply to Jeff King
Quoted 4 lines · Jeff King

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

#9 lore raw

Re: [PATCH 1/8] builtin-apply: use warning() instead of fprintf(stderr, "warning: ")

Quoted 11 lines · Junio C Hamano
Quoted 4 lines · Jeff King

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?

#10 lore raw

Re: [PATCH 1/8] builtin-apply: use warning() instead of fprintf(stderr, "warning: ")

Quoted 8 lines · Miklos Vajna
Quoted 7 lines · Junio C Hamano
Quoted 4 lines · Jeff King

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

Quoted 6 lines
Quoted 4 lines

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.

#11 lore raw

cover fprintf(stderr, "warning: ") -> warning() patches

Quoted 3 lines · Junio C Hamano
Quoted 1 line

Should I rebase the series against current master and resend?

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

Okay, here it is, applies on top of master. All, except the http-push one, applies cleanly on top of next as well here.

Miklos Vajna (9):
http-push: using error() and warning() as appropriate
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 +-
 http-push.c           |    6 +++---
 refs.c                |    8 +++-----
 9 files changed, 22 insertions(+), 28 deletions(-)
#12 lore raw

PATCH 1/9 http-push: using error() and warning() as appropriate

Change three occurences of using inconsistent error/warning reporting by using the relevant error() / warning() calls to be consitent with the rest of the code.

---
 http-push.c |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)
http-push.c +3 -3
index 48e5f38..e6bd01a 100644
@@ -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 {
@@ -2225,7 +2225,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;
 		}
Signature · 1 line
1.6.2
#13 lore raw

PATCH 2/9 builtin-apply: use warning() instead of fprintf(stderr, "warning: ")

---
 builtin-apply.c |   15 +++++++--------
 1 files changed, 7 insertions(+), 8 deletions(-)
builtin-apply.c +7 -8
index b52aa20..1926cd8 100644
@@ -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" : "");
Signature · 1 line
1.6.2
#14 lore raw

Re: [PATCH 2/9] builtin-apply: use warning() instead of fprintf(stderr, "warning: ")

builtin-apply.c static int write_out_one_reject(struct patch *patch) · line 2935

Quoted 7 lines · Miklos Vajna
builtin-apply.c +1 -2
@@ -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",

Again, doesn't this change the output?

Signature · 3 lines
Erik "kusma" Faye-Lund
[email protected]
(+47) 986 59 656
#15 lore raw

PATCH 3/9 builtin-checkout: use warning() instead of fprintf(stderr, "warning: ")

In reply to Miklos Vajna
---
 builtin-checkout.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
builtin-checkout.c +2 -2
index 9fdfc58..fc55bbe 100644
@@ -558,8 +558,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;
 	}
Signature · 1 line
1.6.2
#16 lore raw

PATCH 4/9 builtin-fetch-pack: use warning() instead of fprintf(stderr, "warning: ")

---
 builtin-fetch-pack.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
builtin-fetch-pack.c +1 -1
index d571253..5d134be 100644
@@ -605,7 +605,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.");
Signature · 1 line
1.6.2
#17 lore raw

PATCH 5/9 builtin-init-db: use warning() instead of fprintf(stderr, "warning: ")

---
 builtin-init-db.c |    7 +++----
 1 files changed, 3 insertions(+), 4 deletions(-)
builtin-init-db.c +3 -4
index ee3911f..fc63d0f 100644
@@ -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);
Signature · 1 line
1.6.2
#18 lore raw

PATCH 6/9 builtin-rm: use warning() instead of fprintf(stderr, "warning: ")

---
 builtin-rm.c |    3 +--
 1 files changed, 1 insertions(+), 2 deletions(-)
builtin-rm.c +1 -2
index c11f455..269d608 100644
@@ -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;
 		}
Signature · 1 line
1.6.2
#19 lore raw

PATCH 7/9 builtin-show-branch: use warning() instead of fprintf(stderr, "warning: ")

---
 builtin-show-branch.c |    3 +--
 1 files changed, 1 insertions(+), 2 deletions(-)
builtin-show-branch.c +1 -2
index 306b850..828e6f8 100644
@@ -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;
 	}
Signature · 1 line
1.6.2
#20 lore raw

PATCH 8/9 builtin-show-ref: use warning() instead of fprintf(stderr, "warning: ")

---
 builtin-show-ref.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
builtin-show-ref.c +1 -1
index 572b114..dc76c50 100644
@@ -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)) {
Signature · 1 line
1.6.2
#21 lore raw

PATCH 9/9 refs: use warning() instead of fprintf(stderr, "warning: ")

---
 refs.c |    8 +++-----
 1 files changed, 3 insertions(+), 5 deletions(-)
refs.c +3 -5
index 8d3c502..aeef257 100644
@@ -996,7 +996,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);
@@ -1438,8 +1438,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));
 				}
 			}
@@ -1451,8 +1450,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));
 				}
 			}
Signature · 1 line
1.6.2
#22 lore raw

Re: [PATCH 9/9] refs: use warning() instead of fprintf(stderr, "warning: ")

refs.c int delete_ref(const char *refname, const unsigned char *sha1, int delopt) · line 999

Quoted 6 lines
refs.c +1 -1
@@ -996,7 +996,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",

Doesn't this add a newline? The original string doesn't have a '\n' at the end of the format-field, but AFAIK warning() terminates with one. I'm not saying it's a problem, I'm just pointing it out.

Signature · 3 lines
Erik "kusma" Faye-Lund
[email protected]
(+47) 986 59 656
#23 lore raw

Re: [PATCH 9/9] refs: use warning() instead of fprintf(stderr, "warning: ")

Quoted 10 lines · Erik Faye-Lund

refs.c int delete_ref(const char *refname, const unsigned char *sha1, int delopt) · line 999

Quoted 6 lines
refs.c +1 -1
@@ -996,7 +996,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",

Doesn't this add a newline? The original string doesn't have a '\n' at the end of the format-field, but AFAIK warning() terminates with one. I'm not saying it's a problem, I'm just pointing it out.

Yes, it adds. As Jeff pointed out earlier in this thread, the lack of newline was a bug:

http://article.gmane.org/gmane.comp.version-control.git/110783

#24 lore raw

Re: [PATCH 9/9] refs: use warning() instead of fprintf(stderr, "warning: ")

OK, sorry for not reading the old discussion before commenting. :)

Quoted 17 lines · Miklos Vajna
Quoted 10 lines · Erik Faye-Lund

refs.c int delete_ref(const char *refname, const unsigned char *sha1, int delopt) · line 999

Quoted 6 lines
refs.c +1 -1
@@ -996,7 +996,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",

Doesn't this add a newline? The original string doesn't have a '\n' at the end of the format-field, but AFAIK warning() terminates with one. I'm not saying it's a problem, I'm just pointing it out.

Yes, it adds. As Jeff pointed out earlier in this thread, the lack of newline was a bug:

http://article.gmane.org/gmane.comp.version-control.git/110783

Signature · 3 lines
Erik "kusma" Faye-Lund
[email protected]
(+47) 986 59 656
#25 lore raw

Re: [PATCH 0/9] fprintf(stderr, "warning: ") -> warning() patches

In reply to Miklos Vajna
Quoted 2 lines · Miklos Vajna

Okay, here it is, applies on top of master. All, except the http-push one, applies cleanly on top of next as well here.

I manually scanned the patches and they all look sane to me. Thanks.

-Peff

#26 lore raw

Re: [PATCH 0/9] fprintf(stderr, "warning: ") -> warning() patches

Quoted 7 lines · Jeff King
Quoted 2 lines · Miklos Vajna

Okay, here it is, applies on top of master. All, except the http-push one, applies cleanly on top of next as well here.

I manually scanned the patches and they all look sane to me. Thanks.

Thanks; I've done the same and three sets of eyeballs give me a warm fuzzy feeling ;-)

Applied.

#27 lore raw

PATCH 2/8 builtin-checkout: use warning() instead of fprintf(stderr, "warning: ")

In reply to Miklos Vajna
---
 builtin-checkout.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
builtin-checkout.c +2 -2
index 20b34ce..0ddd34b 100644
@@ -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;
 	}
Signature · 1 line
1.6.1
#28 lore raw

PATCH 3/8 builtin-fetch-pack: use warning() instead of fprintf(stderr, "warning: ")

In reply to Miklos Vajna
---
 builtin-fetch-pack.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
builtin-fetch-pack.c +1 -1
index 67fb80e..85de2ba 100644
@@ -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.");
Signature · 1 line
1.6.1
#29 lore raw

PATCH 4/8 builtin-init-db: use warning() instead of fprintf(stderr, "warning: ")

In reply to Miklos Vajna
---
 builtin-init-db.c |    7 +++----
 1 files changed, 3 insertions(+), 4 deletions(-)
builtin-init-db.c +3 -4
index ee3911f..fc63d0f 100644
@@ -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);
Signature · 1 line
1.6.1
#30 lore raw

PATCH 5/8 builtin-rm: use warning() instead of fprintf(stderr, "warning: ")

In reply to Miklos Vajna
---
 builtin-rm.c |    3 +--
 1 files changed, 1 insertions(+), 2 deletions(-)
builtin-rm.c +1 -2
index c11f455..269d608 100644
@@ -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;
 		}
Signature · 1 line
1.6.1
#31 lore raw

PATCH 6/8 builtin-show-branch: use warning() instead of fprintf(stderr, "warning: ")

In reply to Miklos Vajna
---
 builtin-show-branch.c |    3 +--
 1 files changed, 1 insertions(+), 2 deletions(-)
builtin-show-branch.c +1 -2
index 306b850..828e6f8 100644
@@ -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;
 	}
Signature · 1 line
1.6.1
#32 lore raw

PATCH 7/8 builtin-show-ref: use warning() instead of fprintf(stderr, "warning: ")

In reply to Miklos Vajna
---
 builtin-show-ref.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
builtin-show-ref.c +1 -1
index 572b114..dc76c50 100644
@@ -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)) {
Signature · 1 line
1.6.1
#33 lore raw

PATCH 8/8 refs: use warning() instead of fprintf(stderr, "warning: ")

In reply to Miklos Vajna
---
 refs.c |    8 +++-----
 1 files changed, 3 insertions(+), 5 deletions(-)
refs.c +3 -5
index 6eb5f53..fd96824 100644
@@ -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));
 				}
 			}
Signature · 1 line
1.6.1
#34 lore raw
In reply to John Tapsell
Quoted 6 lines · John Tapsell

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'

[...]

usage.c static void report(const char *prefix, const char *err, va_list params) · line 23

Quoted 2 lines
usage.c +1 -1
-	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.

Signature · 2 lines
Thomas Rast
trast@{inf,student}.ethz.ch