Merge branch 'stable'

* stable:
  GitRevList -- Try to read the encoding of the commit message
  GitRevList: fix crash when loading 0 commits
  Tickets #151 and #155: check for illegal branch names before creating.
This commit is contained in:
Pieter de Bie
2009-05-28 15:12:16 +01:00
4 changed files with 84 additions and 16 deletions
+53 -5
View File
@@ -8,7 +8,7 @@
<string key="IBDocument.HIToolboxVersion">353.00</string>
<object class="NSMutableArray" key="IBDocument.EditedObjectIDs">
<bool key="EncodedWithXMLCoder">YES</bool>
<integer value="236"/>
<integer value="237"/>
<integer value="27"/>
</object>
<object class="NSArray" key="IBDocument.PluginDependencies">
@@ -1119,6 +1119,25 @@
<int key="NSPeriodicInterval">25</int>
</object>
</object>
<object class="NSTextField" id="27300806">
<reference key="NSNextResponder" ref="562356688"/>
<int key="NSvFlags">268</int>
<string key="NSFrame">{{251, 62}, {85, 17}}</string>
<reference key="NSSuperview" ref="562356688"/>
<bool key="NSEnabled">YES</bool>
<object class="NSTextFieldCell" key="NSCell" id="217429948">
<int key="NSCellFlags">68288064</int>
<int key="NSCellFlags2">272630784</int>
<string key="NSContents">Invalid name</string>
<reference key="NSSupport" ref="924107556"/>
<reference key="NSControlView" ref="27300806"/>
<reference key="NSBackgroundColor" ref="457244339"/>
<object class="NSColor" key="NSTextColor">
<int key="NSColorSpace">1</int>
<bytes key="NSRGB">MSAwIDAAA</bytes>
</object>
</object>
</object>
</object>
<string key="NSFrameSize">{346, 133}</string>
<reference key="NSSuperview"/>
@@ -2077,6 +2096,14 @@
</object>
<int key="connectionID">271</int>
</object>
<object class="IBConnectionRecord">
<object class="IBOutletConnection" key="connection">
<string key="label">errorMessage</string>
<reference key="source" ref="892732705"/>
<reference key="destination" ref="27300806"/>
</object>
<int key="connectionID">274</int>
</object>
</object>
<object class="IBMutableOrderedSet" key="objectRecords">
<object class="NSArray" key="orderedObjects">
@@ -2391,6 +2418,7 @@
<reference ref="383988892"/>
<reference ref="60467344"/>
<reference ref="657747237"/>
<reference ref="27300806"/>
</object>
<reference key="parent" ref="296392339"/>
</object>
@@ -2692,6 +2720,20 @@
<reference key="object" ref="496187369"/>
<reference key="parent" ref="604026377"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">272</int>
<reference key="object" ref="27300806"/>
<object class="NSMutableArray" key="children">
<bool key="EncodedWithXMLCoder">YES</bool>
<reference ref="217429948"/>
</object>
<reference key="parent" ref="562356688"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">273</int>
<reference key="object" ref="217429948"/>
<reference key="parent" ref="27300806"/>
</object>
</object>
</object>
<object class="NSMutableDictionary" key="flattenedProperties">
@@ -2769,6 +2811,8 @@
<string>27.IBViewIntegration.shadowOffsetHeight</string>
<string>27.IBViewIntegration.shadowOffsetWidth</string>
<string>27.ImportedFromIB2</string>
<string>272.IBPluginDependency</string>
<string>273.IBPluginDependency</string>
<string>28.IBPluginDependency</string>
<string>28.IBShouldRemoveOnLegacySave</string>
<string>29.IBPluginDependency</string>
@@ -2861,8 +2905,8 @@
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>{{521, 623}, {346, 133}}</string>
<string>{{521, 623}, {346, 133}}</string>
<string>{{504, 581}, {346, 133}}</string>
<string>{{504, 581}, {346, 133}}</string>
<reference ref="8"/>
<string>{3.40282e+38, 3.40282e+38}</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
@@ -2898,6 +2942,8 @@
<reference ref="8"/>
<reference ref="9"/>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<reference ref="9"/>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<reference ref="9"/>
@@ -2931,7 +2977,7 @@
</object>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>{{312, 79}, {852, 432}}</string>
<string>{{189, 79}, {852, 432}}</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
@@ -2966,7 +3012,7 @@
</object>
</object>
<nil key="sourceID"/>
<int key="maxID">271</int>
<int key="maxID">274</int>
</object>
<object class="IBClassDescriber" key="IBDocument.Classes">
<object class="NSMutableArray" key="referencedPartialClassDescriptions">
@@ -3120,6 +3166,7 @@
<string>branchPopUp</string>
<string>commitController</string>
<string>commitList</string>
<string>errorMessage</string>
<string>historyController</string>
<string>newBranchName</string>
<string>newBranchSheet</string>
@@ -3129,6 +3176,7 @@
<string>NSPopUpButton</string>
<string>NSArrayController</string>
<string>PBCommitList</string>
<string>NSTextField</string>
<string>PBGitHistoryController</string>
<string>NSTextField</string>
<string>NSWindow</string>
+15 -5
View File
@@ -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)
+1
View File
@@ -20,6 +20,7 @@
IBOutlet NSWindow *newBranchSheet;
IBOutlet NSTextField *newBranchName;
IBOutlet NSTextField *errorMessage;
IBOutlet NSPopUpButton *branchPopUp;
}
+15 -6
View File
@@ -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];
}