Permalink
Browse files

Add a diffline and implement GTDiffLine.

  • Loading branch information...
1 parent 4ae53d2 commit 0cddf1c0851ec33ef28e5a30981c50a918cd45c8 Danny Greg committed Dec 20, 2012
Showing with 82 additions and 19 deletions.
  1. +0 −11 Classes/GTDiffHunk.h
  2. +30 −0 Classes/GTDiffLine.h
  3. +24 −0 Classes/GTDiffLine.m
  4. +28 −8 ObjectiveGitFramework.xcodeproj/project.pbxproj
View
@@ -10,17 +10,6 @@
@class GTDiffDelta;
-// A character representing the origin of a given line.
-//
-// See diff.h for individual documentation.
-typedef enum : git_diff_line_t {
- GTDiffHunkLineOriginContext = GIT_DIFF_LINE_CONTEXT,
- GTDiffHunkLineOriginAddition = GIT_DIFF_LINE_ADDITION,
- GTDiffHunkLineOriginDeletion = GIT_DIFF_LINE_DELETION,
- GTDiffHunkLineOriginAddEOFNewLine = GIT_DIFF_LINE_ADD_EOFNL,
- GTDiffHunkLineOriginDeleteEOFNewLine = GIT_DIFF_LINE_DEL_EOFNL,
-} GTDiffHunkLineOrigin;
-
// A class representing a hunk within a diff delta.
@interface GTDiffHunk : NSObject
View
@@ -0,0 +1,30 @@
+//
+// GTDiffLine.h
+// ObjectiveGitFramework
+//
+// Created by Danny Greg on 20/12/2012.
+// Copyright (c) 2012 GitHub, Inc. All rights reserved.
+//
+
+#import "git2.h"
+
+// A character representing the origin of a given line.
+//
+// See diff.h for individual documentation.
+typedef enum : git_diff_line_t {
+ GTDiffLineOriginContext = GIT_DIFF_LINE_CONTEXT,
+ GTDiffLineOriginAddition = GIT_DIFF_LINE_ADDITION,
+ GTDiffLineOriginDeletion = GIT_DIFF_LINE_DELETION,
+ GTDiffLineOriginAddEOFNewLine = GIT_DIFF_LINE_ADD_EOFNL,
+ GTDiffLineOriginDeleteEOFNewLine = GIT_DIFF_LINE_DEL_EOFNL,
+} GTDiffLineOrigin;
+
+@interface GTDiffLine : NSObject
+
+@property (nonatomic, readonly) NSString *content;
+@property (nonatomic, readonly) NSUInteger oldLineNumber;
+@property (nonatomic, readonly) GTDiffLineOrigin origin;
+
+- (instancetype)initWithContent:(NSString *)content oldLineNumber:(NSUInteger)oldLineNumber origin:(GTDiffLineOrigin)origin;
+
+@end
View
@@ -0,0 +1,24 @@
+//
+// GTDiffLine.m
+// ObjectiveGitFramework
+//
+// Created by Danny Greg on 20/12/2012.
+// Copyright (c) 2012 GitHub, Inc. All rights reserved.
+//
+
+#import "GTDiffLine.h"
+
+@implementation GTDiffLine
+
+- (instancetype)initWithContent:(NSString *)content oldLineNumber:(NSUInteger)oldLineNumber origin:(GTDiffLineOrigin)origin {
+ self = [super init];
+ if (self == nil) return nil;
+
+ _content = [content copy];
+ _oldLineNumber = oldLineNumber;
+ _origin = origin;
+
+ return self;
+}
+
+@end
@@ -79,6 +79,10 @@
30A3D6551667F11C00C49A39 /* GTDiff.h in Headers */ = {isa = PBXBuildFile; fileRef = 30A3D6521667F11C00C49A39 /* GTDiff.h */; settings = {ATTRIBUTES = (Public, ); }; };
30A3D6561667F11C00C49A39 /* GTDiff.m in Sources */ = {isa = PBXBuildFile; fileRef = 30A3D6531667F11C00C49A39 /* GTDiff.m */; };
30A3D6571667F11C00C49A39 /* GTDiff.m in Sources */ = {isa = PBXBuildFile; fileRef = 30A3D6531667F11C00C49A39 /* GTDiff.m */; };
+ 30FDC07F16835A8100654BF0 /* GTDiffLine.h in Headers */ = {isa = PBXBuildFile; fileRef = 30FDC07D16835A8100654BF0 /* GTDiffLine.h */; };
+ 30FDC08016835A8100654BF0 /* GTDiffLine.h in Headers */ = {isa = PBXBuildFile; fileRef = 30FDC07D16835A8100654BF0 /* GTDiffLine.h */; };
+ 30FDC08116835A8100654BF0 /* GTDiffLine.m in Sources */ = {isa = PBXBuildFile; fileRef = 30FDC07E16835A8100654BF0 /* GTDiffLine.m */; };
+ 30FDC08216835A8100654BF0 /* GTDiffLine.m in Sources */ = {isa = PBXBuildFile; fileRef = 30FDC07E16835A8100654BF0 /* GTDiffLine.m */; };
3E0A23E5159E0FDB00A6068F /* GTObjectDatabase.h in Headers */ = {isa = PBXBuildFile; fileRef = 55C8054C13861F34004DCB0F /* GTObjectDatabase.h */; settings = {ATTRIBUTES = (Public, ); }; };
55C8054F13861FE7004DCB0F /* GTObjectDatabase.m in Sources */ = {isa = PBXBuildFile; fileRef = 55C8054D13861F34004DCB0F /* GTObjectDatabase.m */; };
55C8055013861FE7004DCB0F /* GTObjectDatabase.m in Sources */ = {isa = PBXBuildFile; fileRef = 55C8054D13861F34004DCB0F /* GTObjectDatabase.m */; };
@@ -284,6 +288,8 @@
30865A90167F503400B1AB6E /* GTDiffSpec.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GTDiffSpec.m; sourceTree = "<group>"; };
30A3D6521667F11C00C49A39 /* GTDiff.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GTDiff.h; sourceTree = "<group>"; };
30A3D6531667F11C00C49A39 /* GTDiff.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GTDiff.m; sourceTree = "<group>"; };
+ 30FDC07D16835A8100654BF0 /* GTDiffLine.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GTDiffLine.h; sourceTree = "<group>"; };
+ 30FDC07E16835A8100654BF0 /* GTDiffLine.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GTDiffLine.m; sourceTree = "<group>"; };
32DBCF5E0370ADEE00C91783 /* ObjectiveGitFramework_Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ObjectiveGitFramework_Prefix.pch; sourceTree = "<group>"; };
55C8054C13861F34004DCB0F /* GTObjectDatabase.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GTObjectDatabase.h; sourceTree = "<group>"; };
55C8054D13861F34004DCB0F /* GTObjectDatabase.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; lineEnding = 0; path = GTObjectDatabase.m; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.objc; };
@@ -469,6 +475,23 @@
name = "Other Frameworks";
sourceTree = "<group>";
};
+ 30FDC07C16835A6F00654BF0 /* Diff */ = {
+ isa = PBXGroup;
+ children = (
+ 30A3D6521667F11C00C49A39 /* GTDiff.h */,
+ 30A3D6531667F11C00C49A39 /* GTDiff.m */,
+ 3011D8691668E48500CE3409 /* GTDiffFile.h */,
+ 3011D86A1668E48500CE3409 /* GTDiffFile.m */,
+ 3011D86F1668E78500CE3409 /* GTDiffHunk.h */,
+ 3011D8701668E78500CE3409 /* GTDiffHunk.m */,
+ 3011D8751668F29600CE3409 /* GTDiffDelta.h */,
+ 3011D8761668F29600CE3409 /* GTDiffDelta.m */,
+ 30FDC07D16835A8100654BF0 /* GTDiffLine.h */,
+ 30FDC07E16835A8100654BF0 /* GTDiffLine.m */,
+ );
+ name = Diff;
+ sourceTree = "<group>";
+ };
32C88DFF0371C24200C91783 /* Other Sources */ = {
isa = PBXGroup;
children = (
@@ -607,14 +630,7 @@
88EB7E4C14AEBA600046FEA4 /* GTConfiguration.m */,
883CD6A91600EBC600F57354 /* GTRemote.h */,
883CD6AA1600EBC600F57354 /* GTRemote.m */,
- 30A3D6521667F11C00C49A39 /* GTDiff.h */,
- 30A3D6531667F11C00C49A39 /* GTDiff.m */,
- 3011D8691668E48500CE3409 /* GTDiffFile.h */,
- 3011D86A1668E48500CE3409 /* GTDiffFile.m */,
- 3011D86F1668E78500CE3409 /* GTDiffHunk.h */,
- 3011D8701668E78500CE3409 /* GTDiffHunk.m */,
- 3011D8751668F29600CE3409 /* GTDiffDelta.h */,
- 3011D8761668F29600CE3409 /* GTDiffDelta.m */,
+ 30FDC07C16835A6F00654BF0 /* Diff */,
);
path = Classes;
sourceTree = "<group>";
@@ -663,6 +679,7 @@
3011D86C1668E48500CE3409 /* GTDiffFile.h in Headers */,
3011D8721668E78500CE3409 /* GTDiffHunk.h in Headers */,
3011D8781668F29600CE3409 /* GTDiffDelta.h in Headers */,
+ 30FDC08016835A8100654BF0 /* GTDiffLine.h in Headers */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -697,6 +714,7 @@
3011D8711668E78500CE3409 /* GTDiffHunk.h in Headers */,
3011D8771668F29600CE3409 /* GTDiffDelta.h in Headers */,
8849C6A214AD81FF003890AF /* GTRepository+Private.h in Headers */,
+ 30FDC07F16835A8100654BF0 /* GTDiffLine.h in Headers */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -941,6 +959,7 @@
3011D86E1668E48500CE3409 /* GTDiffFile.m in Sources */,
3011D8741668E78500CE3409 /* GTDiffHunk.m in Sources */,
3011D87A1668F29600CE3409 /* GTDiffDelta.m in Sources */,
+ 30FDC08216835A8100654BF0 /* GTDiffLine.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -995,6 +1014,7 @@
3011D86D1668E48500CE3409 /* GTDiffFile.m in Sources */,
3011D8731668E78500CE3409 /* GTDiffHunk.m in Sources */,
3011D8791668F29600CE3409 /* GTDiffDelta.m in Sources */,
+ 30FDC08116835A8100654BF0 /* GTDiffLine.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};

0 comments on commit 0cddf1c

Please sign in to comment.