grep: use return value of strbuf_detach()

Append the strbuf buffer only after detaching it.  There is no practical
difference here, as the strbuf is not empty and no strbuf_ function is
called between storing the pointer to the still attached buffer and
calling strbuf_detach(), so that pointer is valid, but make sure to
follow the standard sequence anyway for consistency.

Signed-off-by: René Scharfe <l.s.r@web.de>
Acked-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
René Scharfe 2019-08-25 15:26:40 +02:00 коммит произвёл Junio C Hamano
Родитель 82f51af345
Коммит fd99c2dd9b
1 изменённых файлов: 2 добавлений и 2 удалений

Просмотреть файл

@ -1110,8 +1110,8 @@ int cmd_grep(int argc, const char **argv, const char *prefix)
strbuf_addf(&buf, "+/%s%s", strbuf_addf(&buf, "+/%s%s",
strcmp("less", pager) ? "" : "*", strcmp("less", pager) ? "" : "*",
opt.pattern_list->pattern); opt.pattern_list->pattern);
string_list_append(&path_list, buf.buf); string_list_append(&path_list,
strbuf_detach(&buf, NULL); strbuf_detach(&buf, NULL));
} }
} }