Skip to content

Commit 97e3d18

Browse files
committed
Bugfix: obj.realSha() in history.js returns nil/undefined more often than not.
My guess is that this is caused by the rather large buffer size of 2000. Since we know that a full SHA will never be longer than 40+1 bytes, we simply use a default define from libgit2 for the buffer size.
1 parent 0177e20 commit 97e3d18

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

PBGitCommit.m

+4-4
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ - (NSArray *) parents
2626
NSMutableArray *p = [NSMutableArray arrayWithCapacity:nParents];
2727
for (i = 0; i < nParents; ++i)
2828
{
29-
char buff[2000];
30-
char * s = git_oid_to_string(buff, 2000, parentShas + i);
29+
char buff[GIT_OID_HEXSZ+1];
30+
char * s = git_oid_to_string(buff, GIT_OID_HEXSZ+1, parentShas + i);
3131
[p addObject:[NSString stringWithUTF8String:s]];
3232
}
3333
return p;
@@ -127,8 +127,8 @@ - (git_oid *)sha
127127
- (NSString *)realSha
128128
{
129129
if (!realSHA) {
130-
char buff[2000];
131-
char * hex = git_oid_to_string(buff, 2000, &sha);
130+
char buff[GIT_OID_HEXSZ+1];
131+
char * hex = git_oid_to_string(buff, GIT_OID_HEXSZ+1, &sha);
132132
realSHA = [NSString stringWithUTF8String:hex];
133133
}
134134

html/views/history/history.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ var Commit = function(obj) {
77

88
this.refs = obj.refs();
99
this.author_name = obj.author;
10-
this.sha = obj.realSha();
11-
this.parents = obj.parents;
10+
this.sha = obj.realSha();
11+
this.parents = obj.parents;
1212
this.subject = obj.subject;
1313
this.notificationID = null;
1414

0 commit comments

Comments
 (0)