Add staging and unstaging of files

This commit is contained in:
Pieter de Bie
2008-09-24 00:47:41 +02:00
parent 2e7cd5268d
commit 76e176e8b4
4 changed files with 37 additions and 10 deletions
+2 -1
View File
@@ -28,7 +28,8 @@ typedef enum {
@property (assign) BOOL cached;
- (NSImage *)icon;
- (NSString *)changes;
- (void) stageChanges;
- (void) unstageChanges;
- (id) initWithPath:(NSString *)p andRepository:(PBGitRepository *)r;
@end
+10
View File
@@ -47,6 +47,16 @@
return [[NSImage alloc] initByReferencingFile: p];
}
- (void) stageChanges
{
[repository outputInWorkdirForArguments:[NSArray arrayWithObjects:@"add", path, nil]];
self.cached = YES;
}
- (void) unstageChanges
{ [repository outputInWorkdirForArguments:[NSArray arrayWithObjects:@"reset", path, nil]];
self.cached = NO;
}
+ (BOOL)isSelectorExcludedFromWebScript:(SEL)aSelector
{
return NO;
+19 -4
View File
@@ -16,12 +16,13 @@
- (void)awakeFromNib
{
[unstagedFilesController setFilterPredicate:[NSPredicate predicateWithFormat:@"cached == 0"]];
[cachedFilesController setFilterPredicate:[NSPredicate predicateWithFormat:@"cached == 1"]];
[unstagedButtonCell setAction:@selector(cellClicked:)];
[cachedButtonCell setAction:@selector(cellClicked:)];
[self refresh:self];
[unstagedFilesController setFilterPredicate:[NSPredicate predicateWithFormat:@"cached == 0"]];
[cachedFilesController setFilterPredicate:[NSPredicate predicateWithFormat:@"cached == 1"]];
}
- (void) readOtherFiles
@@ -43,6 +44,7 @@
- (void) refresh:(id) sender
{
files = [NSMutableArray array];
[repository outputForCommand:@"update-index"];
[self readUnstagedFiles];
[self readCachedFiles];
[self readOtherFiles];
@@ -87,11 +89,24 @@
if([tableView numberOfSelectedRows] == 1)
{
NSUInteger selectionIndex = [[tableView selectedRowIndexes] firstIndex];
id selectedItem = [[(([tableView tag] == 0) ? unstagedFilesController : cachedFilesController) arrangedObjects] objectAtIndex:selectionIndex];
NSLog(@"%s selectedItem: %@", _cmd, [selectedItem valueForKey:@"path"]);
PBChangedFile *selectedItem = [[(([tableView tag] == 0) ? unstagedFilesController : cachedFilesController) arrangedObjects] objectAtIndex:selectionIndex];
if (selectedItem.cached == NO) {
[selectedItem stageChanges];
}
else {
[selectedItem unstageChanges];
}
[self refreshControllers];
}
}
- (void) refreshControllers
{
[self refresh:self];
}
- (void)tableView:(NSTableView*)tableView willDisplayCell:(id)cell forTableColumn:(NSTableColumn*)tableColumn row:(int)rowIndex
{
[[tableColumn dataCell] setImage:[[[(([tableView tag] == 0) ? unstagedFilesController : cachedFilesController) arrangedObjects] objectAtIndex:rowIndex] icon]];
+6 -5
View File
@@ -2,9 +2,9 @@
<archive type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="7.02">
<data>
<int key="IBDocument.SystemTarget">1050</int>
<string key="IBDocument.SystemVersion">9E17</string>
<string key="IBDocument.SystemVersion">9F33</string>
<string key="IBDocument.InterfaceBuilderVersion">670</string>
<string key="IBDocument.AppKitVersion">949.33</string>
<string key="IBDocument.AppKitVersion">949.34</string>
<string key="IBDocument.HIToolboxVersion">352.00</string>
<object class="NSMutableArray" key="IBDocument.EditedObjectIDs">
<bool key="EncodedWithXMLCoder">YES</bool>
@@ -160,7 +160,7 @@
<object class="NSMutableArray" key="NSTableColumns">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="NSTableColumn" id="746911078">
<double key="NSWidth">1.660000e+02</double>
<double key="NSWidth">1.850000e+02</double>
<double key="NSMinWidth">1.000000e+01</double>
<double key="NSMaxWidth">3.402823e+38</double>
<object class="NSTableHeaderCell" key="NSHeaderCell">
@@ -751,6 +751,7 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA</bytes>
<int key="NSvFlags">4352</int>
<string key="NSFrameSize">{213, 193}</string>
<reference key="NSSuperview" ref="551030904"/>
<int key="NSTag">1</int>
<bool key="NSEnabled">YES</bool>
<object class="_NSCornerView" key="NSCornerView">
<nil key="NSNextResponder"/>
@@ -760,7 +761,7 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA</bytes>
<object class="NSMutableArray" key="NSTableColumns">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="NSTableColumn" id="79177434">
<double key="NSWidth">1.910000e+02</double>
<double key="NSWidth">2.100000e+02</double>
<double key="NSMinWidth">1.000000e+01</double>
<double key="NSMaxWidth">3.402823e+38</double>
<object class="NSTableHeaderCell" key="NSHeaderCell">
@@ -1404,7 +1405,7 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA</bytes>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilderKit</string>
<string>com.apple.InterfaceBuilderKit</string>
<string>{{41, 123}, {852, 432}}</string>
<string>{{312, 344}, {852, 432}}</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<reference ref="8"/>
<reference ref="8"/>