drop trailing newline from warning/error/die messages
Our error reporting routines append a trailing newline, and the strings
we pass to them should not include them (otherwise we get an extra blank
line after the message).
These cases were all found by looking at the results of:
git grep -P '[^_](error|error_errno|warning|die|die_errno)\(.*\\n"[,)]' '*.c'
Note that we _do_ sometimes include a newline in the middle of such
messages, to create multiline output (hence our grep matching "," or ")"
after we see the newline, so we know we're at the end of the string).
It's possible that one or more of these cases could intentionally be
including a blank line at the end, but having looked at them all
manually, I think these are all just mistakes.
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Jeff King committedSep 5, 2024 at 04:51 UTC1a60f2066aadf68391aed69f4d5914d914b60f5b
12 files changed+22-22
builtin/bisect.c
+2-2
index 453a6cccd7..c8aa92b19d 100644--- a/builtin/bisect.c+++ b/builtin/bisect.c@@ -583,7 +583,7 @@ static int prepare_revs(struct bisect_terms *terms, struct rev_info *revs) refs_for_each_glob_ref_in(get_main_ref_store(the_repository), add_bisect_ref, good, "refs/bisect/", &cb); if (prepare_revision_walk(revs))- res = error(_("revision walk setup failed\n"));+ res = error(_("revision walk setup failed")); free(good); free(bad);@@ -1108,7 +1108,7 @@ static enum bisect_error bisect_skip(struct bisect_terms *terms, int argc, setup_revisions(2, argv + i - 1, &revs, NULL); if (prepare_revision_walk(&revs))- die(_("revision walk setup failed\n"));+ die(_("revision walk setup failed")); while ((commit = get_revision(&revs)) != NULL) strvec_push(&argv_state, oid_to_hex(&commit->object.oid));
builtin/fetch.c
+2-2
index b2b5aee5bf..55f97134aa 100644--- a/builtin/fetch.c+++ b/builtin/fetch.c@@ -1161,7 +1161,7 @@ static int store_updated_refs(struct display_state *display_state, opt.exclude_hidden_refs_section = "fetch"; rm = ref_map; if (check_connected(iterate_ref_map, &rm, &opt)) {- rc = error(_("%s did not send all necessary objects\n"),+ rc = error(_("%s did not send all necessary objects"), display_state->url); goto abort; }@@ -1458,7 +1458,7 @@ static void set_option(struct transport *transport, const char *name, const char die(_("option \"%s\" value \"%s\" is not valid for %s"), name, value, transport->url); if (r > 0)- warning(_("option \"%s\" is ignored for %s\n"),+ warning(_("option \"%s\" is ignored for %s"), name, transport->url); }
builtin/stash.c
+1-1
index fcfd97972a..be842258d0 100644--- a/builtin/stash.c+++ b/builtin/stash.c@@ -484,7 +484,7 @@ static void unstage_changes_unless_new(struct object_id *orig_tree) " to make room.\n"), ce->name, new_path.buf); if (rename(ce->name, new_path.buf))- die("Failed to move %s to %s\n",+ die("Failed to move %s to %s", ce->name, new_path.buf); strbuf_release(&new_path); }
builtin/submodule--helper.c
+1-1
index 85fb23dee8..a46ffd49b3 100644--- a/builtin/submodule--helper.c+++ b/builtin/submodule--helper.c@@ -917,7 +917,7 @@ static void generate_submodule_summary(struct summary_cb *info, } else { /* for a submodule removal (mode:0000000), don't warn */ if (p->mod_dst)- warning(_("unexpected mode %o\n"), p->mod_dst);+ warning(_("unexpected mode %o"), p->mod_dst); } }
index a8bf772172..6d6a41b7e5 100644--- a/loose.c+++ b/loose.c@@ -162,7 +162,7 @@ int repo_write_loose_object_map(struct repository *repo) errout: rollback_lock_file(&lock); strbuf_release(&buf);- error_errno(_("failed to write loose object index %s\n"), path.buf);+ error_errno(_("failed to write loose object index %s"), path.buf); strbuf_release(&path); return -1; }@@ -197,7 +197,7 @@ static int write_one_object(struct repository *repo, const struct object_id *oid strbuf_release(&path); return 0; errout:- error_errno(_("failed to write loose object index %s\n"), path.buf);+ error_errno(_("failed to write loose object index %s"), path.buf); close(fd); rollback_lock_file(&lock); strbuf_release(&buf);
negotiator/skipping.c
+1-1
index f65d47858b..6e61b3c5f1 100644--- a/negotiator/skipping.c+++ b/negotiator/skipping.c@@ -239,7 +239,7 @@ static int ack(struct fetch_negotiator *n, struct commit *c) { int known_to_be_common = !!(c->object.flags & COMMON); if (!(c->object.flags & SEEN))- die("received ack for commit %s not sent as 'have'\n",+ die("received ack for commit %s not sent as 'have'", oid_to_hex(&c->object.oid)); mark_common(n->data, c); return known_to_be_common;
index 7314f6c0d8..995e382863 100644--- a/t/helper/test-reach.c+++ b/t/helper/test-reach.c@@ -67,13 +67,13 @@ int cmd__reach(int ac, const char **av) peeled = deref_tag_noverify(the_repository, orig); if (!peeled)- die("failed to load commit for input %s resulting in oid %s\n",+ die("failed to load commit for input %s resulting in oid %s", buf.buf, oid_to_hex(&oid)); c = object_as_type(peeled, OBJ_COMMIT, 0); if (!c)- die("failed to load commit for input %s resulting in oid %s\n",+ die("failed to load commit for input %s resulting in oid %s", buf.buf, oid_to_hex(&oid)); switch (buf.buf[0]) {