summaryrefslogtreecommitdiff
path: root/builtin/commit-tree.c
diff options
context:
space:
mode:
authorJonathan Nieder <jrnieder@gmail.com>2010-10-02 03:41:00 -0500
committerJunio C Hamano <gitster@pobox.com>2010-10-06 20:30:17 -0700
commit79bc2af5ae161d1e81b57313c81fb81e3ec6c57d (patch)
tree9b81d67fe19ab45120dda8171cce6360e34cb988 /builtin/commit-tree.c
parentc752e7f3e8d96a9673ad248addc9418164bd3ce6 (diff)
downloadgit-79bc2af5ae161d1e81b57313c81fb81e3ec6c57d.tar.gz
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 <jrnieder@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin/commit-tree.c')
-rw-r--r--builtin/commit-tree.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/builtin/commit-tree.c b/builtin/commit-tree.c
index 87f0591c2f..732f8952bb 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;
}