summaryrefslogtreecommitdiff
path: root/builtin/commit.c
diff options
context:
space:
mode:
authorJeff King <peff@peff.net>2013-01-26 09:42:45 (GMT)
committerJunio C Hamano <gitster@pobox.com>2013-01-26 21:28:19 (GMT)
commit200ebe362cda2a520219f998d4b2c44767992bdb (patch)
tree96eb5eef6a15bb4ac3f091fc579f16f1ccddf54d /builtin/commit.c
parent50a6b54c03219ad74b9f3f839e0321be18daeaf6 (diff)
downloadgit-200ebe362cda2a520219f998d4b2c44767992bdb.zip
git-200ebe362cda2a520219f998d4b2c44767992bdb.tar.gz
git-200ebe362cda2a520219f998d4b2c44767992bdb.tar.bz2
commit: drop useless xstrdup of commit message
When git-commit is asked to reuse a commit message via "-c", we call read_commit_message, which looks up the commit and hands back either the re-encoded result, or a copy of the original. We make a copy in the latter case so that the ownership semantics of the return value are clear (in either case, it can be freed). However, since we return a "const char *", and since the resulting buffer's lifetime is the same as that of the whole program, we never bother to free it at all. Let's just drop the copy. That saves us a copy in the common case. While it does mean we leak in the re-encode case, it doesn't matter, since we are relying on program exit to free the memory anyway. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin/commit.c')
-rw-r--r--builtin/commit.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/builtin/commit.c b/builtin/commit.c
index 38b9a9c..fbbb40f 100644
--- a/builtin/commit.c
+++ b/builtin/commit.c
@@ -962,7 +962,7 @@ static const char *read_commit_message(const char *name)
* encodings are identical.
*/
if (out == NULL)
- out = xstrdup(commit->buffer);
+ out = commit->buffer;
return out;
}