diff --git a/PBGitHistoryView.xib b/PBGitHistoryView.xib
index 2a02912..0dd3331 100644
--- a/PBGitHistoryView.xib
+++ b/PBGitHistoryView.xib
@@ -8,7 +8,7 @@
353.00
+
{346, 133}
@@ -2075,6 +2094,14 @@
271
+
+
+ errorMessage
+
+
+
+ 274
+
@@ -2389,6 +2416,7 @@
+
@@ -2690,6 +2718,20 @@
+
+ 272
+
+
+ YES
+
+
+
+
+
+ 273
+
+
+
@@ -2767,6 +2809,8 @@
27.IBViewIntegration.shadowOffsetHeight
27.IBViewIntegration.shadowOffsetWidth
27.ImportedFromIB2
+ 272.IBPluginDependency
+ 273.IBPluginDependency
28.IBPluginDependency
28.IBShouldRemoveOnLegacySave
29.IBPluginDependency
@@ -2859,8 +2903,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
@@ -2896,6 +2940,8 @@
com.apple.InterfaceBuilder.CocoaPlugin
+ com.apple.InterfaceBuilder.CocoaPlugin
+ com.apple.InterfaceBuilder.CocoaPlugin
com.apple.InterfaceBuilder.CocoaPlugin
@@ -2929,7 +2975,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
@@ -2964,7 +3010,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/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 ccd5abd..b498386 100644
--- a/PBRefController.m
+++ b/PBRefController.m
@@ -160,6 +160,7 @@
# pragma mark Add ref methods
-(void)addRef:(id)sender
{
+ [errorMessage setStringValue:@""];
[NSApp beginSheet:newBranchSheet
modalForWindow:[[historyController view] window]
modalDelegate:NULL
@@ -170,20 +171,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];
}