From dc6f25cdef4e7a307b430739047807deb0ae2602 Mon Sep 17 00:00:00 2001 From: Loic d'Anterroches Date: Sun, 12 Jul 2009 22:13:52 +0200 Subject: [PATCH] Fixed to handle the case of bad commit. --- src/IDF/Views/Source.php | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/IDF/Views/Source.php b/src/IDF/Views/Source.php index 2f0d5c7..541be76 100644 --- a/src/IDF/Views/Source.php +++ b/src/IDF/Views/Source.php @@ -271,10 +271,17 @@ class IDF_Views_Source $scm->getMainBranch())); return new Pluf_HTTP_Response_Redirect($url); } - $title = sprintf(__('%s Commit Details'), (string) $request->project); - $page_title = sprintf(__('%s Commit Details - %s'), (string) $request->project, $commit); $large = $scm->isCommitLarge($commit); $cobject = $scm->getCommit($commit, !$large); + if (!$cobject) { + // Redirect to the first branch + $url = Pluf_HTTP_URL_urlForView('IDF_Views_Source::treeBase', + array($request->project->shortname, + $scm->getMainBranch())); + return new Pluf_HTTP_Response_Redirect($url); + } + $title = sprintf(__('%s Commit Details'), (string) $request->project); + $page_title = sprintf(__('%s Commit Details - %s'), (string) $request->project, $commit); $rcommit = IDF_Commit::getOrAdd($cobject, $request->project); $diff = new IDF_Diff($cobject->changes); $diff->parse();