{"thread":{"id":"51729","subject":"[PATCH] grep: use return value of strbuf_detach()","startedAt":"2019-08-25T13:26:56Z","lastAt":"2019-08-26T14:59:20Z","messageCount":2,"participants":["René Scharfe","Johannes Schindelin"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"381114","messageId":"caf49742-65ee-7b2a-0179-ee11822b2350@web.de","threadId":"51729","inReplyTo":null,"subject":"[PATCH] grep: use return value of strbuf_detach()","fromName":"René Scharfe","fromEmail":"l.s.r@web.de","sentAt":"2019-08-25T13:26:40Z","receivedAt":"2019-08-25T13:26:56Z","isPatch":true,"sender":{"key":"l.s.r@web.de","avatar":"https://avatars.githubusercontent.com/u/26122331?v=4"},"body":"Append the strbuf buffer only after detaching it.  There is no practical\ndifference here, as the strbuf is not empty and no strbuf_ function is\ncalled between storing the pointer to the still attached buffer and\ncalling strbuf_detach(), so that pointer is valid, but make sure to\nfollow the standard sequence anyway for consistency.\n\nSigned-off-by: René Scharfe <l.s.r@web.de>\n---\n builtin/grep.c | 4 ++--\n 1 file changed, 2 insertions(+), 2 deletions(-)\n\ndiff --git a/builtin/grep.c b/builtin/grep.c\nindex 2699001fbd..69ac053acc 100644\n--- a/builtin/grep.c\n+++ b/builtin/grep.c\n@@ -1110,8 +1110,8 @@ int cmd_grep(int argc, const char **argv, const char *prefix)\n \t\t\tstrbuf_addf(&buf, \"+/%s%s\",\n \t\t\t\t\tstrcmp(\"less\", pager) ? \"\" : \"*\",\n \t\t\t\t\topt.pattern_list->pattern);\n-\t\t\tstring_list_append(&path_list, buf.buf);\n-\t\t\tstrbuf_detach(&buf, NULL);\n+\t\t\tstring_list_append(&path_list,\n+\t\t\t\t\t   strbuf_detach(&buf, NULL));\n \t\t}\n \t}\n\n--\n2.23.0\n"},{"id":"381186","messageId":"nycvar.QRO.7.76.6.1908261658210.46@tvgsbejvaqbjf.bet","threadId":"51729","inReplyTo":"caf49742-65ee-7b2a-0179-ee11822b2350@web.de","subject":"Re: [PATCH] grep: use return value of strbuf_detach()","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2019-08-26T14:58:53Z","receivedAt":"2019-08-26T14:59:20Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi René,\n\nOn Sun, 25 Aug 2019, René Scharfe wrote:\n\n> Append the strbuf buffer only after detaching it.  There is no practical\n> difference here, as the strbuf is not empty and no strbuf_ function is\n> called between storing the pointer to the still attached buffer and\n> calling strbuf_detach(), so that pointer is valid, but make sure to\n> follow the standard sequence anyway for consistency.\n\nACK!\n\nThanks,\nDscho\n\n>\n> Signed-off-by: René Scharfe <l.s.r@web.de>\n> ---\n>  builtin/grep.c | 4 ++--\n>  1 file changed, 2 insertions(+), 2 deletions(-)\n>\n> diff --git a/builtin/grep.c b/builtin/grep.c\n> index 2699001fbd..69ac053acc 100644\n> --- a/builtin/grep.c\n> +++ b/builtin/grep.c\n> @@ -1110,8 +1110,8 @@ int cmd_grep(int argc, const char **argv, const char *prefix)\n>  \t\t\tstrbuf_addf(&buf, \"+/%s%s\",\n>  \t\t\t\t\tstrcmp(\"less\", pager) ? \"\" : \"*\",\n>  \t\t\t\t\topt.pattern_list->pattern);\n> -\t\t\tstring_list_append(&path_list, buf.buf);\n> -\t\t\tstrbuf_detach(&buf, NULL);\n> +\t\t\tstring_list_append(&path_list,\n> +\t\t\t\t\t   strbuf_detach(&buf, NULL));\n>  \t\t}\n>  \t}\n>\n> --\n> 2.23.0\n>\n"}]}