{"thread":{"id":"42973","subject":"[PATCH] use strbuf_addstr() for adding constant strings to a strbuf","startedAt":"2016-07-30T17:36:39Z","lastAt":"2016-08-01T20:41:10Z","messageCount":3,"participants":["René Scharfe","Jeff King","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"292644","messageId":"579CE597.4060009@web.de","threadId":"42973","inReplyTo":null,"subject":"[PATCH] use strbuf_addstr() for adding constant strings to a strbuf","fromName":"René Scharfe","fromEmail":"l.s.r@web.de","sentAt":"2016-07-30T17:36:23Z","receivedAt":"2016-07-30T17:36:39Z","isPatch":true,"sender":{"key":"l.s.r@web.de","avatar":"https://avatars.githubusercontent.com/u/26122331?v=4"},"body":"Replace uses of strbuf_addf() for adding strings with more lightweight\nstrbuf_addstr() calls.\n\nIn http-push.c it becomes easier to see what's going on without having\nto verfiy that the definition of PROPFIND_ALL_REQUEST doesn't contain\nany format specifiers.\n\nSigned-off-by: Rene Scharfe <l.s.r@web.de>\n---\n builtin/rev-parse.c         | 2 +-\n http-push.c                 | 2 +-\n send-pack.c                 | 2 +-\n t/helper/test-run-command.c | 6 +++---\n 4 files changed, 6 insertions(+), 6 deletions(-)\n\ndiff --git a/builtin/rev-parse.c b/builtin/rev-parse.c\nindex c961b74..76cf05e 100644\n--- a/builtin/rev-parse.c\n+++ b/builtin/rev-parse.c\n@@ -469,7 +469,7 @@ static int cmd_parseopt(int argc, const char **argv, const char *prefix)\n \t\t\t(stop_at_non_option ? PARSE_OPT_STOP_AT_NON_OPTION : 0) |\n \t\t\tPARSE_OPT_SHELL_EVAL);\n \n-\tstrbuf_addf(&parsed, \" --\");\n+\tstrbuf_addstr(&parsed, \" --\");\n \tsq_quote_argv(&parsed, argv, 0);\n \tputs(parsed.buf);\n \treturn 0;\ndiff --git a/http-push.c b/http-push.c\nindex a092f02..d0b29ac 100644\n--- a/http-push.c\n+++ b/http-push.c\n@@ -1137,7 +1137,7 @@ static void remote_ls(const char *path, int flags,\n \tls.userData = userData;\n \tls.userFunc = userFunc;\n \n-\tstrbuf_addf(&out_buffer.buf, PROPFIND_ALL_REQUEST);\n+\tstrbuf_addstr(&out_buffer.buf, PROPFIND_ALL_REQUEST);\n \n \tdav_headers = curl_slist_append(dav_headers, \"Depth: 1\");\n \tdav_headers = curl_slist_append(dav_headers, \"Content-Type: text/xml\");\ndiff --git a/send-pack.c b/send-pack.c\nindex 299d303..1f85c56 100644\n--- a/send-pack.c\n+++ b/send-pack.c\n@@ -265,7 +265,7 @@ static int generate_push_cert(struct strbuf *req_buf,\n \tstruct strbuf cert = STRBUF_INIT;\n \tint update_seen = 0;\n \n-\tstrbuf_addf(&cert, \"certificate version 0.1\\n\");\n+\tstrbuf_addstr(&cert, \"certificate version 0.1\\n\");\n \tstrbuf_addf(&cert, \"pusher %s \", signing_key);\n \tdatestamp(&cert);\n \tstrbuf_addch(&cert, '\\n');\ndiff --git a/t/helper/test-run-command.c b/t/helper/test-run-command.c\nindex 30a64a9..6bb53da 100644\n--- a/t/helper/test-run-command.c\n+++ b/t/helper/test-run-command.c\n@@ -26,7 +26,7 @@ static int parallel_next(struct child_process *cp,\n \t\treturn 0;\n \n \targv_array_pushv(&cp->args, d->argv);\n-\tstrbuf_addf(err, \"preloaded output of a child\\n\");\n+\tstrbuf_addstr(err, \"preloaded output of a child\\n\");\n \tnumber_callbacks++;\n \treturn 1;\n }\n@@ -36,7 +36,7 @@ static int no_job(struct child_process *cp,\n \t\t  void *cb,\n \t\t  void **task_cb)\n {\n-\tstrbuf_addf(err, \"no further jobs available\\n\");\n+\tstrbuf_addstr(err, \"no further jobs available\\n\");\n \treturn 0;\n }\n \n@@ -45,7 +45,7 @@ static int task_finished(int result,\n \t\t\t void *pp_cb,\n \t\t\t void *pp_task_cb)\n {\n-\tstrbuf_addf(err, \"asking for a quick stop\\n\");\n+\tstrbuf_addstr(err, \"asking for a quick stop\\n\");\n \treturn 1;\n }\n \n-- \n2.9.2\n\n"},{"id":"292753","messageId":"20160801164929.ezalmutcrc3erc22@sigill.intra.peff.net","threadId":"42973","inReplyTo":"579CE597.4060009@web.de","subject":"Re: [PATCH] use strbuf_addstr() for adding constant strings to a strbuf","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2016-08-01T16:49:29Z","receivedAt":"2016-08-01T17:16:22Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Sat, Jul 30, 2016 at 07:36:23PM +0200, René Scharfe wrote:\n\n> Replace uses of strbuf_addf() for adding strings with more lightweight\n> strbuf_addstr() calls.\n> \n> In http-push.c it becomes easier to see what's going on without having\n> to verfiy that the definition of PROPFIND_ALL_REQUEST doesn't contain\n> any format specifiers.\n\nNice. I care a lot less about whether \"addf\" or \"addstr\" is more\nefficient. But the second point, that it makes the intent clearer, is a\nbig win.\n\n-Peff\n"},{"id":"292790","messageId":"xmqqd1lsi5nn.fsf@gitster.mtv.corp.google.com","threadId":"42973","inReplyTo":"20160801164929.ezalmutcrc3erc22@sigill.intra.peff.net","subject":"Re: [PATCH] use strbuf_addstr() for adding constant strings to a strbuf","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2016-08-01T20:41:00Z","receivedAt":"2016-08-01T20:41:10Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Jeff King <peff@peff.net> writes:\n\n> On Sat, Jul 30, 2016 at 07:36:23PM +0200, René Scharfe wrote:\n>\n>> Replace uses of strbuf_addf() for adding strings with more lightweight\n>> strbuf_addstr() calls.\n>> \n>> In http-push.c it becomes easier to see what's going on without having\n>> to verfiy that the definition of PROPFIND_ALL_REQUEST doesn't contain\n>> any format specifiers.\n>\n> Nice. I care a lot less about whether \"addf\" or \"addstr\" is more\n> efficient. But the second point, that it makes the intent clearer, is a\n> big win.\n\nYes!\n"}]}