Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 132 lines (108 sloc) 2.372 kB
b752f5b @pieter Add a search field and subject
authored
1 //
2 // PBGitCommit.m
3 // GitTest
4 //
5 // Created by Pieter de Bie on 13-06-08.
6 // Copyright 2008 __MyCompanyName__. All rights reserved.
7 //
8
9 #import "PBGitCommit.h"
c00f736 @pieter Add preference to ignore whitespace differences in history view
authored
10 #import "PBGitDefaults.h"
b752f5b @pieter Add a search field and subject
authored
11
12 @implementation PBGitCommit
13
ddc9ae7 @pieter PBGitCommit: Don't store refs
authored
14 @synthesize repository, subject, timestamp, author, parentShas, nParents, sign, lineInfo;
3979787 @pieter Optimize rev-list parsing
authored
15
8372aee @pieter PBGitCommit: Use git_oids for parent shas
authored
16 - (NSArray *) parents
17 {
18 if (nParents == 0)
19 return NULL;
20
21 int i;
22 NSMutableArray *p = [NSMutableArray arrayWithCapacity:nParents];
23 for (i = 0; i < nParents; ++i)
24 {
25 char *s = git_oid_mkhex(parentShas + i);
26 [p addObject:[NSString stringWithUTF8String:s]];
27 free(s);
28 }
29 return p;
30 }
3979787 @pieter Optimize rev-list parsing
authored
31
483cbc9 @pieter GitCommit: store the date as a timestamp
authored
32 - (NSDate *)date
33 {
34 return [NSDate dateWithTimeIntervalSince1970:timestamp];
35 }
36
3979787 @pieter Optimize rev-list parsing
authored
37 - (NSString *) dateString
38 {
39 NSDateFormatter* formatter = [[NSDateFormatter alloc] initWithDateFormat:@"%Y-%m-%d %H:%M:%S" allowNaturalLanguage:NO];
40 return [formatter stringFromDate: self.date];
41 }
b752f5b @pieter Add a search field and subject
authored
42
3106379 @pieter Use unified interface and display tree contents
authored
43 - (NSArray*) treeContents
44 {
45 return self.tree.children;
46 }
47
d2eafc2 @pieter Include libgit2 as submodule and use it to store sha's
authored
48 - (git_oid *)sha
49 {
50 return &sha;
51 }
52
53 - initWithRepository:(PBGitRepository*) repo andSha:(git_oid)newSha
b752f5b @pieter Add a search field and subject
authored
54 {
3a672ae @pieter Cache commit details so we have to fork less
authored
55 details = nil;
d2eafc2 @pieter Include libgit2 as submodule and use it to store sha's
authored
56 repository = repo;
57 sha = newSha;
b752f5b @pieter Add a search field and subject
authored
58 return self;
59 }
60
d2eafc2 @pieter Include libgit2 as submodule and use it to store sha's
authored
61 - (NSString *)realSha
62 {
63 char *hex = git_oid_mkhex(&sha);
64 NSString *str = [NSString stringWithUTF8String:hex];
65 free(hex);
66 return str;
67 }
68
0363eea @pieter HistoryView: don't load in commit information in a separate thread an…
authored
69 // FIXME: Remove this method once it's unused.
b752f5b @pieter Add a search field and subject
authored
70 - (NSString*) details
71 {
0363eea @pieter HistoryView: don't load in commit information in a separate thread an…
authored
72 return @"";
b752f5b @pieter Add a search field and subject
authored
73 }
79e9ba9 @pieter Add a detailed HTML view
authored
74
c6966ad @pieter HistoryView: Add a method to put a commit online
authored
75 - (NSString *) patch
76 {
77 if (_patch != nil)
78 return _patch;
79
2bab86c @pieter GitCommit: Fix patch generation
authored
80 NSString *p = [repository outputForArguments:[NSArray arrayWithObjects:@"format-patch", @"-1", @"--stdout", [self realSha], nil]];
d4f2b4a @pieter GitCommit: Add a GitX identifier to the patch output
authored
81 // Add a GitX identifier to the patch ;)
82 _patch = [[p substringToIndex:[p length] -1] stringByAppendingString:@"+GitX"];
c6966ad @pieter HistoryView: Add a method to put a commit online
authored
83 return _patch;
84 }
85
9be3c50 @pieter Add a Tree displayer
authored
86 - (PBGitTree*) tree
87 {
88 return [PBGitTree rootForCommit: self];
89 }
90
d38c195 Fix moving of refs
Pieter de Bie authored
91 - (void)addRef:(PBGitRef *)ref
4cefe8e @pieter HistoryView: Allow dragging of refs to move them
authored
92 {
93 if (!self.refs)
94 self.refs = [NSMutableArray arrayWithObject:ref];
95 else
96 [self.refs addObject:ref];
97 }
98
8a399c0 @pieter GitCommit: Add a 'removeRef' function
authored
99 - (void)removeRef:(id)ref
100 {
101 if (!self.refs)
102 return;
103
ddc9ae7 @pieter PBGitCommit: Don't store refs
authored
104 [self.refs removeObject:ref];
105 }
106
107 - (NSMutableArray *)refs
108 {
109 return [[repository refs] objectForKey:[self realSha]];
110 }
111
112 - (void) setRefs:(NSMutableArray *)refs
113 {
d38c195 Fix moving of refs
Pieter de Bie authored
114 [[repository refs] setObject:refs forKey:[self realSha]];
8a399c0 @pieter GitCommit: Add a 'removeRef' function
authored
115 }
116
8372aee @pieter PBGitCommit: Use git_oids for parent shas
authored
117 - (void)finalize
118 {
119 free(parentShas);
120 [super finalize];
121 }
122
79e9ba9 @pieter Add a detailed HTML view
authored
123 + (BOOL)isSelectorExcludedFromWebScript:(SEL)aSelector
124 {
125 return NO;
126 }
127
128 + (BOOL)isKeyExcludedFromWebScript:(const char *)name {
129 return NO;
130 }
b752f5b @pieter Add a search field and subject
authored
131 @end
Something went wrong with that request. Please try again.