Permalink
Browse files

updated everything

  • Loading branch information...
1 parent d1f3844 commit 13b8199a5c76eadd508bfb9174ac298bc69f0c4d @schacon committed Dec 13, 2009
Showing with 4,934 additions and 2,081 deletions.
  1. BIN .DS_Store
  2. 0 { → Classes}/AppController.h
  3. 0 { → Classes}/AppController.m
  4. 0 {Networking → Classes}/BrowserViewController.h
  5. 0 {Networking → Classes}/BrowserViewController.m
  6. 0 { → Classes}/CommitDetailViewController.h
  7. 0 { → Classes}/CommitDetailViewController.m
  8. 0 { → Classes}/CommitsViewController.h
  9. 0 { → Classes}/CommitsViewController.m
  10. 0 { → Classes}/ProjectController.h
  11. 0 { → Classes}/ProjectController.m
  12. 0 { → Classes}/ProjectDetailViewController.h
  13. 0 { → Classes}/ProjectDetailViewController.m
  14. 0 { → Classes}/ProjectViewController.h
  15. 0 { → Classes}/ProjectViewController.m
  16. 0 { → Classes}/ServerViewController.h
  17. 0 { → Classes}/ServerViewController.m
  18. 0 { → CocoaGit/Core}/GITBlob.h
  19. +2 −3 { → CocoaGit/Core}/GITBlob.m
  20. +6 −3 { → CocoaGit/Core}/GITCommit.h
  21. +302 −0 CocoaGit/Core/GITCommit.m
  22. +25 −0 CocoaGit/Core/GITObject+Parsing.h
  23. +82 −0 CocoaGit/Core/GITObject+Parsing.m
  24. +7 −28 { → CocoaGit/Core}/GITObject.h
  25. +24 −35 { → CocoaGit/Core}/GITObject.m
  26. 0 { → CocoaGit/Core}/GITTag.h
  27. +6 −23 { → CocoaGit/Core}/GITTag.m
  28. 0 { → CocoaGit/Core}/GITTree.h
  29. +5 −22 { → CocoaGit/Core}/GITTree.m
  30. 0 { → CocoaGit/Core}/GITTreeEntry.h
  31. +13 −26 { → CocoaGit/Core}/GITTreeEntry.m
  32. +18 −2 { → CocoaGit/Extra}/GITActor.h
  33. +87 −0 CocoaGit/Extra/GITActor.m
  34. +34 −0 CocoaGit/Extra/GITDateTime.h
  35. +85 −0 CocoaGit/Extra/GITDateTime.m
  36. +1 −1 { → CocoaGit/Extra}/GITErrors.h
  37. +1 −0 { → CocoaGit/Extra}/GITErrors.m
  38. +1 −0 { → CocoaGit/Extra}/GITUtilityBelt.h
  39. +47 −28 { → CocoaGit/Extra}/GITUtilityBelt.m
  40. +24 −22 { → CocoaGit}/GITRepo.h
  41. +353 −0 CocoaGit/GITRepo.m
  42. 0 { → CocoaGit}/Git.h
  43. +29 −0 CocoaGit/Graph/GITCommitEnumerator.h
  44. +122 −0 CocoaGit/Graph/GITCommitEnumerator.m
  45. +36 −0 CocoaGit/Graph/GITGraph.h
  46. +231 −0 CocoaGit/Graph/GITGraph.m
  47. +51 −0 CocoaGit/Graph/GITNode.h
  48. +128 −0 CocoaGit/Graph/GITNode.m
  49. +16 −0 CocoaGit/Graph/GITRepo+Enumerators.h
  50. +22 −0 CocoaGit/Graph/GITRepo+Enumerators.m
  51. 0 { → CocoaGit/Pack}/GITPackFile.h
  52. 0 { → CocoaGit/Pack}/GITPackFile.m
  53. 0 { → CocoaGit/Pack}/GITPackFileVersion2.h
  54. +34 −20 { → CocoaGit/Pack}/GITPackFileVersion2.m
  55. +35 −1 { → CocoaGit/Pack}/GITPackIndex.h
  56. +40 −0 { → CocoaGit/Pack}/GITPackIndex.m
  57. +2 −1 { → CocoaGit/Pack}/GITPackIndexVersion1.h
  58. +104 −28 { → CocoaGit/Pack}/GITPackIndexVersion1.m
  59. +0 −1 { → CocoaGit/Pack}/GITPackIndexVersion2.h
  60. +114 −47 { → CocoaGit/Pack}/GITPackIndexVersion2.m
  61. +5 −10 { → CocoaGit/Pack}/GITPackReverseIndex.h
  62. +162 −0 CocoaGit/Pack/GITPackReverseIndex.m
  63. 0 { → CocoaGit/Pack}/GITPlaceholderPackFile.h
  64. +1 −1 { → CocoaGit/Pack}/GITPlaceholderPackFile.m
  65. 0 { → CocoaGit/Pack}/GITPlaceholderPackIndex.h
  66. +2 −2 { → CocoaGit/Pack}/GITPlaceholderPackIndex.m
  67. 0 { → CocoaGit/Refs}/GITBranch.h
  68. 0 { → CocoaGit/Refs}/GITBranch.m
  69. +41 −0 CocoaGit/Refs/GITRef.h
  70. +168 −0 CocoaGit/Refs/GITRef.m
  71. 0 { → CocoaGit/Store}/GITCombinedStore.h
  72. +5 −0 { → CocoaGit/Store}/GITCombinedStore.m
  73. 0 { → CocoaGit/Store}/GITFileStore.h
  74. +38 −14 { → CocoaGit/Store}/GITFileStore.m
  75. +20 −0 { → CocoaGit/Store}/GITObjectStore.h
  76. +13 −0 { → CocoaGit/Store}/GITObjectStore.m
  77. 0 { → CocoaGit/Store}/GITPackStore.h
  78. +14 −14 { → CocoaGit/Store}/GITPackStore.m
  79. +50 −0 CocoaGit/Store/GITRefStore.h
  80. +291 −0 CocoaGit/Store/GITRefStore.m
  81. +14 −0 CocoaGit/Util/NSCharacterSet+StringComparison.h
  82. +19 −0 CocoaGit/Util/NSCharacterSet+StringComparison.m
  83. 0 { → CocoaGit/Util}/NSData+Compression.h
  84. 0 { → CocoaGit/Util}/NSData+Compression.m
  85. 0 { → CocoaGit/Util}/NSData+Hashing.h
  86. 0 { → CocoaGit/Util}/NSData+Hashing.m
  87. 0 { → CocoaGit/Util}/NSData+HexDump.h
  88. 0 { → CocoaGit/Util}/NSData+HexDump.m
  89. 0 { → CocoaGit/Util}/NSData+Patching.h
  90. 0 { → CocoaGit/Util}/NSData+Patching.m
  91. 0 { → CocoaGit/Util}/NSData+Searching.h
  92. 0 { → CocoaGit/Util}/NSData+Searching.m
  93. 0 { → CocoaGit/Util}/NSError-OBExtensions.h
  94. 0 { → CocoaGit/Util}/NSError-OBExtensions.m
  95. 0 { → CocoaGit/Util}/NSFileManager+DirHelper.h
  96. 0 { → CocoaGit/Util}/NSFileManager+DirHelper.m
  97. 0 { → CocoaGit/Util}/NSTimeZone+Offset.h
  98. 0 { → CocoaGit/Util}/NSTimeZone+Offset.m
  99. 0 { → CocoaGit/Util}/assertions.h
  100. 0 { → CocoaGit/Util}/assertions.m
  101. +67 −0 Controllers/AppController.h
  102. +117 −0 Controllers/AppController.m
  103. +96 −0 Controllers/BrowserViewController.h
  104. +404 −0 Controllers/BrowserViewController.m
  105. +21 −0 Controllers/CommitDetailViewController.h
  106. +254 −0 Controllers/CommitDetailViewController.m
  107. +24 −0 Controllers/CommitsViewController.h
  108. +230 −0 Controllers/CommitsViewController.m
  109. +16 −0 Controllers/ProjectController.h
  110. +52 −0 Controllers/ProjectController.m
  111. +15 −0 Controllers/ProjectDetailViewController.h
  112. +117 −0 Controllers/ProjectDetailViewController.m
  113. +16 −0 Controllers/ProjectViewController.h
  114. +111 −0 Controllers/ProjectViewController.m
  115. +20 −0 Controllers/ServerViewController.h
  116. +81 −0 Controllers/ServerViewController.m
  117. +0 −58 GITActor.m
  118. +0 −255 GITCommit.m
  119. +0 −23 GITDateTime.h
  120. +0 −55 GITDateTime.m
  121. +0 −205 GITPackReverseIndex.m
  122. +0 −30 GITRef.h
  123. +0 −79 GITRef.m
  124. +0 −445 GITRepo.m
  125. +0 −15 Git/NSDataCompression.h
  126. +0 −80 Git/NSDataCompression.m
  127. +0 −13 GitTest.h
  128. +0 −14 GitTest.m
  129. +0 −27 Picker.h
  130. +0 −117 Picker.m
  131. BIN { → assets}/Default.png
  132. BIN { → assets}/bg.png
  133. BIN { → assets}/icon.png
  134. BIN { → assets}/octocat.png
  135. BIN { → assets}/rssicon.png
  136. BIN { → assets}/server.png
  137. BIN { → assets}/servericon.png
  138. BIN { → assets}/test.png
  139. +363 −333 iGitHub.xcodeproj/project.pbxproj
