From df4a50aebef61c54fca42c229fa64fd8105b0499 Mon Sep 17 00:00:00 2001 From: Pieter de Bie Date: Wed, 27 May 2009 17:51:23 +0100 Subject: [PATCH] CommitController: Don't rewrap commit message when amending We used to use git log with a custom pretty command to reread the commit message, but this rewraps the subject line, and also adds extra newlines. We fix this by reading in the raw commit from git-cat-file, and then searching for the double newline. --- PBGitCommitController.m | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/PBGitCommitController.m b/PBGitCommitController.m index 315da43..10c5bf1 100644 --- a/PBGitCommitController.m +++ b/PBGitCommitController.m @@ -44,8 +44,17 @@ return; amend = newAmend; - if (amend && [[commitMessageView string] length] <= 3) - commitMessageView.string = [repository outputForCommand:@"log -1 --pretty=format:%s%n%n%b HEAD"]; + // Replace commit message with the old one if it's less than 3 characters long. + // This is just a random number. + if (amend && [[commitMessageView string] length] <= 3) { + NSString *message = [repository outputForCommand:@"cat-file commit HEAD"]; + NSRange r = [message rangeOfString:@"\n\n"]; + if (r.location != NSNotFound) + message = [message substringFromIndex:r.location + 2]; + + commitMessageView.string = message; + } + [self refresh:self]; }