From 97e3d189caff422d264729919ca6cb02dc31f1d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Berg?= Date: Fri, 26 Mar 2010 00:57:53 +0100 Subject: [PATCH] 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. --- PBGitCommit.m | 8 ++++---- html/views/history/history.js | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/PBGitCommit.m b/PBGitCommit.m index 36d3b09..1db6cd5 100644 --- a/PBGitCommit.m +++ b/PBGitCommit.m @@ -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]; } diff --git a/html/views/history/history.js b/html/views/history/history.js index 0c02b86..65c188a 100644 --- a/html/views/history/history.js +++ b/html/views/history/history.js @@ -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;