mirror of
https://github.com/kennethreitz-archive/gitx.git
synced 2026-06-05 23:40:18 +00:00
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:
+13
-13
@@ -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];
|
||||
|
||||
|
||||
Reference in New Issue
Block a user