mirror of
https://github.com/kennethreitz-archive/gitx.git
synced 2026-06-05 23:40:18 +00:00
GitRevList -- Try to read the encoding of the commit message
This tries to read the encoding of the commit message, if it's specified by git (using i18n.commitEncoding at the time of committing). It uses an ugly hack to try to convert the encoding string to an NSStringEncoding, and then uses that for the subject and committer name. I'm not sure how expensive this is. If it's too expensive, we might need to cache this value.
This commit is contained in:
+10
-4
@@ -76,9 +76,9 @@ using namespace std;
|
||||
BOOL showSign = [rev hasLeftRight];
|
||||
|
||||
if (showSign)
|
||||
arguments = [NSMutableArray arrayWithObjects:@"log", @"-z", @"--early-output", @"--topo-order", @"--pretty=format:%H\01%an\01%s\01%P\01%at\01%m", nil];
|
||||
arguments = [NSMutableArray arrayWithObjects:@"log", @"-z", @"--early-output", @"--topo-order", @"--pretty=format:%H\01%e\01%an\01%s\01%P\01%at\01%m", nil];
|
||||
else
|
||||
arguments = [NSMutableArray arrayWithObjects:@"log", @"-z", @"--early-output", @"--topo-order", @"--pretty=format:%H\01%an\01%s\01%P\01%at", nil];
|
||||
arguments = [NSMutableArray arrayWithObjects:@"log", @"-z", @"--early-output", @"--topo-order", @"--pretty=format:%H\01%e\01%an\01%s\01%P\01%at", nil];
|
||||
|
||||
if (!rev)
|
||||
[arguments addObject:@"HEAD"];
|
||||
@@ -120,6 +120,12 @@ using namespace std;
|
||||
}
|
||||
|
||||
// From now on, 1.2 seconds
|
||||
string encoding_str;
|
||||
getline(stream, encoding_str, '\1');
|
||||
NSStringEncoding encoding = NSUTF8StringEncoding;
|
||||
if (encoding_str.length())
|
||||
encoding = CFStringConvertEncodingToNSStringEncoding(CFStringConvertIANACharSetNameToEncoding((CFStringRef)[NSString stringWithUTF8String:encoding_str.c_str()]));
|
||||
|
||||
git_oid oid;
|
||||
git_oid_mkstr(&oid, sha.c_str());
|
||||
PBGitCommit* newCommit = [[PBGitCommit alloc] initWithRepository:repository andSha:oid];
|
||||
@@ -152,8 +158,8 @@ using namespace std;
|
||||
stream >> time;
|
||||
|
||||
|
||||
[newCommit setSubject:[NSString stringWithUTF8String:subject.c_str()]];
|
||||
[newCommit setAuthor:[NSString stringWithUTF8String:author.c_str()]];
|
||||
[newCommit setSubject:[NSString stringWithCString:subject.c_str() encoding:encoding]];
|
||||
[newCommit setAuthor:[NSString stringWithCString:author.c_str() encoding:encoding]];
|
||||
[newCommit setTimestamp:time];
|
||||
|
||||
if (showSign)
|
||||
|
||||
Reference in New Issue
Block a user