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.
This commit is contained in:
André Berg
2010-03-26 00:57:53 +01:00
parent 0177e20824
commit 97e3d189ca
2 changed files with 6 additions and 6 deletions
+4 -4
View File
@@ -26,8 +26,8 @@ NSString * const kGitXCommitType = @"commit";
NSMutableArray *p = [NSMutableArray arrayWithCapacity:nParents];
for (i = 0; i < nParents; ++i)
{
char buff[2000];
char * s = git_oid_to_string(buff, 2000, parentShas + i);
char buff[GIT_OID_HEXSZ+1];
char * s = git_oid_to_string(buff, GIT_OID_HEXSZ+1, parentShas + i);
[p addObject:[NSString stringWithUTF8String:s]];
}
return p;
@@ -127,8 +127,8 @@ NSString * const kGitXCommitType = @"commit";
- (NSString *)realSha
{
if (!realSHA) {
char buff[2000];
char * hex = git_oid_to_string(buff, 2000, &sha);
char buff[GIT_OID_HEXSZ+1];
char * hex = git_oid_to_string(buff, GIT_OID_HEXSZ+1, &sha);
realSHA = [NSString stringWithUTF8String:hex];
}
+2 -2
View File
@@ -7,8 +7,8 @@ var Commit = function(obj) {
this.refs = obj.refs();
this.author_name = obj.author;
this.sha = obj.realSha();
this.parents = obj.parents;
this.sha = obj.realSha();
this.parents = obj.parents;
this.subject = obj.subject;
this.notificationID = null;