{"thread":{"id":"16985","subject":"[PATCH] remove trailing '\\n's in 'die' macros","startedAt":"2009-01-04T18:38:41Z","lastAt":"2009-01-04T18:38:41Z","messageCount":1,"participants":["Alexander Potashev"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"99318","messageId":"1231094321-8796-1-git-send-email-aspotashev@gmail.com","threadId":"16985","inReplyTo":null,"subject":"[PATCH] remove trailing '\\n's in 'die' macros","fromName":"Alexander Potashev","fromEmail":"aspotashev@gmail.com","sentAt":"2009-01-04T18:38:41Z","receivedAt":"2009-01-04T18:38:41Z","isPatch":true,"sender":{"key":"aspotashev@gmail.com","avatar":null},"body":"'\\n's in the end of format strings given to 'die' are redundant because\ndie uses error reporting function like 'static void report(const char\n*prefix, const char *err, va_list params)' which always adds a '\\n'.\n\nSigned-off-by: Alexander Potashev <aspotashev@gmail.com>\n---\n builtin-cat-file.c        |    2 +-\n builtin-clone.c           |   14 +++++++-------\n builtin-fetch.c           |    2 +-\n builtin-init-db.c         |    2 +-\n builtin-log.c             |    2 +-\n builtin-mailinfo.c        |    2 +-\n builtin-merge-recursive.c |    2 +-\n builtin-update-index.c    |    2 +-\n connect.c                 |    2 +-\n daemon.c                  |    2 +-\n diff.c                    |    2 +-\n git.c                     |    2 +-\n grep.c                    |    2 +-\n imap-send.c               |    6 +++---\n index-pack.c              |    2 +-\n pack-redundant.c          |    8 ++++----\n 16 files changed, 27 insertions(+), 27 deletions(-)\n\ndiff --git a/builtin-cat-file.c b/builtin-cat-file.c\nindex 30d00a6..8fad19d 100644\n--- a/builtin-cat-file.c\n+++ b/builtin-cat-file.c\n@@ -137,7 +137,7 @@ static int cat_one_file(int opt, const char *exp_type, const char *obj_name)\n \t\tbreak;\n \n \tdefault:\n-\t\tdie(\"git cat-file: unknown option: %s\\n\", exp_type);\n+\t\tdie(\"git cat-file: unknown option: %s\", exp_type);\n \t}\n \n \tif (!buf)\ndiff --git a/builtin-clone.c b/builtin-clone.c\nindex 2feac9c..f1a1a0c 100644\n--- a/builtin-clone.c\n+++ b/builtin-clone.c\n@@ -192,15 +192,15 @@ static void copy_or_link_directory(struct strbuf *src, struct strbuf *dest)\n \n \tdir = opendir(src->buf);\n \tif (!dir)\n-\t\tdie(\"failed to open %s\\n\", src->buf);\n+\t\tdie(\"failed to open %s\", src->buf);\n \n \tif (mkdir(dest->buf, 0777)) {\n \t\tif (errno != EEXIST)\n-\t\t\tdie(\"failed to create directory %s\\n\", dest->buf);\n+\t\t\tdie(\"failed to create directory %s\", dest->buf);\n \t\telse if (stat(dest->buf, &buf))\n-\t\t\tdie(\"failed to stat %s\\n\", dest->buf);\n+\t\t\tdie(\"failed to stat %s\", dest->buf);\n \t\telse if (!S_ISDIR(buf.st_mode))\n-\t\t\tdie(\"%s exists and is not a directory\\n\", dest->buf);\n+\t\t\tdie(\"%s exists and is not a directory\", dest->buf);\n \t}\n \n \tstrbuf_addch(src, '/');\n@@ -224,16 +224,16 @@ static void copy_or_link_directory(struct strbuf *src, struct strbuf *dest)\n \t\t}\n \n \t\tif (unlink(dest->buf) && errno != ENOENT)\n-\t\t\tdie(\"failed to unlink %s\\n\", dest->buf);\n+\t\t\tdie(\"failed to unlink %s\", dest->buf);\n \t\tif (!option_no_hardlinks) {\n \t\t\tif (!link(src->buf, dest->buf))\n \t\t\t\tcontinue;\n \t\t\tif (option_local)\n-\t\t\t\tdie(\"failed to create link %s\\n\", dest->buf);\n+\t\t\t\tdie(\"failed to create link %s\", dest->buf);\n \t\t\toption_no_hardlinks = 1;\n \t\t}\n \t\tif (copy_file(dest->buf, src->buf, 0666))\n-\t\t\tdie(\"failed to copy file to %s\\n\", dest->buf);\n+\t\t\tdie(\"failed to copy file to %s\", dest->buf);\n \t}\n \tclosedir(dir);\n }\ndiff --git a/builtin-fetch.c b/builtin-fetch.c\nindex 7568163..de6f307 100644\n--- a/builtin-fetch.c\n+++ b/builtin-fetch.c\n@@ -607,7 +607,7 @@ static void set_option(const char *name, const char *value)\n {\n \tint r = transport_set_option(transport, name, value);\n \tif (r < 0)\n-\t\tdie(\"Option \\\"%s\\\" value \\\"%s\\\" is not valid for %s\\n\",\n+\t\tdie(\"Option \\\"%s\\\" value \\\"%s\\\" is not valid for %s\",\n \t\t\tname, value, transport->url);\n \tif (r > 0)\n \t\twarning(\"Option \\\"%s\\\" is ignored for %s\\n\",\ndiff --git a/builtin-init-db.c b/builtin-init-db.c\nindex d30c3fe..ee3911f 100644\n--- a/builtin-init-db.c\n+++ b/builtin-init-db.c\n@@ -29,7 +29,7 @@ static void safe_create_dir(const char *dir, int share)\n \t\t}\n \t}\n \telse if (share && adjust_shared_perm(dir))\n-\t\tdie(\"Could not make %s writable by group\\n\", dir);\n+\t\tdie(\"Could not make %s writable by group\", dir);\n }\n \n static void copy_templates_1(char *path, int baselen,\ndiff --git a/builtin-log.c b/builtin-log.c\nindex 99d1137..1fc1ae0 100644\n--- a/builtin-log.c\n+++ b/builtin-log.c\n@@ -824,7 +824,7 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)\n \t\t\tcommitter = git_committer_info(IDENT_ERROR_ON_NO_NAME);\n \t\t\tendpos = strchr(committer, '>');\n \t\t\tif (!endpos)\n-\t\t\t\tdie(\"bogus committer info %s\\n\", committer);\n+\t\t\t\tdie(\"bogus committer info %s\", committer);\n \t\t\tadd_signoff = xmemdupz(committer, endpos - committer + 1);\n \t\t}\n \t\telse if (!strcmp(argv[i], \"--attach\")) {\ndiff --git a/builtin-mailinfo.c b/builtin-mailinfo.c\nindex e890f7a..f7c8c08 100644\n--- a/builtin-mailinfo.c\n+++ b/builtin-mailinfo.c\n@@ -494,7 +494,7 @@ static void convert_to_utf8(struct strbuf *line, const char *charset)\n \t\treturn;\n \tout = reencode_string(line->buf, metainfo_charset, charset);\n \tif (!out)\n-\t\tdie(\"cannot convert from %s to %s\\n\",\n+\t\tdie(\"cannot convert from %s to %s\",\n \t\t    charset, metainfo_charset);\n \tstrbuf_attach(line, out, strlen(out), strlen(out));\n }\ndiff --git a/builtin-merge-recursive.c b/builtin-merge-recursive.c\nindex 6b534c1..703045b 100644\n--- a/builtin-merge-recursive.c\n+++ b/builtin-merge-recursive.c\n@@ -33,7 +33,7 @@ int cmd_merge_recursive(int argc, const char **argv, const char *prefix)\n \t}\n \n \tif (argc < 4)\n-\t\tdie(\"Usage: %s <base>... -- <head> <remote> ...\\n\", argv[0]);\n+\t\tdie(\"Usage: %s <base>... -- <head> <remote> ...\", argv[0]);\n \n \tfor (i = 1; i < argc; ++i) {\n \t\tif (!strcmp(argv[i], \"--\"))\ndiff --git a/builtin-update-index.c b/builtin-update-index.c\nindex 65d5775..5604977 100644\n--- a/builtin-update-index.c\n+++ b/builtin-update-index.c\n@@ -486,7 +486,7 @@ static int unresolve_one(const char *path)\n static void read_head_pointers(void)\n {\n \tif (read_ref(\"HEAD\", head_sha1))\n-\t\tdie(\"No HEAD -- no initial commit yet?\\n\");\n+\t\tdie(\"No HEAD -- no initial commit yet?\");\n \tif (read_ref(\"MERGE_HEAD\", merge_head_sha1)) {\n \t\tfprintf(stderr, \"Not in the middle of a merge.\\n\");\n \t\texit(0);\ndiff --git a/connect.c b/connect.c\nindex 2f55ad2..2f23ab3 100644\n--- a/connect.c\n+++ b/connect.c\n@@ -315,7 +315,7 @@ static int git_tcp_connect_sock(char *host, int flags)\n \t\t/* Not numeric */\n \t\tstruct servent *se = getservbyname(port,\"tcp\");\n \t\tif ( !se )\n-\t\t\tdie(\"Unknown port %s\\n\", port);\n+\t\t\tdie(\"Unknown port %s\", port);\n \t\tnport = se->s_port;\n \t}\n \ndiff --git a/daemon.c b/daemon.c\nindex 60bf6c7..540700e 100644\n--- a/daemon.c\n+++ b/daemon.c\n@@ -716,7 +716,7 @@ static int socksetup(char *listen_addr, int listen_port, int **socklist_p)\n \n \tgai = getaddrinfo(listen_addr, pbuf, &hints, &ai0);\n \tif (gai)\n-\t\tdie(\"getaddrinfo() failed: %s\\n\", gai_strerror(gai));\n+\t\tdie(\"getaddrinfo() failed: %s\", gai_strerror(gai));\n \n \tfor (ai = ai0; ai; ai = ai->ai_next) {\n \t\tint sockfd;\ndiff --git a/diff.c b/diff.c\nindex 0484601..c159a5f 100644\n--- a/diff.c\n+++ b/diff.c\n@@ -2039,7 +2039,7 @@ static void diff_fill_sha1_info(struct diff_filespec *one)\n \t\t\tif (lstat(one->path, &st) < 0)\n \t\t\t\tdie(\"stat %s\", one->path);\n \t\t\tif (index_path(one->sha1, one->path, &st, 0))\n-\t\t\t\tdie(\"cannot hash %s\\n\", one->path);\n+\t\t\t\tdie(\"cannot hash %s\", one->path);\n \t\t}\n \t}\n \telse\ndiff --git a/git.c b/git.c\nindex e0d9071..a53e24f 100644\n--- a/git.c\n+++ b/git.c\n@@ -158,7 +158,7 @@ static int handle_alias(int *argcp, const char ***argv)\n \t\t\tif (ret >= 0 && WIFEXITED(ret) &&\n \t\t\t    WEXITSTATUS(ret) != 127)\n \t\t\t\texit(WEXITSTATUS(ret));\n-\t\t\tdie(\"Failed to run '%s' when expanding alias '%s'\\n\",\n+\t\t\tdie(\"Failed to run '%s' when expanding alias '%s'\",\n \t\t\t    alias_string + 1, alias_command);\n \t\t}\n \t\tcount = split_cmdline(alias_string, &new_argv);\ndiff --git a/grep.c b/grep.c\nindex 600f69f..49e9319 100644\n--- a/grep.c\n+++ b/grep.c\n@@ -395,7 +395,7 @@ static int match_expr_eval(struct grep_opt *o,\n \t\th |= match_expr_eval(o, x->u.binary.right, bol, eol, ctx, 1);\n \t\tbreak;\n \tdefault:\n-\t\tdie(\"Unexpected node type (internal error) %d\\n\", x->node);\n+\t\tdie(\"Unexpected node type (internal error) %d\", x->node);\n \t}\n \tif (collect_hits)\n \t\tx->hit |= h;\ndiff --git a/imap-send.c b/imap-send.c\nindex 3703dbd..c3fa0df 100644\n--- a/imap-send.c\n+++ b/imap-send.c\n@@ -115,9 +115,9 @@ static int nfvasprintf(char **strp, const char *fmt, va_list ap)\n \n \tlen = vsnprintf(tmp, sizeof(tmp), fmt, ap);\n \tif (len < 0)\n-\t\tdie(\"Fatal: Out of memory\\n\");\n+\t\tdie(\"Fatal: Out of memory\");\n \tif (len >= sizeof(tmp))\n-\t\tdie(\"imap command overflow !\\n\");\n+\t\tdie(\"imap command overflow!\");\n \t*strp = xmemdupz(tmp, len);\n \treturn len;\n }\n@@ -482,7 +482,7 @@ static int nfsnprintf(char *buf, int blen, const char *fmt, ...)\n \n \tva_start(va, fmt);\n \tif (blen <= 0 || (unsigned)(ret = vsnprintf(buf, blen, fmt, va)) >= (unsigned)blen)\n-\t\tdie(\"Fatal: buffer too small. Please report a bug.\\n\");\n+\t\tdie(\"Fatal: buffer too small. Please report a bug.\");\n \tva_end(va);\n \treturn ret;\n }\ndiff --git a/index-pack.c b/index-pack.c\nindex 60ed41a..2931511 100644\n--- a/index-pack.c\n+++ b/index-pack.c\n@@ -178,7 +178,7 @@ static char *open_pack_file(char *pack_name)\n \t\t} else\n \t\t\toutput_fd = open(pack_name, O_CREAT|O_EXCL|O_RDWR, 0600);\n \t\tif (output_fd < 0)\n-\t\t\tdie(\"unable to create %s: %s\\n\", pack_name, strerror(errno));\n+\t\t\tdie(\"unable to create %s: %s\", pack_name, strerror(errno));\n \t\tpack_fd = output_fd;\n \t} else {\n \t\tinput_fd = open(pack_name, O_RDONLY);\ndiff --git a/pack-redundant.c b/pack-redundant.c\nindex 25b81a4..e93eb96 100644\n--- a/pack-redundant.c\n+++ b/pack-redundant.c\n@@ -463,7 +463,7 @@ static void minimize(struct pack_list **min)\n \t\tpll_free(perm_all);\n \t}\n \tif (perm_ok == NULL)\n-\t\tdie(\"Internal error: No complete sets found!\\n\");\n+\t\tdie(\"Internal error: No complete sets found!\");\n \n \t/* find the permutation with the smallest size */\n \tperm = perm_ok;\n@@ -573,14 +573,14 @@ static struct pack_list * add_pack_file(char *filename)\n \tstruct packed_git *p = packed_git;\n \n \tif (strlen(filename) < 40)\n-\t\tdie(\"Bad pack filename: %s\\n\", filename);\n+\t\tdie(\"Bad pack filename: %s\", filename);\n \n \twhile (p) {\n \t\tif (strstr(p->pack_name, filename))\n \t\t\treturn add_pack(p);\n \t\tp = p->next;\n \t}\n-\tdie(\"Filename %s not found in packed_git\\n\", filename);\n+\tdie(\"Filename %s not found in packed_git\", filename);\n }\n \n static void load_all(void)\n@@ -636,7 +636,7 @@ int main(int argc, char **argv)\n \t\t\tadd_pack_file(*(argv + i++));\n \n \tif (local_packs == NULL)\n-\t\tdie(\"Zero packs found!\\n\");\n+\t\tdie(\"Zero packs found!\");\n \n \tload_all_objects();\n \n-- \n1.6.0.6\n"}]}