From 69e1c6fc45c2cdb6cf4034302e78ecaed95ea5b5 Mon Sep 17 00:00:00 2001 From: Pieter de Bie Date: Thu, 9 Oct 2008 12:43:24 +0200 Subject: [PATCH] CommitView: Don't break on oneliners e2210f7306e4c1647ff068f660db1674ce0391e1 (CommitView: Add a better reflog entry) created a bug where an exception was thrown if you enter a one-lined commit message. --- PBGitCommitController.m | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/PBGitCommitController.m b/PBGitCommitController.m index 24d6937..502ce7e 100644 --- a/PBGitCommitController.m +++ b/PBGitCommitController.m @@ -222,10 +222,12 @@ return; } - NSString *commitSubject = [commitMessage substringToIndex: - [commitMessage rangeOfString:@"\n"].location]; - if (!commitSubject) + NSString *commitSubject; + NSRange newLine = [commitMessage rangeOfString:@"\n"]; + if (newLine.location == NSNotFound) commitSubject = commitMessage; + else + commitSubject = [commitMessage substringToIndex:newLine.location]; commitSubject = [@"commit: " stringByAppendingString:commitSubject];