mirror of
https://github.com/kennethreitz-archive/gitx.git
synced 2026-06-05 23:40:18 +00:00
CommitView: Migrate patch apply stuff to GitIndex
This commit is contained in:
@@ -127,35 +127,5 @@
|
||||
[commitMessageView setString:@""];
|
||||
}
|
||||
|
||||
- (void) stageHunk:(NSString *)hunk reverse:(BOOL)reverse
|
||||
{
|
||||
[self processHunk:hunk stage:TRUE reverse:reverse];
|
||||
}
|
||||
|
||||
- (void)discardHunk:(NSString *)hunk
|
||||
{
|
||||
[self processHunk:hunk stage:FALSE reverse:TRUE];
|
||||
}
|
||||
|
||||
- (void)processHunk:(NSString *)hunk stage:(BOOL)stage reverse:(BOOL)reverse
|
||||
{
|
||||
NSMutableArray *array = [NSMutableArray arrayWithObjects:@"apply", nil];
|
||||
if (stage)
|
||||
[array addObject:@"--cached"];
|
||||
if (reverse)
|
||||
[array addObject:@"--reverse"];
|
||||
|
||||
int ret = 1;
|
||||
NSString *error = [repository outputForArguments:array
|
||||
inputString:hunk
|
||||
retValue:&ret];
|
||||
|
||||
// FIXME: show this error, rather than just logging it
|
||||
if (ret)
|
||||
NSLog(@"Error: %@", error);
|
||||
|
||||
// TODO: We should do this smarter by checking if the file diff is empty, which is faster.
|
||||
[self refresh:self];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@@ -82,10 +82,11 @@
|
||||
[NSNumber numberWithBool:selectedFileIsCached], nil]];
|
||||
}
|
||||
|
||||
- (void) stageHunk:(NSString *)hunk reverse:(BOOL)reverse
|
||||
- (void)stageHunk:(NSString *)hunk reverse:(BOOL)reverse
|
||||
{
|
||||
//[controller stageHunk: hunk reverse:reverse];
|
||||
[controller.index applyPatch:hunk stage:YES reverse:reverse];
|
||||
// FIXME: Don't need a hard refresh
|
||||
|
||||
[self refresh];
|
||||
}
|
||||
|
||||
@@ -101,7 +102,7 @@
|
||||
}
|
||||
|
||||
if (ret == NSAlertDefaultReturn) {
|
||||
// [controller discardHunk:hunk];
|
||||
[controller.index applyPatch:hunk stage:NO reverse:YES];
|
||||
[self refresh];
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user