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.
This commit is contained in:
Pieter de Bie
2009-05-27 17:51:23 +01:00
parent b5dac080ff
commit df4a50aebe
+11 -2
View File
@@ -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];
}