{"thread":{"id":"30357","subject":"[PATCH 0/2] minor error message newline purge","startedAt":"2012-04-30T00:28:44Z","lastAt":"2012-04-30T00:28:46Z","messageCount":3,"participants":["Pete Wyckoff"],"isPatch":true,"patchVersion":1,"patchTotal":2},"messages":[{"id":"190262","messageId":"1335745726-2583-1-git-send-email-pw@padd.com","threadId":"30357","inReplyTo":null,"subject":"[PATCH 0/2] minor error message newline purge","fromName":"Pete Wyckoff","fromEmail":"pw@padd.com","sentAt":"2012-04-30T00:28:44Z","receivedAt":"2012-04-30T00:28:44Z","isPatch":true,"sender":{"key":"pw@padd.com","avatar":null},"body":"Some error messages show up with an extra blank line, like this\none:\n\n    $ git commit -m foo\n    unable to create temporary sha1 filename : Too many open files\n\n    error: Error building trees\n    $\n\nMost of the callers of error() and similar functions in usage.c\ndon't add a newline, but a few do, causing odd output like the\nabove.\n\nNo tests for these; they're hopefully trivial.  One of the edited\nmessages was marked for translation.  I'm not sure if changing it\nrequires any work in po/.\n\nPete Wyckoff (2):\n  remove superfluous newlines in error messages\n  remove blank filename in error message\n\n builtin/branch.c                       |    2 +-\n builtin/merge-file.c                   |    4 ++--\n builtin/unpack-objects.c               |    2 +-\n compat/win32mmap.c                     |    2 +-\n contrib/examples/builtin-fetch--tool.c |    4 ++--\n fsck.c                                 |    2 +-\n http-push.c                            |    4 ++--\n http.c                                 |    2 +-\n imap-send.c                            |    2 +-\n ll-merge.c                             |    2 +-\n object.c                               |    6 +++---\n sha1_file.c                            |    6 +++---\n transport-helper.c                     |    4 ++--\n unpack-trees.c                         |    2 +-\n vcs-svn/svndump.c                      |    4 ++--\n 15 files changed, 24 insertions(+), 24 deletions(-)\n\n-- \n1.7.10.572.ged86f\n"},{"id":"190263","messageId":"1335745726-2583-2-git-send-email-pw@padd.com","threadId":"30357","inReplyTo":"1335745726-2583-1-git-send-email-pw@padd.com","subject":"[PATCH 1/2] remove superfluous newlines in error messages","fromName":"Pete Wyckoff","fromEmail":"pw@padd.com","sentAt":"2012-04-30T00:28:45Z","receivedAt":"2012-04-30T00:28:45Z","isPatch":true,"sender":{"key":"pw@padd.com","avatar":null},"body":"The error handling routines add a newline.  Remove\nthe duplicate ones in error messages.\n\nSigned-off-by: Pete Wyckoff <pw@padd.com>\n---\n builtin/branch.c                       |    2 +-\n builtin/merge-file.c                   |    4 ++--\n builtin/unpack-objects.c               |    2 +-\n compat/win32mmap.c                     |    2 +-\n contrib/examples/builtin-fetch--tool.c |    4 ++--\n fsck.c                                 |    2 +-\n http-push.c                            |    4 ++--\n http.c                                 |    2 +-\n imap-send.c                            |    2 +-\n ll-merge.c                             |    2 +-\n object.c                               |    6 +++---\n sha1_file.c                            |    6 +++---\n transport-helper.c                     |    4 ++--\n unpack-trees.c                         |    2 +-\n vcs-svn/svndump.c                      |    4 ++--\n 15 files changed, 24 insertions(+), 24 deletions(-)\n\ndiff --git a/builtin/branch.c b/builtin/branch.c\nindex 5f150b4..dc353ff 100644\n--- a/builtin/branch.c\n+++ b/builtin/branch.c\n@@ -657,7 +657,7 @@ static int edit_branch_description(const char *branch_name)\n \tfp = fopen(git_path(edit_description), \"w\");\n \tif ((fwrite(buf.buf, 1, buf.len, fp) < buf.len) || fclose(fp)) {\n \t\tstrbuf_release(&buf);\n-\t\treturn error(_(\"could not write branch description template: %s\\n\"),\n+\t\treturn error(_(\"could not write branch description template: %s\"),\n \t\t\t     strerror(errno));\n \t}\n \tstrbuf_reset(&buf);\ndiff --git a/builtin/merge-file.c b/builtin/merge-file.c\nindex 237abd3..6f0efef 100644\n--- a/builtin/merge-file.c\n+++ b/builtin/merge-file.c\n@@ -63,7 +63,7 @@ int cmd_merge_file(int argc, const char **argv, const char *prefix)\n \tif (quiet) {\n \t\tif (!freopen(\"/dev/null\", \"w\", stderr))\n \t\t\treturn error(\"failed to redirect stderr to /dev/null: \"\n-\t\t\t\t     \"%s\\n\", strerror(errno));\n+\t\t\t\t     \"%s\", strerror(errno));\n \t}\n \n \tif (prefix)\n@@ -76,7 +76,7 @@ int cmd_merge_file(int argc, const char **argv, const char *prefix)\n \t\tif (read_mmfile(mmfs + i, fname))\n \t\t\treturn -1;\n \t\tif (buffer_is_binary(mmfs[i].ptr, mmfs[i].size))\n-\t\t\treturn error(\"Cannot merge binary files: %s\\n\",\n+\t\t\treturn error(\"Cannot merge binary files: %s\",\n \t\t\t\t\targv[i]);\n \t}\n \ndiff --git a/builtin/unpack-objects.c b/builtin/unpack-objects.c\nindex 14e04e6..2217d7b 100644\n--- a/builtin/unpack-objects.c\n+++ b/builtin/unpack-objects.c\n@@ -107,7 +107,7 @@ static void *get_data(unsigned long size)\n \t\tif (stream.total_out == size && ret == Z_STREAM_END)\n \t\t\tbreak;\n \t\tif (ret != Z_OK) {\n-\t\t\terror(\"inflate returned %d\\n\", ret);\n+\t\t\terror(\"inflate returned %d\", ret);\n \t\t\tfree(buf);\n \t\t\tbuf = NULL;\n \t\t\tif (!recover)\ndiff --git a/compat/win32mmap.c b/compat/win32mmap.c\nindex b58aa69..61d2ef8 100644\n--- a/compat/win32mmap.c\n+++ b/compat/win32mmap.c\n@@ -30,7 +30,7 @@ void *git_mmap(void *start, size_t length, int prot, int flags, int fd, off_t of\n \ttemp = MapViewOfFileEx(hmap, FILE_MAP_COPY, h, l, length, start);\n \n \tif (!CloseHandle(hmap))\n-\t\twarning(\"unable to close file mapping handle\\n\");\n+\t\twarning(\"unable to close file mapping handle\");\n \n \treturn temp ? temp : MAP_FAILED;\n }\ndiff --git a/contrib/examples/builtin-fetch--tool.c b/contrib/examples/builtin-fetch--tool.c\nindex 3140e40..0d54aa7 100644\n--- a/contrib/examples/builtin-fetch--tool.c\n+++ b/contrib/examples/builtin-fetch--tool.c\n@@ -518,7 +518,7 @@ int cmd_fetch__tool(int argc, const char **argv, const char *prefix)\n \t\tfilename = git_path(\"FETCH_HEAD\");\n \t\tfp = fopen(filename, \"a\");\n \t\tif (!fp)\n-\t\t\treturn error(\"cannot open %s: %s\\n\", filename, strerror(errno));\n+\t\t\treturn error(\"cannot open %s: %s\", filename, strerror(errno));\n \t\tresult = append_fetch_head(fp, argv[2], argv[3],\n \t\t\t\t\t   argv[4], argv[5],\n \t\t\t\t\t   argv[6], !!argv[7][0],\n@@ -536,7 +536,7 @@ int cmd_fetch__tool(int argc, const char **argv, const char *prefix)\n \t\tfilename = git_path(\"FETCH_HEAD\");\n \t\tfp = fopen(filename, \"a\");\n \t\tif (!fp)\n-\t\t\treturn error(\"cannot open %s: %s\\n\", filename, strerror(errno));\n+\t\t\treturn error(\"cannot open %s: %s\", filename, strerror(errno));\n \t\tresult = fetch_native_store(fp, argv[2], argv[3], argv[4],\n \t\t\t\t\t    verbose, force);\n \t\tfclose(fp);\ndiff --git a/fsck.c b/fsck.c\nindex 6c855f8..4c63b2c 100644\n--- a/fsck.c\n+++ b/fsck.c\n@@ -27,7 +27,7 @@ static int fsck_walk_tree(struct tree *tree, fsck_walk_func walk, void *data)\n \t\telse if (S_ISREG(entry.mode) || S_ISLNK(entry.mode))\n \t\t\tresult = walk(&lookup_blob(entry.sha1)->object, OBJ_BLOB, data);\n \t\telse {\n-\t\t\tresult = error(\"in tree %s: entry %s has bad mode %.6o\\n\",\n+\t\t\tresult = error(\"in tree %s: entry %s has bad mode %.6o\",\n \t\t\t\t\tsha1_to_hex(tree->object.sha1), entry.path, entry.mode);\n \t\t}\n \t\tif (result < 0)\ndiff --git a/http-push.c b/http-push.c\nindex f22f7e4..1df7ab5 100644\n--- a/http-push.c\n+++ b/http-push.c\n@@ -1108,7 +1108,7 @@ static void handle_remote_ls_ctx(struct xml_ctx *ctx, int tag_closed)\n \t\t\t\tif (repo->path)\n \t\t\t\t\turl = repo->path;\n \t\t\t\tif (strncmp(path, url, repo->path_len))\n-\t\t\t\t\terror(\"Parsed path '%s' does not match url: '%s'\\n\",\n+\t\t\t\t\terror(\"Parsed path '%s' does not match url: '%s'\",\n \t\t\t\t\t      path, url);\n \t\t\t\telse {\n \t\t\t\t\tpath += repo->path_len;\n@@ -1702,7 +1702,7 @@ static int delete_remote_branch(const char *pattern, int force)\n \t\trun_active_slot(slot);\n \t\tfree(url);\n \t\tif (results.curl_result != CURLE_OK)\n-\t\t\treturn error(\"DELETE request failed (%d/%ld)\\n\",\n+\t\t\treturn error(\"DELETE request failed (%d/%ld)\",\n \t\t\t\t     results.curl_result, results.http_code);\n \t} else {\n \t\tfree(url);\ndiff --git a/http.c b/http.c\nindex f3f83d7..ef331bd 100644\n--- a/http.c\n+++ b/http.c\n@@ -906,7 +906,7 @@ static char *fetch_pack_index(unsigned char *sha1, const char *base_url)\n \ttmp = strbuf_detach(&buf, NULL);\n \n \tif (http_get_file(url, tmp, 0) != HTTP_OK) {\n-\t\terror(\"Unable to get pack index %s\\n\", url);\n+\t\terror(\"Unable to get pack index %s\", url);\n \t\tfree(tmp);\n \t\ttmp = NULL;\n \t}\ndiff --git a/imap-send.c b/imap-send.c\nindex 972ad62..d42e471 100644\n--- a/imap-send.c\n+++ b/imap-send.c\n@@ -1022,7 +1022,7 @@ static int auth_cram_md5(struct imap_store *ctx, struct imap_cmd *cmd, const cha\n \n \tret = socket_write(&ctx->imap->buf.sock, response, strlen(response));\n \tif (ret != strlen(response))\n-\t\treturn error(\"IMAP error: sending response failed\\n\");\n+\t\treturn error(\"IMAP error: sending response failed\");\n \n \tfree(response);\n \ndiff --git a/ll-merge.c b/ll-merge.c\nindex da59738..f3f7692 100644\n--- a/ll-merge.c\n+++ b/ll-merge.c\n@@ -73,7 +73,7 @@ static int ll_xdl_merge(const struct ll_merge_driver *drv_unused,\n \tif (buffer_is_binary(orig->ptr, orig->size) ||\n \t    buffer_is_binary(src1->ptr, src1->size) ||\n \t    buffer_is_binary(src2->ptr, src2->size)) {\n-\t\twarning(\"Cannot merge binary files: %s (%s vs. %s)\\n\",\n+\t\twarning(\"Cannot merge binary files: %s (%s vs. %s)\",\n \t\t\tpath, name1, name2);\n \t\treturn ll_binary_merge(drv_unused, result,\n \t\t\t\t       path,\ndiff --git a/object.c b/object.c\nindex 49a864c..4af3451 100644\n--- a/object.c\n+++ b/object.c\n@@ -176,7 +176,7 @@ struct object *parse_object_buffer(const unsigned char *sha1, enum object_type t\n \t\t\tobj = &tag->object;\n \t\t}\n \t} else {\n-\t\twarning(\"object %s has unknown type id %d\\n\", sha1_to_hex(sha1), type);\n+\t\twarning(\"object %s has unknown type id %d\", sha1_to_hex(sha1), type);\n \t\tobj = NULL;\n \t}\n \tif (obj && obj->type == OBJ_NONE)\n@@ -202,7 +202,7 @@ struct object *parse_object(const unsigned char *sha1)\n \t    (!obj && has_sha1_file(sha1) &&\n \t     sha1_object_info(sha1, NULL) == OBJ_BLOB)) {\n \t\tif (check_sha1_signature(repl, NULL, 0, NULL) < 0) {\n-\t\t\terror(\"sha1 mismatch %s\\n\", sha1_to_hex(repl));\n+\t\t\terror(\"sha1 mismatch %s\", sha1_to_hex(repl));\n \t\t\treturn NULL;\n \t\t}\n \t\tparse_blob_buffer(lookup_blob(sha1), NULL, 0);\n@@ -213,7 +213,7 @@ struct object *parse_object(const unsigned char *sha1)\n \tif (buffer) {\n \t\tif (check_sha1_signature(repl, buffer, size, typename(type)) < 0) {\n \t\t\tfree(buffer);\n-\t\t\terror(\"sha1 mismatch %s\\n\", sha1_to_hex(repl));\n+\t\t\terror(\"sha1 mismatch %s\", sha1_to_hex(repl));\n \t\t\treturn NULL;\n \t\t}\n \ndiff --git a/sha1_file.c b/sha1_file.c\nindex ad314f0..c8d572d 100644\n--- a/sha1_file.c\n+++ b/sha1_file.c\n@@ -2417,7 +2417,7 @@ int move_temp_to_file(const char *tmpfile, const char *filename)\n \tunlink_or_warn(tmpfile);\n \tif (ret) {\n \t\tif (ret != EEXIST) {\n-\t\t\treturn error(\"unable to write sha1 filename %s: %s\\n\", filename, strerror(ret));\n+\t\t\treturn error(\"unable to write sha1 filename %s: %s\", filename, strerror(ret));\n \t\t}\n \t\t/* FIXME!!! Collision check here ? */\n \t}\n@@ -2509,9 +2509,9 @@ static int write_loose_object(const unsigned char *sha1, char *hdr, int hdrlen,\n \tfd = create_tmpfile(tmp_file, sizeof(tmp_file), filename);\n \tif (fd < 0) {\n \t\tif (errno == EACCES)\n-\t\t\treturn error(\"insufficient permission for adding an object to repository database %s\\n\", get_object_directory());\n+\t\t\treturn error(\"insufficient permission for adding an object to repository database %s\", get_object_directory());\n \t\telse\n-\t\t\treturn error(\"unable to create temporary sha1 filename %s: %s\\n\", tmp_file, strerror(errno));\n+\t\t\treturn error(\"unable to create temporary sha1 filename %s: %s\", tmp_file, strerror(errno));\n \t}\n \n \t/* Set it up */\ndiff --git a/transport-helper.c b/transport-helper.c\nindex f6b3b1f..61c928f 100644\n--- a/transport-helper.c\n+++ b/transport-helper.c\n@@ -199,7 +199,7 @@ static struct child_process *get_helper(struct transport *transport)\n \t\t\tdata->import_marks = strbuf_detach(&arg, NULL);\n \t\t} else if (mandatory) {\n \t\t\tdie(\"Unknown mandatory capability %s. This remote \"\n-\t\t\t    \"helper probably needs newer version of Git.\\n\",\n+\t\t\t    \"helper probably needs newer version of Git.\",\n \t\t\t    capname);\n \t\t}\n \t}\n@@ -599,7 +599,7 @@ static void push_update_ref_status(struct strbuf *buf,\n \t\tstatus = REF_STATUS_REMOTE_REJECT;\n \t\trefname = buf->buf + 6;\n \t} else\n-\t\tdie(\"expected ok/error, helper said '%s'\\n\", buf->buf);\n+\t\tdie(\"expected ok/error, helper said '%s'\", buf->buf);\n \n \tmsg = strchr(refname, ' ');\n \tif (msg) {\ndiff --git a/unpack-trees.c b/unpack-trees.c\nindex 36523da..7cfa026 100644\n--- a/unpack-trees.c\n+++ b/unpack-trees.c\n@@ -1792,7 +1792,7 @@ int bind_merge(struct cache_entry **src,\n \tstruct cache_entry *a = src[1];\n \n \tif (o->merge_size != 1)\n-\t\treturn error(\"Cannot do a bind merge of %d trees\\n\",\n+\t\treturn error(\"Cannot do a bind merge of %d trees\",\n \t\t\t     o->merge_size);\n \tif (a && old)\n \t\treturn o->gently ? -1 :\ndiff --git a/vcs-svn/svndump.c b/vcs-svn/svndump.c\nindex 644fdc7..0899790 100644\n--- a/vcs-svn/svndump.c\n+++ b/vcs-svn/svndump.c\n@@ -175,7 +175,7 @@ static void read_props(void)\n \t\tint ch;\n \n \t\tif (!type || t[1] != ' ')\n-\t\t\tdie(\"invalid property line: %s\\n\", t);\n+\t\t\tdie(\"invalid property line: %s\", t);\n \t\tlen = atoi(&t[2]);\n \t\tstrbuf_reset(&val);\n \t\tbuffer_read_binary(&input, &val, len);\n@@ -201,7 +201,7 @@ static void read_props(void)\n \t\t\tstrbuf_reset(&key);\n \t\t\tcontinue;\n \t\tdefault:\n-\t\t\tdie(\"invalid property line: %s\\n\", t);\n+\t\t\tdie(\"invalid property line: %s\", t);\n \t\t}\n \t}\n }\n-- \n1.7.10.572.ged86f\n"},{"id":"190264","messageId":"1335745726-2583-3-git-send-email-pw@padd.com","threadId":"30357","inReplyTo":"1335745726-2583-1-git-send-email-pw@padd.com","subject":"[PATCH 2/2] remove blank filename in error message","fromName":"Pete Wyckoff","fromEmail":"pw@padd.com","sentAt":"2012-04-30T00:28:46Z","receivedAt":"2012-04-30T00:28:46Z","isPatch":true,"sender":{"key":"pw@padd.com","avatar":null},"body":"When write_loose_object() finds that it is unable to\ncreate a temporary file, it complains, for instance:\n\n    unable to create temporary sha1 filename : Too many open files\n\nThat extra space was supposed to be the name of the file,\nand will be an empty string if the git_mkstemps_mode() fails.\n\nThe name of the temporary file is unimportant; delete it.\n\nSigned-off-by: Pete Wyckoff <pw@padd.com>\n---\n sha1_file.c |    2 +-\n 1 file changed, 1 insertion(+), 1 deletion(-)\n\ndiff --git a/sha1_file.c b/sha1_file.c\nindex c8d572d..3c4f165 100644\n--- a/sha1_file.c\n+++ b/sha1_file.c\n@@ -2511,7 +2511,7 @@ static int write_loose_object(const unsigned char *sha1, char *hdr, int hdrlen,\n \t\tif (errno == EACCES)\n \t\t\treturn error(\"insufficient permission for adding an object to repository database %s\", get_object_directory());\n \t\telse\n-\t\t\treturn error(\"unable to create temporary sha1 filename %s: %s\", tmp_file, strerror(errno));\n+\t\t\treturn error(\"unable to create temporary file: %s\", strerror(errno));\n \t}\n \n \t/* Set it up */\n-- \n1.7.10.572.ged86f\n"}]}