diff --git a/PBGitCommit.h b/PBGitCommit.h index 995df01..edee41e 100644 --- a/PBGitCommit.h +++ b/PBGitCommit.h @@ -15,6 +15,7 @@ NSString* subject; NSString* author; NSString* details; + NSArray* parents; NSDate* date; PBGitRepository* repository; } @@ -24,6 +25,7 @@ @property (copy) NSString* sha; @property (copy) NSString* subject; @property (copy) NSString* author; +@property (retain) NSArray* parents; @property (copy) NSDate* date; @property (readonly) NSString* dateString; diff --git a/PBGitCommit.m b/PBGitCommit.m index 5e68674..7cb7a7b 100644 --- a/PBGitCommit.m +++ b/PBGitCommit.m @@ -11,7 +11,7 @@ @implementation PBGitCommit -@synthesize sha, repository, subject, author, date; +@synthesize sha, repository, subject, author, date, parents; - (NSString *) dateString diff --git a/PBGitRepository.m b/PBGitRepository.m index 593cdfc..e174049 100644 --- a/PBGitRepository.m +++ b/PBGitRepository.m @@ -76,7 +76,7 @@ static NSString* gitPath = @"/usr/bin/env"; NSMutableArray * newArray = [NSMutableArray array]; NSDate* start = [NSDate date]; - NSFileHandle* handle = [self handleForCommand:@"log --pretty=format:%H\01%an\01%s\01%at HEAD"]; + NSFileHandle* handle = [self handleForCommand:@"log --pretty=format:%H\01%an\01%s\01%P\01%at HEAD"]; int fd = [handle fileDescriptor]; FILE* f = fdopen(fd, "r"); @@ -102,11 +102,13 @@ static NSString* gitPath = @"/usr/bin/env"; // If we are here, we currentLine is a full line. NSArray* components = [currentLine componentsSeparatedByString:@"\01"]; - if ([components count] < 4) { + if ([components count] < 5) { NSLog(@"Can't split string: %@", currentLine); continue; } PBGitCommit* newCommit = [[PBGitCommit alloc] initWithRepository: self andSha: [components objectAtIndex:0]]; + NSArray* parents = [[components objectAtIndex:3] componentsSeparatedByString:@" "]; + newCommit.parents = parents; newCommit.subject = [components objectAtIndex:2]; newCommit.author = [components objectAtIndex:1]; newCommit.date = [NSDate dateWithTimeIntervalSince1970:[[components objectAtIndex:3] intValue]]; diff --git a/html/commit.js b/html/commit.js index adba0bf..18d5f00 100644 --- a/html/commit.js +++ b/html/commit.js @@ -27,10 +27,7 @@ var Commit = Class.create({ this.committer_email = match[2]; this.committer_date = new Date(parseInt(match[3]) * 1000); - this.parents = $A(this.header.match(/\nparent ([0-9a-f]{40,40})/g)).map(function(x) { - return x.replace("\nparent ",""); - }); - + this.parents = obj.parents; }, });