summaryrefslogtreecommitdiff
path: root/prompt.c
diff options
context:
space:
mode:
authorJeff King <peff@peff.net>2012-02-03 17:14:11 -0500
committerJunio C Hamano <gitster@pobox.com>2012-02-03 14:37:02 -0800
commit31b49d9b653803e7c7fd18b21c8bdd86e3421668 (patch)
treeda885e35b5710ea8f100af03ed6c8b75c1905b44 /prompt.c
parent828ea97de486c1693d6e4f2c7347acb50235a85d (diff)
downloadgit-31b49d9b653803e7c7fd18b21c8bdd86e3421668.tar.gz
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: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'prompt.c')
-rw-r--r--prompt.c3
1 files changed, 1 insertions, 2 deletions
diff --git a/prompt.c b/prompt.c
index 72ab9de2f9..64f817b36d 100644
--- a/prompt.c
+++ b/prompt.c
@@ -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)