From: Jonathan Nieder Date: Sat, 2 Oct 2010 08:41:00 +0000 (-0500) Subject: commit-tree: free commit message before exiting X-Git-Tag: v1.7.4-rc0~182 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=79bc2af5ae161d1e81b57313c81fb81e3ec6c57d;p=git.git commit-tree: free commit message before exiting This buffer is freed by the C runtime when commit-tree exits moments later, but freeing it explicitly should make valgrind quieter. Signed-off-by: Jonathan Nieder Signed-off-by: Junio C Hamano --- diff --git a/builtin/commit-tree.c b/builtin/commit-tree.c index 87f0591c2..732f8952b 100644 --- a/builtin/commit-tree.c +++ b/builtin/commit-tree.c @@ -56,10 +56,12 @@ int cmd_commit_tree(int argc, const char **argv, const char *prefix) if (strbuf_read(&buffer, 0, 0) < 0) die_errno("git commit-tree: failed to read"); - if (!commit_tree(buffer.buf, tree_sha1, parents, commit_sha1, NULL)) { - printf("%s\n", sha1_to_hex(commit_sha1)); - return 0; - } - else + if (commit_tree(buffer.buf, tree_sha1, parents, commit_sha1, NULL)) { + strbuf_release(&buffer); return 1; + } + + printf("%s\n", sha1_to_hex(commit_sha1)); + strbuf_release(&buffer); + return 0; }