diff --git a/PBGitHistoryView.xib b/PBGitHistoryView.xib
index b001d40..cf41060 100644
--- a/PBGitHistoryView.xib
+++ b/PBGitHistoryView.xib
@@ -8,7 +8,7 @@
353.00
+
{346, 133}
@@ -2077,6 +2096,14 @@
271
+
+
+ errorMessage
+
+
+
+ 274
+
@@ -2391,6 +2418,7 @@
+
@@ -2692,6 +2720,20 @@
+
+ 272
+
+
+ YES
+
+
+
+
+
+ 273
+
+
+
@@ -2769,6 +2811,8 @@
27.IBViewIntegration.shadowOffsetHeight
27.IBViewIntegration.shadowOffsetWidth
27.ImportedFromIB2
+ 272.IBPluginDependency
+ 273.IBPluginDependency
28.IBPluginDependency
28.IBShouldRemoveOnLegacySave
29.IBPluginDependency
@@ -2861,8 +2905,8 @@
com.apple.InterfaceBuilder.CocoaPlugin
com.apple.InterfaceBuilder.CocoaPlugin
com.apple.InterfaceBuilder.CocoaPlugin
- {{521, 623}, {346, 133}}
- {{521, 623}, {346, 133}}
+ {{504, 581}, {346, 133}}
+ {{504, 581}, {346, 133}}
{3.40282e+38, 3.40282e+38}
com.apple.InterfaceBuilder.CocoaPlugin
@@ -2898,6 +2942,8 @@
com.apple.InterfaceBuilder.CocoaPlugin
+ com.apple.InterfaceBuilder.CocoaPlugin
+ com.apple.InterfaceBuilder.CocoaPlugin
com.apple.InterfaceBuilder.CocoaPlugin
@@ -2931,7 +2977,7 @@
com.apple.InterfaceBuilder.CocoaPlugin
com.apple.InterfaceBuilder.CocoaPlugin
- {{312, 79}, {852, 432}}
+ {{189, 79}, {852, 432}}
com.apple.InterfaceBuilder.CocoaPlugin
com.apple.InterfaceBuilder.CocoaPlugin
com.apple.InterfaceBuilder.CocoaPlugin
@@ -2966,7 +3012,7 @@
- 271
+ 274
@@ -3120,6 +3166,7 @@
branchPopUp
commitController
commitList
+ errorMessage
historyController
newBranchName
newBranchSheet
@@ -3129,6 +3176,7 @@
NSPopUpButton
NSArrayController
PBCommitList
+ NSTextField
PBGitHistoryController
NSTextField
NSWindow
diff --git a/PBGitRevList.mm b/PBGitRevList.mm
index ba39a3a..61a1b27 100644
--- a/PBGitRevList.mm
+++ b/PBGitRevList.mm
@@ -76,9 +76,9 @@ using namespace std;
BOOL showSign = [rev hasLeftRight];
if (showSign)
- arguments = [NSMutableArray arrayWithObjects:@"log", @"-z", @"--early-output", @"--topo-order", @"--pretty=format:%H\01%an\01%s\01%P\01%at\01%m", nil];
+ arguments = [NSMutableArray arrayWithObjects:@"log", @"-z", @"--early-output", @"--topo-order", @"--pretty=format:%H\01%e\01%an\01%s\01%P\01%at\01%m", nil];
else
- arguments = [NSMutableArray arrayWithObjects:@"log", @"-z", @"--early-output", @"--topo-order", @"--pretty=format:%H\01%an\01%s\01%P\01%at", nil];
+ arguments = [NSMutableArray arrayWithObjects:@"log", @"-z", @"--early-output", @"--topo-order", @"--pretty=format:%H\01%e\01%an\01%s\01%P\01%at", nil];
if (!rev)
[arguments addObject:@"HEAD"];
@@ -111,11 +111,21 @@ using namespace std;
[self performSelectorOnMainThread:@selector(setCommits:) withObject:revisions waitUntilDone:NO];
g = [[PBGitGrapher alloc] initWithRepository: repository];
revisions = [NSMutableArray array];
-
+
+ // If the length is < 40, then there are no commits.. quit now
+ if (sha.length() < 40)
+ break;
+
sha = sha.substr(sha.length() - 40, 40);
}
// From now on, 1.2 seconds
+ string encoding_str;
+ getline(stream, encoding_str, '\1');
+ NSStringEncoding encoding = NSUTF8StringEncoding;
+ if (encoding_str.length())
+ encoding = CFStringConvertEncodingToNSStringEncoding(CFStringConvertIANACharSetNameToEncoding((CFStringRef)[NSString stringWithUTF8String:encoding_str.c_str()]));
+
git_oid oid;
git_oid_mkstr(&oid, sha.c_str());
PBGitCommit* newCommit = [[PBGitCommit alloc] initWithRepository:repository andSha:oid];
@@ -148,8 +158,8 @@ using namespace std;
stream >> time;
- [newCommit setSubject:[NSString stringWithUTF8String:subject.c_str()]];
- [newCommit setAuthor:[NSString stringWithUTF8String:author.c_str()]];
+ [newCommit setSubject:[NSString stringWithCString:subject.c_str() encoding:encoding]];
+ [newCommit setAuthor:[NSString stringWithCString:author.c_str() encoding:encoding]];
[newCommit setTimestamp:time];
if (showSign)
diff --git a/PBRefController.h b/PBRefController.h
index 4ec8990..0706fc5 100644
--- a/PBRefController.h
+++ b/PBRefController.h
@@ -20,6 +20,7 @@
IBOutlet NSWindow *newBranchSheet;
IBOutlet NSTextField *newBranchName;
+ IBOutlet NSTextField *errorMessage;
IBOutlet NSPopUpButton *branchPopUp;
}
diff --git a/PBRefController.m b/PBRefController.m
index 345ad93..23abe60 100644
--- a/PBRefController.m
+++ b/PBRefController.m
@@ -177,6 +177,7 @@
# pragma mark Add ref methods
-(void)addRef:(id)sender
{
+ [errorMessage setStringValue:@""];
[NSApp beginSheet:newBranchSheet
modalForWindow:[[historyController view] window]
modalDelegate:NULL
@@ -187,20 +188,28 @@
-(void)saveSheet:(id) sender
{
NSString *branchName = [@"refs/heads/" stringByAppendingString:[newBranchName stringValue]];
- [self closeSheet:sender];
if ([[commitController selectedObjects] count] == 0)
return;
-
+
PBGitCommit *commit = [[commitController selectedObjects] objectAtIndex:0];
+
int retValue = 1;
- [historyController.repository outputForArguments:[NSArray arrayWithObjects:@"update-ref", @"-mCreate branch from GitX", branchName, [commit realSha], NULL] retValue:&retValue];
- if (retValue)
- {
- NSLog(@"Creating ref failed!");
+ [historyController.repository outputForArguments:[NSArray arrayWithObjects:@"check-ref-format", branchName, nil] retValue:&retValue];
+ if (retValue != 0) {
+ [errorMessage setStringValue:@"Invalid name"];
return;
}
+ retValue = 1;
+ [historyController.repository outputForArguments:[NSArray arrayWithObjects:@"update-ref", @"-mCreate branch from GitX", branchName, [commit realSha], @"0000000000000000000000000000000000000000", NULL] retValue:&retValue];
+ if (retValue)
+ {
+ [errorMessage setStringValue:@"Branch exists"];
+ return;
+ }
+
+ [self closeSheet:sender];
[commit addRef:[PBGitRef refFromString:branchName]];
[commitController rearrangeObjects];
}