Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 132 lines (108 sloc) 2.372 kb
b752f5bc »
2008-06-14 Add a search field and subject
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"
c00f7360 »
2009-06-11 Add preference to ignore whitespace differences in history view
10 #import "PBGitDefaults.h"
b752f5bc »
2008-06-14 Add a search field and subject
11
12 @implementation PBGitCommit
13
ddc9ae76 »
2009-01-24 PBGitCommit: Don't store refs
14 @synthesize repository, subject, timestamp, author, parentShas, nParents, sign, lineInfo;
39797876 »
2008-06-17 Optimize rev-list parsing
15
8372aee4 »
2008-11-24 PBGitCommit: Use git_oids for parent shas
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 }
39797876 »
2008-06-17 Optimize rev-list parsing
31
483cbc9d »
2008-11-24 GitCommit: store the date as a timestamp
32 - (NSDate *)date
33 {
34 return [NSDate dateWithTimeIntervalSince1970:timestamp];
35 }
36
39797876 »
2008-06-17 Optimize rev-list parsing
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 }
b752f5bc »
2008-06-14 Add a search field and subject
42
31063793 »
2008-06-15 Use unified interface and display tree contents
43 - (NSArray*) treeContents
44 {
45 return self.tree.children;
46 }
47
d2eafc2d »
2008-11-21 Include libgit2 as submodule and use it to store sha's
48 - (git_oid *)sha
49 {
50 return &sha;
51 }
52
53 - initWithRepository:(PBGitRepository*) repo andSha:(git_oid)newSha
b752f5bc »
2008-06-14 Add a search field and subject
54 {
3a672aee »
2008-06-16 Cache commit details so we have to fork less
55 details = nil;
d2eafc2d »
2008-11-21 Include libgit2 as submodule and use it to store sha's
56 repository = repo;
57 sha = newSha;
b752f5bc »
2008-06-14 Add a search field and subject
58 return self;
59 }
60
d2eafc2d »
2008-11-21 Include libgit2 as submodule and use it to store sha's
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
0363eea4 »
2009-09-17 HistoryView: don't load in commit information in a separate thread an…
69 // FIXME: Remove this method once it's unused.
b752f5bc »
2008-06-14 Add a search field and subject
70 - (NSString*) details
71 {
0363eea4 »
2009-09-17 HistoryView: don't load in commit information in a separate thread an…
72 return @"";
b752f5bc »
2008-06-14 Add a search field and subject
73 }
79e9ba9f »
2008-06-14 Add a detailed HTML view
74
c6966ade »
2008-09-25 HistoryView: Add a method to put a commit online
75 - (NSString *) patch
76 {
77 if (_patch != nil)
78 return _patch;
79
2bab86cf »
2008-11-26 GitCommit: Fix patch generation
80 NSString *p = [repository outputForArguments:[NSArray arrayWithObjects:@"format-patch", @"-1", @"--stdout", [self realSha], nil]];
d4f2b4a1 »
2008-10-03 GitCommit: Add a GitX identifier to the patch output
81 // Add a GitX identifier to the patch ;)
82 _patch = [[p substringToIndex:[p length] -1] stringByAppendingString:@"+GitX"];
c6966ade »
2008-09-25 HistoryView: Add a method to put a commit online
83 return _patch;
84 }
85
9be3c50a »
2008-06-15 Add a Tree displayer
86 - (PBGitTree*) tree
87 {
88 return [PBGitTree rootForCommit: self];
89 }
90
d38c1951 »
2009-03-23 Fix moving of refs
91 - (void)addRef:(PBGitRef *)ref
4cefe8ee »
2008-11-01 HistoryView: Allow dragging of refs to move them
92 {
93 if (!self.refs)
94 self.refs = [NSMutableArray arrayWithObject:ref];
95 else
96 [self.refs addObject:ref];
97 }
98
8a399c07 »
2008-11-01 GitCommit: Add a 'removeRef' function
99 - (void)removeRef:(id)ref
100 {
101 if (!self.refs)
102 return;
103
ddc9ae76 »
2009-01-24 PBGitCommit: Don't store refs
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 {
d38c1951 »
2009-03-23 Fix moving of refs
114 [[repository refs] setObject:refs forKey:[self realSha]];
8a399c07 »
2008-11-01 GitCommit: Add a 'removeRef' function
115 }
116
8372aee4 »
2008-11-24 PBGitCommit: Use git_oids for parent shas
117 - (void)finalize
118 {
119 free(parentShas);
120 [super finalize];
121 }
122
79e9ba9f »
2008-06-14 Add a detailed HTML view
123 + (BOOL)isSelectorExcludedFromWebScript:(SEL)aSelector
124 {
125 return NO;
126 }
127
128 + (BOOL)isKeyExcludedFromWebScript:(const char *)name {
129 return NO;
130 }
b752f5bc »
2008-06-14 Add a search field and subject
131 @end
Something went wrong with that request. Please try again.