From a94981f35915828b92e94901d1f306dbe7dfc4b4 Mon Sep 17 00:00:00 2001 From: Pieter de Bie Date: Wed, 28 Jan 2009 20:30:56 +0000 Subject: [PATCH] RevList: Don't rely on the presence of %x00 The %x00 pretty specifier was only added in git v1.5.6. This is quite new, so we try to support older git clients in GitX (v1.5.4 and up). In order to do this, we need to use another specifier. Unfortunately, we can't use a real \0 in our argument, as that just cuts off our argument string. So we get the next best thing -- we use \01 :). --- PBGitRevList.mm | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/PBGitRevList.mm b/PBGitRevList.mm index cc6eb84..ba39a3a 100644 --- a/PBGitRevList.mm +++ b/PBGitRevList.mm @@ -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%x00%an%x00%s%x00%P%x00%at%x00%m", nil]; + arguments = [NSMutableArray arrayWithObjects:@"log", @"-z", @"--early-output", @"--topo-order", @"--pretty=format:%H\01%an\01%s\01%P\01%at\01%m", nil]; else - arguments = [NSMutableArray arrayWithObjects:@"log", @"-z", @"--early-output", @"--topo-order", @"--pretty=format:%H%x00%an%x00%s%x00%P%x00%at", nil]; + arguments = [NSMutableArray arrayWithObjects:@"log", @"-z", @"--early-output", @"--topo-order", @"--pretty=format:%H\01%an\01%s\01%P\01%at", nil]; if (!rev) [arguments addObject:@"HEAD"]; @@ -99,7 +99,7 @@ using namespace std; int num = 0; while (true) { string sha; - if (!getline(stream, sha, '\0')) + if (!getline(stream, sha, '\1')) break; // We reached the end of some temporary output. Show what we have @@ -121,13 +121,13 @@ using namespace std; PBGitCommit* newCommit = [[PBGitCommit alloc] initWithRepository:repository andSha:oid]; string author; - getline(stream, author, '\0'); + getline(stream, author, '\1'); string subject; - getline(stream, subject, '\0'); + getline(stream, subject, '\1'); string parentString; - getline(stream, parentString, '\0'); + getline(stream, parentString, '\1'); if (parentString.size() != 0) { if (((parentString.size() + 1) % 41) != 0) { @@ -146,11 +146,7 @@ using namespace std; int time; stream >> time; - char c; - stream >> c; - if (c != '\0') - cout << "Error" << endl; [newCommit setSubject:[NSString stringWithUTF8String:subject.c_str()]]; [newCommit setAuthor:[NSString stringWithUTF8String:author.c_str()]]; @@ -158,15 +154,19 @@ using namespace std; if (showSign) { + char c; + stream >> c; // Remove separator stream >> c; if (c != '>' && c != '<' && c != '^' && c != '-') NSLog(@"Error loading commits: sign not correct"); [newCommit setSign: c]; - stream >> c; - if (c != '\0' && !stream.eof()) - NSLog(@"Error: unexpected char (expected '0', was: %c)", c); } + char c; + stream >> c; + if (c != '\0') + cout << "Error" << endl; + [revisions addObject: newCommit]; [g decorateCommit: newCommit];