View
BIN .DS_Store
Binary file not shown.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
@@ -8,6 +8,7 @@
#import "GITBlob.h"
#import "GITRepo.h"
+#import "GITErrors.h"
#import "NSData+Searching.h"
@@ -38,7 +39,6 @@ - (GITObjectType)objectType
#pragma mark Deprecated Initialisers
- (id)initWithSha1:(NSString*)newSha1 data:(NSData*)raw repo:(GITRepo*)theRepo
{
- self.cachedRawData = raw;
if (self = [super initType:kGITObjectBlobName sha1:newSha1
size:[raw length] repo:theRepo])
{
@@ -89,5 +89,4 @@ - (NSData*)rawContent
{
return self.data;
}
-
-@end
+@end
@@ -15,7 +15,7 @@ extern NSString * const kGITObjectCommitName;
@interface GITCommit : GITObject
{
NSString * treeSha1;
- NSSet * parents;
+ NSArray * parents;
NSArray * parentShas;
GITTree * tree;
@@ -25,20 +25,23 @@ extern NSString * const kGITObjectCommitName;
GITDateTime * authored;
GITDateTime * committed;
+ unsigned long sortDate;
NSString * message;
+ NSData *cachedRawData;
}
@property(readonly,copy) NSString * treeSha1;
@property(readonly,copy) NSString * parentSha1;
-@property(readwrite,copy) NSArray * parentShas;
+@property(readwrite,retain) NSArray * parentShas;
@property(readonly,copy) GITTree * tree;
@property(readonly,copy) GITCommit * parent;
-@property(readonly,copy) NSSet *parents;
+@property(readonly,copy) NSArray *parents;
@property(readonly,copy) GITActor * author;
@property(readonly,copy) GITActor * committer;
@property(readonly,copy) GITDateTime * authored;
@property(readonly,copy) GITDateTime * committed;
+@property(readonly) unsigned long sortDate;
@property(readonly,copy) NSString * message;
- (BOOL)isFirstCommit;
View
@@ -0,0 +1,302 @@
+//
+// GITCommit.m
+// CocoaGit
+//
+// Created by Geoffrey Garside on 05/08/2008.
+// Copyright 2008 ManicPanda.com. All rights reserved.
+//
+
+#import "GITCommit.h"
+#import "GITRepo.h"
+#import "GITTree.h"
+#import "GITActor.h"
+#import "GITDateTime.h"
+#import "GITErrors.h"
+#import "GITObject+Parsing.h"
+
+NSString * const kGITObjectCommitName = @"commit";
+
+static struct objectRecord recTree = { "tree ", 5, 5, 40, '\n' };
+static struct objectRecord recParent = { "parent ", 7, 7, 40, '\n' };
+static struct objectRecord recRawDate = { "committer ", 10, -17, 10, '\n' };
+static struct objectRecord recAuthor = { "author ", 7, 7, 0, '\n' };
+static struct objectRecord recAuthorInfo = { "author ", 7, 7, 0, '>' };
+static struct objectRecord recCommitterInfo = { "committer ", 10, 10, 0, '>' };
+static struct objectRecord recDate = { " ", 1, 1, 10, ' ' };
+static struct objectRecord recTz = { "", 0, 0, 5, '\n' };
+
+/*! \cond
+ Make properties readwrite so we can use
+ them within the class.
+*/
+@interface GITCommit ()
+@property(readwrite,copy) NSString * treeSha1;
+@property(readwrite,copy) GITTree * tree;
+@property(readwrite,copy) NSArray * parents;
+@property(readwrite,copy) GITActor * author;
+@property(readwrite,copy) GITActor * committer;
+@property(readwrite,copy) GITDateTime * authored;
+@property(readwrite,copy) GITDateTime * committed;
+@property(readwrite,copy) NSString * message;
+@property(readwrite,retain) NSData *cachedRawData;
+- (void) parseCachedRawData;
+@end
+/*! \endcond */
+
+@implementation GITCommit
+@synthesize treeSha1;
+@synthesize parentShas;
+@synthesize tree;
+@synthesize parents;
+@synthesize author;
+@synthesize committer;
+@synthesize authored;
+@synthesize committed;
+@synthesize sortDate;
+@synthesize message;
+@synthesize cachedRawData;
+
++ (NSString*)typeName
+{
+ return kGITObjectCommitName;
+}
+- (GITObjectType)objectType
+{
+ return GITObjectTypeCommit;
+}
+
+#pragma mark -
+#pragma mark Mem overrides
+- (void)dealloc
+{
+ self.tree = nil;
+ self.treeSha1 = nil;
+ self.parents = nil;
+ self.parentShas = nil;
+ self.author = nil;
+ self.committer = nil;
+ self.authored = nil;
+ self.committed = nil;
+ self.cachedRawData = nil;
+ [super dealloc];
+}
+
+- (id)copyWithZone:(NSZone*)zone
+{
+ GITCommit * commit = (GITCommit*)[super copyWithZone:zone];
+ commit.tree = self.tree;
+ commit.treeSha1 = self.treeSha1;
+ commit.parents = self.parents;
+ commit.parentShas = self.parentShas;
+ commit.author = self.author;
+ commit.committer = self.committer;
+ commit.authored = self.authored;
+ commit.committed = self.committed;
+ commit.cachedRawData = self.cachedRawData;
+
+ return commit;
+}
+
+- (BOOL)isFirstCommit
+{
+ return ([self.parents count] > 0);
+}
+
+#pragma mark -
+#pragma mark Object Loaders
+- (GITTree*)tree
+{
+ if (!tree && self.treeSha1)
+ self.tree = [self.repo treeWithSha1:self.treeSha1 error:NULL]; //!< Ideally we'd like to care about the error
+ return tree;
+}
+
+- (NSString *)parentSha1
+{
+ return self.parent.sha1;
+}
+
+- (GITCommit*)parent
+{
+ return [self.parents lastObject];
+}
+
+- (NSArray *)parents
+{
+ if (!parents && self.parentShas) {
+ NSMutableArray *newParents = [[NSMutableArray alloc] initWithCapacity:[self.parentShas count]];
+ for (NSString *parentSha1 in self.parentShas) {
+ GITCommit *parent = [self.repo commitWithSha1:parentSha1 error:NULL];
+ [newParents addObject:parent];
+ }
+ self.parents = newParents;
+ [newParents release];
+ }
+ return parents;
+}
+
+#pragma mark Lazy Loaders
+
+- (GITActor *) author
+{
+ if ( !author ) {
+ [self parseCachedRawData];
+ }
+ return author;
+}
+
+- (GITDateTime *) authored
+{
+ if ( !authored ) {
+ [self parseCachedRawData];
+ }
+ return authored;
+}
+
+- (GITActor *) committer
+{
+ if ( !committer ) {
+ [self parseCachedRawData];
+ }
+ return committer;
+}
+
+- (GITDateTime *) committed
+{
+ if ( !committed ) {
+ [self parseCachedRawData];
+ }
+ return committed;
+}
+
+- (NSString *) message
+{
+ if ( !message ) {
+ [self parseCachedRawData];
+ }
+ return message;
+}
+
+#pragma mark -
+#pragma mark Data Parser
+
+- (BOOL)parseRawData:(NSData*)raw error:(NSError**)error
+{
+ const char *rawString = [raw bytes];
+ const char *start = rawString;
+ NSString *errorDescription;
+ NSMutableArray *commitParents = [NSMutableArray new];
+
+ NSString *treeString = [self createStringWithObjectRecord:recTree bytes:&rawString];
+ if ( !treeString ) {
+ errorDescription = NSLocalizedString(@"Failed to parse tree reference for commit", @"GITErrorObjectParsingFailed (GITCommit:tree)");
+ GITError(error, GITErrorObjectParsingFailed, errorDescription);
+ return NO;
+ }
+ [self setTreeSha1:treeString];
+ [treeString release];
+
+ // parents
+ NSString *parentString;
+ while ( nil != (parentString = [self createStringWithObjectRecord:recParent bytes:&rawString]) ) {
+ if ( !parentString ) {
+ errorDescription = NSLocalizedString(@"Failed to parse parent reference for commit", @"GITErrorObjectParsingFailed (GITCommit:parent)");
+ GITError(error, GITErrorObjectParsingFailed, errorDescription);
+ [commitParents release];
+ return NO;
+ }
+ [commitParents addObject:parentString];
+ [parentString release];
+ }
+
+ [self setParentShas:commitParents];
+ [commitParents release];
+
+ // use this pointer to save the raw data for lazy parsing later
+ const char *buf = rawString;
+ NSUInteger bufLen = [raw length] - (buf-start);
+ NSData *cachedData = [[NSData alloc] initWithBytes:buf length:bufLen];
+ [self setCachedRawData:cachedData];
+ [cachedData release];
+
+ parseObjectRecord(&rawString, recAuthor, NULL, NULL);
+ const char *rawDate;
+ if ( !parseObjectRecord(&rawString, recRawDate, &rawDate, NULL) ) {
+ errorDescription = NSLocalizedString(@"Failed to parse committer date", @"GITErrorObjectParsingFailed (GITCommit:committer)");
+ GITError(error, GITErrorObjectParsingFailed, errorDescription);
+ return NO;
+ }
+ sortDate = (unsigned long)strtoul(rawDate, NULL, recRawDate.matchLen);
+
+ return YES;
+}
+
+- (GITDateTime *) dateWithBytes:(const char **)bytes
+{
+ const char *date;
+ parseObjectRecord(bytes, recDate, &date, NULL);
+ unsigned long timeInSec = (unsigned long)strtoul(date, NULL, recDate.matchLen);
+
+ const char *tzData;
+ parseObjectRecord(bytes, recTz, &tzData, NULL);
+ NSInteger tz = (NSInteger)atoi(tzData);
+
+ return [[GITDateTime alloc] initWithBSDTime:timeInSec timeZoneOffset:tz];
+}
+
+- (void) parseCachedRawData
+{
+ if ( cachedRawData == nil )
+ return;
+ const char *rawString = [cachedRawData bytes];
+ const char *start = rawString;
+ NSString *authorInfo = [self createStringWithObjectRecord:recAuthorInfo bytes:&rawString];
+ GITActor *authorActor = [[GITActor alloc] initWithString:authorInfo];
+ [authorInfo release];
+ [self setAuthor:authorActor];
+ [authorActor release];
+
+ GITDateTime *authorDate = [self dateWithBytes:&rawString];
+ [self setAuthored:authorDate];
+ [authorDate release];
+
+ NSString *committerInfo = [self createStringWithObjectRecord:recCommitterInfo bytes:&rawString];
+ GITActor *committerActor = [[GITActor alloc] initWithString:committerInfo];
+ [committerInfo release];
+ [self setCommitter:committerActor];
+ [committerActor release];
+
+ GITDateTime *commitDate = [self dateWithBytes:&rawString];
+ [self setCommitted:commitDate];
+ [commitDate release];
+
+ rawString++; // skip '\n'
+ NSUInteger messageLength = [cachedRawData length] - (rawString - start) - 1;
+ NSString *messageString = [[NSString alloc] initWithBytes:rawString
+ length:messageLength
+ encoding:NSASCIIStringEncoding];
+ [self setMessage:messageString];
+ [messageString release];
+ [self setCachedRawData:nil];
+}
+
+- (NSString*)description
+{
+ return [NSString stringWithFormat:@"Commit <%@>", self.sha1];
+}
+
+#pragma mark -
+#pragma mark Output Methods
+- (NSData*)rawContent
+{
+ NSMutableString *treeString = [NSMutableString stringWithFormat:@"tree %@\n", self.tree.sha1];
+ for (GITCommit *parent in [self parents]) {
+ [treeString appendFormat:@"parent %@\n", [parent sha1]];
+ }
+ NSString *contentString = [NSString stringWithFormat:@"%@author %@ %@\ncommitter %@ %@\n\n%@\n",
+ treeString, self.author, self.authored,
+ self.committer, self.committed, self.message];
+ return [contentString dataUsingEncoding:NSUTF8StringEncoding];
+}
+
+@end
@@ -0,0 +1,25 @@
+//
+// GITObject+Parsing.h
+// CocoaGit
+//
+// Created by Brian Chapados on 4/29/09.
+// Copyright 2009 Brian Chapados. All rights reserved.
+//
+
+#import <Foundation/Foundation.h>
+#import "GITObject.h"
+
+struct objectRecord {
+ char *startPattern;
+ NSUInteger patternLen;
+ NSInteger startLen;
+ NSUInteger matchLen;
+ char endChar;
+};
+
+@interface GITObject (Parsing)
+BOOL parseObjectRecord(const char **buffer, struct objectRecord delim, const char **matchStart, NSUInteger *matchLength);
+// 'create' prefix indicates that the caller owns the string
+- (NSString *) createStringWithObjectRecord:(struct objectRecord)record bytes:(const char **)bytes;
+- (NSString *) createStringWithObjectRecord:(struct objectRecord)record bytes:(const char **)bytes encoding:(NSStringEncoding)encoding;
+@end
Oops, something went wrong.

0 comments on commit 13b8199

Please sign in to comment.