Permalink
Browse files

Reimplement the enumeration in GTDiffHunk.

  • Loading branch information...
Danny Greg
Danny Greg committed Dec 20, 2012
1 parent 02c8507 commit 1767cd8d7927d7ac702de5e910342c0bb367729c
Showing with 6 additions and 3 deletions.
  1. +2 −1 Classes/GTDiffHunk.h
  2. +4 −2 Classes/GTDiffHunk.m
View
@@ -9,6 +9,7 @@
#import "git2.h"
@class GTDiffDelta;
+@class GTDiffLine;
// A class representing a hunk within a diff delta.
@interface GTDiffHunk : NSObject
@@ -31,6 +32,6 @@
//
// block - A block to execute on each line. Setting `stop` to `NO` will
// immediately stop the enumeration and return from the method.
-- (void)enumerateLinesInHunkUsingBlock:(void (^)(NSString *lineContent, NSUInteger oldLineNumber, NSUInteger newLineNumber, GTDiffHunkLineOrigin lineOrigin, BOOL *stop))block;
+- (void)enumerateLinesInHunkUsingBlock:(void (^)(GTDiffLine *line, BOOL *stop))block;
@end
View
@@ -9,6 +9,7 @@
#import "GTDiffHunk.h"
#import "GTDiffDelta.h"
+#import "GTDiffLine.h"
@interface GTDiffHunk ()
@@ -38,7 +39,7 @@ - (instancetype)initWithDelta:(GTDiffDelta *)delta hunkIndex:(NSUInteger)hunkInd
return self;
}
-- (void)enumerateLinesInHunkUsingBlock:(void (^)(NSString *lineContent, NSUInteger oldLineNumber, NSUInteger newLineNumber, GTDiffHunkLineOrigin lineOrigin, BOOL *stop))block {
+- (void)enumerateLinesInHunkUsingBlock:(void (^)(GTDiffLine *line, BOOL *stop))block {
NSParameterAssert(block != nil);
for (NSUInteger idx = 0; idx < self.lineCount; idx ++) {
@@ -51,8 +52,9 @@ - (void)enumerateLinesInHunkUsingBlock:(void (^)(NSString *lineContent, NSUInteg
if (result != GIT_OK) continue;
NSString *lineString = [[[NSString alloc] initWithBytes:content length:contentLength encoding:NSUTF8StringEncoding] stringByTrimmingCharactersInSet:NSCharacterSet.newlineCharacterSet];
+ GTDiffLine *line = [[GTDiffLine alloc] initWithContent:lineString oldLineNumber:(NSUInteger)oldLineNumber newLineNumber:(NSUInteger)newLineNumber origin:lineOrigin];
BOOL stop = NO;
- block(lineString, (NSUInteger)oldLineNumber, (NSUInteger)newLineNumber, lineOrigin, &stop);
+ block(line, &stop);
if (stop) return;
}
}

0 comments on commit 1767cd8

Please sign in to comment.