Signed-off-by: Igor Gnatenko <i.gnatenko.brain@gmail.com>epel9
parent
42b79661eb
commit
a1fed87ff1
@ -0,0 +1,43 @@
|
|||||||
|
From a719ef5e6d4a1a8ec53469c7914032ed67922772 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Patrick Steinhardt <ps@pks.im>
|
||||||
|
Date: Fri, 7 Oct 2016 09:31:41 +0200
|
||||||
|
Subject: [PATCH] commit: always initialize commit message
|
||||||
|
|
||||||
|
When parsing a commit, we will treat all bytes left after parsing
|
||||||
|
the headers as the commit message. When no bytes are left, we
|
||||||
|
leave the commit's message uninitialized. While uncommon to have
|
||||||
|
a commit without message, this is the right behavior as Git
|
||||||
|
unfortunately allows for empty commit messages.
|
||||||
|
|
||||||
|
Given that this scenario is so uncommon, most programs acting on
|
||||||
|
the commit message will never check if the message is actually
|
||||||
|
set, which may lead to errors. To work around the error and not
|
||||||
|
lay the burden of checking for empty commit messages to the
|
||||||
|
developer, initialize the commit message with an empty string
|
||||||
|
when no commit message is given.
|
||||||
|
---
|
||||||
|
src/commit.c | 7 ++++---
|
||||||
|
1 file changed, 4 insertions(+), 3 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/src/commit.c b/src/commit.c
|
||||||
|
index 99a8085..76e6dcb 100644
|
||||||
|
--- a/src/commit.c
|
||||||
|
+++ b/src/commit.c
|
||||||
|
@@ -459,10 +459,11 @@ int git_commit__parse(void *_commit, git_odb_object *odb_obj)
|
||||||
|
buffer = buffer_start + header_len + 1;
|
||||||
|
|
||||||
|
/* extract commit message */
|
||||||
|
- if (buffer <= buffer_end) {
|
||||||
|
+ if (buffer <= buffer_end)
|
||||||
|
commit->raw_message = git__strndup(buffer, buffer_end - buffer);
|
||||||
|
- GITERR_CHECK_ALLOC(commit->raw_message);
|
||||||
|
- }
|
||||||
|
+ else
|
||||||
|
+ commit->raw_message = git__strdup("");
|
||||||
|
+ GITERR_CHECK_ALLOC(commit->raw_message);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
--
|
||||||
|
2.10.1
|
||||||
|
|
Loading…
Reference in new issue