From a2c832a130e6063201a627efa9361f0d80f97cd9 Mon Sep 17 00:00:00 2001 From: Thomas Keller Date: Wed, 17 Aug 2011 20:17:14 +0200 Subject: [PATCH] Improve the 'parents' parsing for git and ignore any empty parts; also react gracefully if we could not parse the parents for some weird reason. --- NEWS.mdtext | 2 ++ src/IDF/Scm/Git.php | 6 +++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/NEWS.mdtext b/NEWS.mdtext index b404543..4732038 100644 --- a/NEWS.mdtext +++ b/NEWS.mdtext @@ -37,6 +37,8 @@ or newer to properly run this version of Indefero! and only display this list if there are any branches available for all SCMs - If git's author name is not encoded in an UTF-8 compatible encoding, skip the author lookup, as we have no information what the author string is actually encoded in +- Indefero no longer displays an empty parents paragraph in the commit view for root revisions of + a git repository ## Documentation diff --git a/src/IDF/Scm/Git.php b/src/IDF/Scm/Git.php index e56ca74..53bb417 100644 --- a/src/IDF/Scm/Git.php +++ b/src/IDF/Scm/Git.php @@ -646,7 +646,11 @@ class IDF_Scm_Git extends IDF_Scm $c['full_message'] = IDF_Commit::toUTF8($c['full_message']); $c['title'] = IDF_Commit::toUTF8($c['title']); if (isset($c['parents'])) { - $c['parents'] = explode(' ', trim($c['parents'])); + $c['parents'] = preg_split('/ /', trim($c['parents']), -1, PREG_SPLIT_NO_EMPTY); + } else { + // this is actually an error state because we should _always_ + // be able to parse the parents line with every git version + $c['parents'] = null; } $res[] = (object) $c; return $res;