Skip to content

Commit 3337fbd

Browse files
author
Jan Gassen
committed
Added git_patch_to_buf method
1 parent d3ecf14 commit 3337fbd

File tree

3 files changed

+44
-13
lines changed

3 files changed

+44
-13
lines changed

ObjectiveGit/GTDiffPatch.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,9 @@
5050
/// Returns the raw size of the delta, in bytes.
5151
- (NSUInteger)sizeWithContext:(BOOL)includeContext hunkHeaders:(BOOL)includeHunkHeaders fileHeaders:(BOOL)includeFileHeaders;
5252

53+
/// Returns the raw patch data as buffer.
54+
- (NSData*)toBuffer;
55+
5356
/// Enumerate the hunks contained in the patch.
5457
///
5558
/// This enumeration is synchronous, and will block the calling thread while

ObjectiveGit/GTDiffPatch.m

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,16 @@ - (NSUInteger)sizeWithContext:(BOOL)includeContext hunkHeaders:(BOOL)includeHunk
5959
return git_patch_size(self.git_patch, includeContext, includeHunkHeaders, includeFileHeaders);
6060
}
6161

62+
- (NSData*)toBuffer {
63+
git_buf buf = GIT_BUF_INIT_CONST(0, NULL);
64+
git_patch_to_buf(&buf, self.git_patch);
65+
66+
NSData* buffer = [[NSData alloc] initWithBytes:buf.ptr length:buf.size];
67+
git_buf_free(&buf);
68+
69+
return buffer;
70+
}
71+
6272
#pragma mark Hunks
6373

