提交 31b49d9b 编写于 作者: J Jeff King 提交者: Junio C Hamano

prompt: clean up strbuf usage

The do_askpass function inherited a few bad habits from the
original git_getpass. One, there's no need to strbuf_reset a
buffer which was just initialized. And two, it's a good
habit to use strbuf_detach to claim ownership of a buffer's
string (even though in this case the owning buffer goes out
of scope, so it's effectively the same thing).
Signed-off-by: NJeff King <peff@peff.net>
Signed-off-by: NJunio C Hamano <gitster@pobox.com>
上级 828ea97d
......@@ -21,7 +21,6 @@ static char *do_askpass(const char *cmd, const char *prompt)
if (start_command(&pass))
exit(1);
strbuf_reset(&buffer);
if (strbuf_read(&buffer, pass.out, 20) < 0)
die("failed to get '%s' from %s\n", prompt, cmd);
......@@ -32,7 +31,7 @@ static char *do_askpass(const char *cmd, const char *prompt)
strbuf_setlen(&buffer, strcspn(buffer.buf, "\r\n"));
return buffer.buf;
return strbuf_detach(&buffer, NULL);
}
char *git_prompt(const char *prompt, int flags)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册