Skip to content

Commit

Permalink
RevList: Don't rely on the presence of %x00
Browse files Browse the repository at this point in the history
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 :).
  • Loading branch information
Pieter de Bie committed Jan 28, 2009
1 parent ba80ae0 commit a94981f
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions PBGitRevList.mm
Expand Up @@ -76,9 +76,9 @@ - (void) walkRevisionListWithSpecifier: (PBGitRevSpecifier*) rev
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"];
Expand All @@ -99,7 +99,7 @@ - (void) walkRevisionListWithSpecifier: (PBGitRevSpecifier*) rev
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
Expand All @@ -121,13 +121,13 @@ - (void) walkRevisionListWithSpecifier: (PBGitRevSpecifier*) rev
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) {
Expand All @@ -146,27 +146,27 @@ - (void) walkRevisionListWithSpecifier: (PBGitRevSpecifier*) rev

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()]];
[newCommit setTimestamp:time];

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];

Expand Down

0 comments on commit a94981f

Please sign in to comment.