6474
- (BOOL)enumerateHunksUsingBlock:(void (^)(GTDiffHunk *hunk, BOOL *stop))block {

ObjectiveGitFramework.xcodeproj/project.pbxproj

Lines changed: 31 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -311,6 +311,13 @@
311311
/* End PBXBuildFile section */
312312

313313
/* Begin PBXContainerItemProxy section */
314+
3D6123BD1A6432F6008F831A /* PBXContainerItemProxy */ = {
315+
isa = PBXContainerItemProxy;
316+
containerPortal = 0867D690FE84028FC02AAC07 /* Project object */;
317+
proxyType = 1;
318+
remoteGlobalIDString = D0A330ED16027F1E00A616FA;
319+
remoteInfo = libgit2;
320+
};
314321
6A28265A17C69D6300C6A948 /* PBXContainerItemProxy */ = {
315322
isa = PBXContainerItemProxy;
316323
containerPortal = 0867D690FE84028FC02AAC07 /* Project object */;
@@ -346,13 +353,6 @@
346353
remoteGlobalIDString = D0A330F216027F3600A616FA;
347354
remoteInfo = "libgit2-iOS";
348355
};
349-
D0A330F716027F4900A616FA /* PBXContainerItemProxy */ = {
350-
isa = PBXContainerItemProxy;
351-
containerPortal = 0867D690FE84028FC02AAC07 /* Project object */;
352-
proxyType = 1;
353-
remoteGlobalIDString = D0A330ED16027F1E00A616FA;
354-
remoteInfo = libgit2;
355-
};
356356
/* End PBXContainerItemProxy section */
357357

358358
/* Begin PBXCopyFilesBuildPhase section */
@@ -412,6 +412,7 @@
412412
30DCBA7017B4791A009B0EBD /* NSArray+StringArray.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSArray+StringArray.m"; sourceTree = "<group>"; };
413413
30FDC07D16835A8100654BF0 /* GTDiffLine.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GTDiffLine.h; sourceTree = "<group>"; };
414414
30FDC07E16835A8100654BF0 /* GTDiffLine.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GTDiffLine.m; sourceTree = "<group>"; };
415+
3D6123BB1A643296008F831A /* libgit2.0.21.2.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libgit2.0.21.2.dylib; path = ../../../../../usr/local/Cellar/libgit2/0.21.2/lib/libgit2.0.21.2.dylib; sourceTree = "<group>"; };
415416
4D103ADC1819CFAA0029DB24 /* libiconv.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libiconv.dylib; path = usr/lib/libiconv.dylib; sourceTree = SDKROOT; };
416417
4D12323F178E009E0048F785 /* GTRepositoryCommittingSpec.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GTRepositoryCommittingSpec.m; sourceTree = "<group>"; };
417418
4D1C40D7182C006D00BE2960 /* GTBlobSpec.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GTBlobSpec.m; sourceTree = "<group>"; };
@@ -620,6 +621,7 @@
620621
0867D691FE84028FC02AAC07 /* ObjectiveGitFramework */ = {
621622
isa = PBXGroup;
622623
children = (
624+
3D6123BB1A643296008F831A /* libgit2.0.21.2.dylib */,
623625
BDD8AB01130F01AB00CB5D40 /* README.md */,
624626
887B948D1A3A38130070D41D /* ObjectiveGit.modulemap */,
625627
BDE4C05E130EFE2C00851650 /* ObjectiveGit */,
@@ -1094,7 +1096,7 @@
10941096
buildRules = (
10951097
);
10961098
dependencies = (
1097-
D0A330F816027F4900A616FA /* PBXTargetDependency */,
1099+
3D6123BE1A6432F6008F831A /* PBXTargetDependency */,
10981100
);
10991101
name = "ObjectiveGit-Mac";
11001102
productInstallPath = "$(HOME)/Library/Frameworks";
@@ -1396,6 +1398,11 @@
13961398
/* End PBXSourcesBuildPhase section */
13971399

13981400
/* Begin PBXTargetDependency section */
1401+
3D6123BE1A6432F6008F831A /* PBXTargetDependency */ = {
1402+
isa = PBXTargetDependency;
1403+
target = D0A330ED16027F1E00A616FA /* libgit2 */;
1404+
targetProxy = 3D6123BD1A6432F6008F831A /* PBXContainerItemProxy */;
1405+
};
13991406
6A28265B17C69D6300C6A948 /* PBXTargetDependency */ = {
14001407
isa = PBXTargetDependency;
14011408
target = 6A28265217C69CB400C6A948 /* OpenSSL-iOS */;
@@ -1421,11 +1428,6 @@
14211428
target = D0A330F216027F3600A616FA /* libgit2-iOS */;
14221429
targetProxy = D019779619F8335100F523DA /* PBXContainerItemProxy */;
14231430
};
1424-
D0A330F816027F4900A616FA /* PBXTargetDependency */ = {
1425-
isa = PBXTargetDependency;
1426-
target = D0A330ED16027F1E00A616FA /* libgit2 */;
1427-
targetProxy = D0A330F716027F4900A616FA /* PBXContainerItemProxy */;
1428-
};
14291431
/* End PBXTargetDependency section */
14301432

14311433
/* Begin PBXVariantGroup section */
@@ -1449,6 +1451,10 @@
14491451
DYLIB_CURRENT_VERSION = 1;
14501452
FRAMEWORK_VERSION = A;
14511453
INFOPLIST_FILE = Info.plist;
1454+
LIBRARY_SEARCH_PATHS = (
1455+
"$(inherited)",
1456+
/usr/local/Cellar/libgit2/0.21.2/lib,
1457+
);
14521458
MODULEMAP_FILE = ObjectiveGit.modulemap;
14531459
OTHER_LDFLAGS = (
14541460
"-lgit2",
@@ -1472,6 +1478,10 @@
14721478
DYLIB_CURRENT_VERSION = 1;
14731479
FRAMEWORK_VERSION = A;
14741480
INFOPLIST_FILE = Info.plist;
1481+
LIBRARY_SEARCH_PATHS = (
1482+
"$(inherited)",
1483+
/usr/local/Cellar/libgit2/0.21.2/lib,
1484+
);
14751485
MODULEMAP_FILE = ObjectiveGit.modulemap;
14761486
OTHER_LDFLAGS = (
14771487
"-lgit2",
@@ -1656,6 +1666,10 @@
16561666
DYLIB_CURRENT_VERSION = 1;
16571667
FRAMEWORK_VERSION = A;
16581668
INFOPLIST_FILE = Info.plist;
1669+
LIBRARY_SEARCH_PATHS = (
1670+
"$(inherited)",
1671+
/usr/local/Cellar/libgit2/0.21.2/lib,
1672+
);
16591673
MODULEMAP_FILE = ObjectiveGit.modulemap;
16601674
OTHER_LDFLAGS = (
16611675
"-lgit2",
@@ -1873,6 +1887,10 @@
18731887
DYLIB_CURRENT_VERSION = 1;
18741888
FRAMEWORK_VERSION = A;
18751889
INFOPLIST_FILE = Info.plist;
1890+
LIBRARY_SEARCH_PATHS = (
1891+
"$(inherited)",
1892+
/usr/local/Cellar/libgit2/0.21.2/lib,
1893+
);
18761894
MODULEMAP_FILE = ObjectiveGit.modulemap;
18771895
OTHER_LDFLAGS = (
18781896
"-lgit2",

0 commit comments

Comments
 (0)