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 :).
This commit is contained in:
Pieter de Bie
2009-01-28 20:30:56 +00:00
parent ba80ae0311
commit a94981f359
+13 -13
View File
@@ -76,9 +76,9 @@ using namespace std;
BOOL showSign = [rev hasLeftRight]; BOOL showSign = [rev hasLeftRight];
if (showSign) 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 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) if (!rev)
[arguments addObject:@"HEAD"]; [arguments addObject:@"HEAD"];
@@ -99,7 +99,7 @@ using namespace std;
int num = 0; int num = 0;
while (true) { while (true) {
string sha; string sha;
if (!getline(stream, sha, '\0')) if (!getline(stream, sha, '\1'))
break; break;
// We reached the end of some temporary output. Show what we have // 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]; PBGitCommit* newCommit = [[PBGitCommit alloc] initWithRepository:repository andSha:oid];
string author; string author;
getline(stream, author, '\0'); getline(stream, author, '\1');
string subject; string subject;
getline(stream, subject, '\0'); getline(stream, subject, '\1');
string parentString; string parentString;
getline(stream, parentString, '\0'); getline(stream, parentString, '\1');
if (parentString.size() != 0) if (parentString.size() != 0)
{ {
if (((parentString.size() + 1) % 41) != 0) { if (((parentString.size() + 1) % 41) != 0) {
@@ -146,11 +146,7 @@ using namespace std;
int time; int time;
stream >> time; stream >> time;
char c;
stream >> c;
if (c != '\0')
cout << "Error" << endl;
[newCommit setSubject:[NSString stringWithUTF8String:subject.c_str()]]; [newCommit setSubject:[NSString stringWithUTF8String:subject.c_str()]];
[newCommit setAuthor:[NSString stringWithUTF8String:author.c_str()]]; [newCommit setAuthor:[NSString stringWithUTF8String:author.c_str()]];
@@ -158,15 +154,19 @@ using namespace std;
if (showSign) if (showSign)
{ {
char c;
stream >> c; // Remove separator
stream >> c; stream >> c;
if (c != '>' && c != '<' && c != '^' && c != '-') if (c != '>' && c != '<' && c != '^' && c != '-')
NSLog(@"Error loading commits: sign not correct"); NSLog(@"Error loading commits: sign not correct");
[newCommit setSign: c]; [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]; [revisions addObject: newCommit];
[g decorateCommit: newCommit]; [g decorateCommit: newCommit];