Permalink
Browse files

Bugfix: Stop committer names from getting mangled

If the commit's detail is not UTF8 then PBWebHistoryController's commitDetailsLoaded: method will drop down to Latin1. That can cause character's in the committer's name to not be converted correctly.

Move parsing the name to PBGitRevList where the correct encoding can be determined.
  • Loading branch information...
1 parent 1bad051 commit e067390fb22a9619efdbb8c29952ed9b7ec09ee3 @brotherbard committed Jul 3, 2010
Showing with 17 additions and 13 deletions.
  1. +2 −0 PBGitCommit.h
  2. +1 −0 PBGitCommit.m
  3. +5 −1 PBGitRevList.mm
  4. +9 −12 html/views/history/history.js
View
2 PBGitCommit.h
@@ -23,6 +23,7 @@ extern NSString * const kGitXCommitType;
NSString* subject;
NSString* author;
+ NSString *committer;
NSString* details;
NSString *_patch;
NSArray* parents;
@@ -53,6 +54,7 @@ extern NSString * const kGitXCommitType;
@property (readonly) git_oid *sha;
@property (copy) NSString* subject;
@property (copy) NSString* author;
+@property (copy) NSString *committer;
@property (readonly) NSArray* parents; // TODO: remove this and its uses
@property (assign) git_oid *parentShas;
View
1 PBGitCommit.m
@@ -16,6 +16,7 @@
@implementation PBGitCommit
@synthesize repository, subject, timestamp, author, parentShas, nParents, sign, lineInfo;
+@synthesize committer;
- (NSArray *) parents
{
View
6 PBGitRevList.mm
@@ -96,7 +96,7 @@ - (void) walkRevisionListWithSpecifier:(PBGitRevSpecifier*)rev
std::map<string, NSStringEncoding> encodingMap;
NSThread *currentThread = [NSThread currentThread];
- NSString *formatString = @"--pretty=format:%H\01%e\01%an\01%s\01%P\01%at";
+ NSString *formatString = @"--pretty=format:%H\01%e\01%an\01%cn\01%s\01%P\01%at";
BOOL showSign = [rev hasLeftRight];
if (showSign)
@@ -145,6 +145,9 @@ - (void) walkRevisionListWithSpecifier:(PBGitRevSpecifier*)rev
string author;
getline(stream, author, '\1');
+ string committer;
+ getline(stream, committer, '\1');
+
string subject;
getline(stream, subject, '\1');
@@ -171,6 +174,7 @@ - (void) walkRevisionListWithSpecifier:(PBGitRevSpecifier*)rev
[newCommit setSubject:[NSString stringWithCString:subject.c_str() encoding:encoding]];
[newCommit setAuthor:[NSString stringWithCString:author.c_str() encoding:encoding]];
+ [newCommit setCommitter:[NSString stringWithCString:committer.c_str() encoding:encoding]];
[newCommit setTimestamp:time];
if (showSign)
View
21 html/views/history/history.js
@@ -7,6 +7,7 @@ var Commit = function(obj) {
this.refs = obj.refs();
this.author_name = obj.author;
+ this.committer_name = obj.committer;
this.sha = obj.realSha();
this.parents = obj.parents;
this.subject = obj.subject;
@@ -37,21 +38,17 @@ var Commit = function(obj) {
if (typeof match !== 'undefined' && typeof match[2] !== 'undefined') {
if (!(match[2].match(/@[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}/)))
this.author_email = match[2];
-
- this.author_date = new Date(parseInt(match[3]) * 1000);
-
+
+ if (typeof match[3] !== 'undefined')
+ this.author_date = new Date(parseInt(match[3]) * 1000);
+
match = this.header.match(/\ncommitter (.*) <(.*@.*|.*)> ([0-9].*)/);
- if (typeof match !== 'undefined') {
- this.committer_name = match[1];
- this.committer_email = match[2];
- } else {
- this.committer_name = "undefined";
- this.committer_email = "undefined";
- }
+ if (typeof match[2] !== 'undefined')
+ this.committer_email = match[2];
+ if (typeof match[3] !== 'undefined')
+ this.committer_date = new Date(parseInt(match[3]) * 1000);
}
}
-
- this.committer_date = new Date(parseInt(match[3]) * 1000);
}
this.reloadRefs = function() {

0 comments on commit e067390

Please sign in to comment.