git » git-arr » commit d3bf98e

Fix parsing of empty commit messages

author Vanya Sergeev
2013-10-11 17:27:21 UTC
committer Alberto Bertogli
2013-10-12 00:19:57 UTC
parent 6f5f3c4aa5b8e4bc8925aa28fff8bd0ebddc0156

Fix parsing of empty commit messages

git.py +6 -1

diff --git a/git.py b/git.py
index d005b13..f0e73ba 100644
--- a/git.py
+++ b/git.py
@@ -397,7 +397,12 @@ class Commit (object):
     @staticmethod
     def from_str(repo, buf):
         """Parses git rev-list output, returns a commit object."""
-        header, raw_message = buf.split('\n\n', 1)
+        if '\n\n' in buf:
+            # Header, commit message
+            header, raw_message = buf.split('\n\n', 1)
+        else:
+            # Header only, no commit message
+            header, raw_message = buf.rstrip(), '    '
 
         header_lines = header.split('\n')
         commit_id = header_lines.pop(0)