Skip to content

Commit e067390

Browse files
committed
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.
1 parent 1bad051 commit e067390

File tree

4 files changed

+17
-13
lines changed

4 files changed

+17
-13
lines changed

PBGitCommit.h

+2
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ extern NSString * const kGitXCommitType;
2323

2424
NSString* subject;
2525
NSString* author;
26+
NSString *committer;
2627
NSString* details;
2728
NSString *_patch;
2829
NSArray* parents;
@@ -53,6 +54,7 @@ extern NSString * const kGitXCommitType;
5354
@property (readonly) git_oid *sha;
5455
@property (copy) NSString* subject;
5556
@property (copy) NSString* author;
57+
@property (copy) NSString *committer;
5658
@property (readonly) NSArray* parents; // TODO: remove this and its uses
5759

5860
@property (assign) git_oid *parentShas;

PBGitCommit.m

+1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
@implementation PBGitCommit
1717

1818
@synthesize repository, subject, timestamp, author, parentShas, nParents, sign, lineInfo;
19+
@synthesize committer;
1920

2021
- (NSArray *) parents
2122
{

PBGitRevList.mm

+5-1
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ - (void) walkRevisionListWithSpecifier:(PBGitRevSpecifier*)rev
9696
std::map<string, NSStringEncoding> encodingMap;
9797
NSThread *currentThread = [NSThread currentThread];
9898

99-
NSString *formatString = @"--pretty=format:%H\01%e\01%an\01%s\01%P\01%at";
99+
NSString *formatString = @"--pretty=format:%H\01%e\01%an\01%cn\01%s\01%P\01%at";
100100
BOOL showSign = [rev hasLeftRight];
101101

102102
if (showSign)
@@ -145,6 +145,9 @@ - (void) walkRevisionListWithSpecifier:(PBGitRevSpecifier*)rev
145145
string author;
146146
getline(stream, author, '\1');
147147

148+
string committer;
149+
getline(stream, committer, '\1');
150+
148151
string subject;
149152
getline(stream, subject, '\1');
150153

@@ -171,6 +174,7 @@ - (void) walkRevisionListWithSpecifier:(PBGitRevSpecifier*)rev
171174

172175
[newCommit setSubject:[NSString stringWithCString:subject.c_str() encoding:encoding]];
173176
[newCommit setAuthor:[NSString stringWithCString:author.c_str() encoding:encoding]];
177+
[newCommit setCommitter:[NSString stringWithCString:committer.c_str() encoding:encoding]];
174178
[newCommit setTimestamp:time];
175179

176180
if (showSign)

html/views/history/history.js

+9-12
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ var Commit = function(obj) {
77

88
this.refs = obj.refs();
99
this.author_name = obj.author;
10+
this.committer_name = obj.committer;
1011
this.sha = obj.realSha();
1112
this.parents = obj.parents;
1213
this.subject = obj.subject;
@@ -37,21 +38,17 @@ var Commit = function(obj) {
3738
if (typeof match !== 'undefined' && typeof match[2] !== 'undefined') {
3839
if (!(match[2].match(/@[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}/)))
3940
this.author_email = match[2];
40-
41-
this.author_date = new Date(parseInt(match[3]) * 1000);
42-
41+
42+
if (typeof match[3] !== 'undefined')
43+
this.author_date = new Date(parseInt(match[3]) * 1000);
44+
4345
match = this.header.match(/\ncommitter (.*) <(.*@.*|.*)> ([0-9].*)/);
44-
if (typeof match !== 'undefined') {
45-
this.committer_name = match[1];
46-
this.committer_email = match[2];
47-
} else {
48-
this.committer_name = "undefined";
49-
this.committer_email = "undefined";
50-
}
46+
if (typeof match[2] !== 'undefined')
47+
this.committer_email = match[2];
48+
if (typeof match[3] !== 'undefined')
49+
this.committer_date = new Date(parseInt(match[3]) * 1000);
5150
}
5251
}
53-
54-
this.committer_date = new Date(parseInt(match[3]) * 1000);
5552
}
5653

5754
this.reloadRefs = function() {

0 commit comments

Comments
 (0)