Permalink
Browse files

Add diffstat API and simple implementation.

  • Loading branch information...
1 parent 7d45561 commit 98a22de4202f7bcd80d31a88128c92aea8b18e44 Danny Greg committed Jan 31, 2013
Showing with 24 additions and 0 deletions.
  1. +15 −0 Classes/GTDiffDelta.h
  2. +9 −0 Classes/GTDiffDelta.m
View
@@ -67,6 +67,21 @@ typedef enum : git_delta_t {
// The number of hunks represented by this delta.
@property (nonatomic, readonly) NSUInteger hunkCount;
+// The number of added lines in this delta.
+//
+// Undefined if this delta is binary.
+@property (nonatomic, readonly) NSUInteger addedLinesCount;
+
+// The number of deleted lines in this delta.
+//
+// Undefined if this delta is binary.
+@property (nonatomic, readonly) NSUInteger deletedLinesCount;
+
+// The number of context lines in this delta.
+//
+// Undefined if this delta is binary.
+@property (nonatomic, readonly) NSUInteger contextLinesCount;
+
// Designated initialiser.
- (instancetype)initWithGitPatch:(git_diff_patch *)patch;
View
@@ -21,6 +21,15 @@ - (instancetype)initWithGitPatch:(git_diff_patch *)patch {
_git_diff_patch = patch;
+ size_t adds = 0;
+ size_t deletes = 0;
+ size_t contexts = 0;
+ git_diff_patch_line_stats(&contexts, &adds, &deletes, patch);
+
+ _addedLinesCount = adds;
+ _deletedLinesCount = deletes;
+ _contextLinesCount = contexts;
+
return self;
}

0 comments on commit 98a22de

Please sign in to comment.