summaryrefslogtreecommitdiff
path: root/commit.h
diff options
context:
space:
mode:
authorJeff King <peff@peff.net>2013-01-26 09:44:06 (GMT)
committerJunio C Hamano <gitster@pobox.com>2013-01-26 21:28:21 (GMT)
commitdd0d388c44c28ebc021a24eeddc60287d4ea249c (patch)
treec2899c33f7bebae72fcc57d5d120a781a63b8ac5 /commit.h
parent200ebe362cda2a520219f998d4b2c44767992bdb (diff)
downloadgit-dd0d388c44c28ebc021a24eeddc60287d4ea249c.zip
git-dd0d388c44c28ebc021a24eeddc60287d4ea249c.tar.gz
git-dd0d388c44c28ebc021a24eeddc60287d4ea249c.tar.bz2
logmsg_reencode: never return NULL
The logmsg_reencode function will return the reencoded commit buffer, or NULL if reencoding failed or no reencoding was necessary. Since every caller then ends up checking for NULL and just using the commit's original buffer, anyway, we can be a bit more helpful and just return that buffer when we would have returned NULL. Since the resulting string may or may not need to be freed, we introduce a logmsg_free, which checks whether the buffer came from the commit object or not (callers either implemented the same check already, or kept two separate pointers, one to mark the buffer to be used, and one for the to-be-freed string). Pushing this logic into logmsg_* simplifies the callers, and will let future patches lazily load the commit buffer in a single place. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'commit.h')
-rw-r--r--commit.h1
1 files changed, 1 insertions, 0 deletions
diff --git a/commit.h b/commit.h
index c16c8a7..e770649 100644
--- a/commit.h
+++ b/commit.h
@@ -101,6 +101,7 @@ extern int has_non_ascii(const char *text);
struct rev_info; /* in revision.h, it circularly uses enum cmit_fmt */
extern char *logmsg_reencode(const struct commit *commit,
const char *output_encoding);
+extern void logmsg_free(char *msg, const struct commit *commit);
extern void get_commit_format(const char *arg, struct rev_info *);
extern const char *format_subject(struct strbuf *sb, const char *msg,
const char *line_separator);