5 // Created by Pieter de Bie on 13-06-08.
6 // Copyright 2008 __MyCompanyName__. All rights reserved.
9 #import "PBGitCommit.h"
10 #import "PBGitDefaults.h"
12 @implementation PBGitCommit
14 @synthesize repository, subject, timestamp, author, parentShas, nParents, sign, lineInfo;
22 NSMutableArray *p = [NSMutableArray arrayWithCapacity:nParents];
23 for (i = 0; i < nParents; ++i)
25 char *s = git_oid_mkhex(parentShas + i);
26 [p addObject:[NSString stringWithUTF8String:s]];
34 return [NSDate dateWithTimeIntervalSince1970:timestamp];
37 - (NSString *) dateString
39 NSDateFormatter* formatter = [[NSDateFormatter alloc] initWithDateFormat:@"%Y-%m-%d %H:%M:%S" allowNaturalLanguage:NO];
40 return [formatter stringFromDate: self.date];
43 - (NSArray*) treeContents
45 return self.tree.children;
53 - initWithRepository:(PBGitRepository*) repo andSha:(git_oid)newSha
63 char *hex = git_oid_mkhex(&sha);
64 NSString *str = [NSString stringWithUTF8String:hex];
69 // NOTE: This method should remain threadsafe, as we load it in async
76 NSMutableArray *arguments = [NSMutableArray arrayWithObjects:@"show", @"--pretty=raw", @"-M", @"--no-color", [self realSha], nil];
77 if (![PBGitDefaults showWhitespaceDifferences])
78 [arguments insertObject:@"-w" atIndex:1];
80 details = [self.repository outputForArguments:arguments];
90 NSString *p = [repository outputForArguments:[NSArray arrayWithObjects:@"format-patch", @"-1", @"--stdout", [self realSha], nil]];
91 // Add a GitX identifier to the patch ;)
92 _patch = [[p substringToIndex:[p length] -1] stringByAppendingString:@"+GitX"];
98 return [PBGitTree rootForCommit: self];
101 - (void)addRef:(PBGitRef *)ref
104 self.refs = [NSMutableArray arrayWithObject:ref];
106 [self.refs addObject:ref];
109 - (void)removeRef:(id)ref
114 [self.refs removeObject:ref];
117 - (NSMutableArray *)refs
119 return [[repository refs] objectForKey:[self realSha]];
122 - (void) setRefs:(NSMutableArray *)refs
124 [[repository refs] setObject:refs forKey:[self realSha]];
133 + (BOOL)isSelectorExcludedFromWebScript:(SEL)aSelector
138 + (BOOL)isKeyExcludedFromWebScript:(const char *)name {