Skip to content

Commit

Permalink
Bugfix: Stop committer names from getting mangled
Browse files Browse the repository at this point in the history
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
brotherbard committed Jul 4, 2010
1 parent 1bad051 commit e067390
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 13 deletions.
2 changes: 2 additions & 0 deletions PBGitCommit.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ extern NSString * const kGitXCommitType;

NSString* subject;
NSString* author;
NSString *committer;
NSString* details;
NSString *_patch;
NSArray* parents;
Expand Down Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions PBGitCommit.m
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
@implementation PBGitCommit

@synthesize repository, subject, timestamp, author, parentShas, nParents, sign, lineInfo;
@synthesize committer;

- (NSArray *) parents
{
Expand Down
6 changes: 5 additions & 1 deletion PBGitRevList.mm
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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');

Expand All @@ -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)
Expand Down
21 changes: 9 additions & 12 deletions html/views/history/history.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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() {
Expand Down

0 comments on commit e067390

Please sign in to comment.