summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 828ea97)
raw | patch | inline | side by side (parent: 828ea97)
author | Jeff King <peff@peff.net> | |
Fri, 3 Feb 2012 22:14:11 +0000 (17:14 -0500) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Fri, 3 Feb 2012 22:37:02 +0000 (14:37 -0800) |
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>
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>
prompt.c | patch | blob | history |
diff --git a/prompt.c b/prompt.c
index 72ab9de2f94be30eef9e41ced97580f7de48e0fc..64f817b36d9b654986d8499786bb5873b8246fd8 100644 (file)
--- a/prompt.c
+++ b/prompt.c
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);
strbuf_setlen(&buffer, strcspn(buffer.buf, "\r\n"));
- return buffer.buf;
+ return strbuf_detach(&buffer, NULL);
}
char *git_prompt(const char *prompt, int flags)