Commit 2cf2d4d0 authored by Maciej Dems's avatar Maciej Dems Committed by Elvis Angelaccio

Fixed git status retrieval splitting entries


Sometimes, for large repositories the status is messed up (which in unlucky case causes `Commit..` command to disappear).

The reason for this is that `FileViewGitPlugin::beginRetrieval` method cannot correctly parse the `git status` output. The reason for this is that `FileViewGitPlugin::readUntilZeroChar` does not return complete entry, because it is not provided fast enough.

The idea of this patch is to allow the `FileViewGitPlugin::readUntilZeroChar` to wait for the remaining data.

Test Plan:
The bug depends on the race condition between the plugin code and executed `git` code. Hence it is hard to test. To fake the issue make fake git process that pauses mid entry. In such case the loop in `FileViewGitPlugin::beginRetrieval` should parse eg:

    !! ABCDEFGH\0x00

Instead it gets:

    !! AB\0x00

which results in two entries for non-existent files.

The patch solves this issue.

BUG: 413870
FIXED-IN: 19.11.80

Reviewers: elvisangelaccio

Reviewed By: elvisangelaccio

Differential Revision:
parent 0f39869f
......@@ -140,8 +140,13 @@ int FileViewGitPlugin::readUntilZeroChar(QIODevice* device, char* buffer, const
int index = -1;
while (++index < maxChars) {
if (!device->getChar(&buffer[index])) {
buffer[index] = '\0';
return index == 0 ? 0 : index + 1;
if (device->waitForReadyRead(30000)) { // 30 seconds to be consistent with QProcess::waitForReadyRead default
} else {
buffer[index] = '\0';
return index <= 0 ? 0 : index + 1;
if (buffer[index] == '\0') { // line end or we put it there (see above)
return index + 1;
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment