Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeff King <peff@peff.net>2010-02-12 00:07:06 +0300
committerJunio C Hamano <gitster@pobox.com>2010-02-12 09:11:03 +0300
commit08565bdb4b5d1da597ed8b90d1a23729f7c006d0 (patch)
tree76622bf234ef4d2c4220df1dc34c250ed75123b1 /builtin-revert.c
parentdd9314cc2a2f353bf9438db14cbbf02a1c219bda (diff)
cherry-pick: format help message as strbuf
This gets rid of the fixed-size buffer and an unchecked sprintf. That sprintf is actually OK as the only variable-sized thing put in it is an abbreviated sha1, which is bounded at 40 characters. However, the next patch will change that to something unbounded. Note that this function now returns an allocated buffer instead of a static one; however, it doesn't matter as the only caller exits immediately. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin-revert.c')
-rw-r--r--builtin-revert.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/builtin-revert.c b/builtin-revert.c
index 012c64644d..77e4f4eed3 100644
--- a/builtin-revert.c
+++ b/builtin-revert.c
@@ -200,23 +200,23 @@ static void set_author_ident_env(const char *message)
static char *help_msg(const unsigned char *sha1)
{
- static char helpbuf[1024];
+ struct strbuf helpbuf = STRBUF_INIT;
char *msg = getenv("GIT_CHERRY_PICK_HELP");
if (msg)
return msg;
- strcpy(helpbuf, " After resolving the conflicts,\n"
+ strbuf_addstr(&helpbuf, " After resolving the conflicts,\n"
"mark the corrected paths with 'git add <paths>' or 'git rm <paths>'\n"
"and commit the result.");
if (action == CHERRY_PICK) {
- sprintf(helpbuf + strlen(helpbuf),
+ strbuf_addf(&helpbuf,
" When committing, use the option '-c %s'\n"
"to retain authorship and message.",
find_unique_abbrev(sha1, DEFAULT_ABBREV));
}
- return helpbuf;
+ return strbuf_detach(&helpbuf, NULL);
}
static struct tree *empty_tree(void)