| 1411 | } |
| 1412 | |
| 1413 | void GitPlugin::parseGitStatusOutput(DVcsJob* job) |
| 1414 | { |
| 1415 | const auto output = job->output(); |
| 1416 | const auto outputLines = QStringView{output}.split(QLatin1Char('\n'), Qt::SkipEmptyParts); |
| 1417 | QDir workingDir = job->directory(); |
| 1418 | QDir dotGit = dotGitDirectory(QUrl::fromLocalFile(workingDir.absolutePath())); |
| 1419 | |
| 1420 | QVariantList statuses; |
| 1421 | QList<QUrl> processedFiles; |
| 1422 | |
| 1423 | for (const auto line : outputLines) { |
| 1424 | //every line is 2 chars for the status, 1 space then the file desc |
| 1425 | if (line.size() < 3) { |
| 1426 | qCWarning(PLUGIN_GIT) << "a git-status --porcelain output line is shorter than expected:" << line; |
| 1427 | continue; |
| 1428 | } |
| 1429 | auto curr = line.sliced(3); |
| 1430 | const auto state = line.first(2); |
| 1431 | |
| 1432 | int arrow = curr.indexOf(QLatin1String(" -> ")); |
| 1433 | if(arrow>=0) { |
| 1434 | VcsStatusInfo status; |
| 1435 | status.setUrl(QUrl::fromLocalFile(dotGit.absoluteFilePath(curr.first(arrow).toString()))); |
| 1436 | status.setState(VcsStatusInfo::ItemDeleted); |
| 1437 | statuses.append(QVariant::fromValue<VcsStatusInfo>(status)); |
| 1438 | processedFiles += status.url(); |
| 1439 | |
| 1440 | curr = curr.sliced(arrow + 4); |
| 1441 | } |
| 1442 | |
| 1443 | constexpr QLatin1Char doubleQuote{'"'}; |
| 1444 | if (curr.size() >= 2 && curr.front() == doubleQuote && curr.back() == doubleQuote) { |
| 1445 | // the path is quoted => unquote |
| 1446 | curr = curr.sliced(1, curr.size() - 2); |
| 1447 | } |
| 1448 | |
| 1449 | VcsStatusInfo status; |
| 1450 | ExtendedState ex_state = parseGitState(state); |
| 1451 | status.setUrl(QUrl::fromLocalFile(dotGit.absoluteFilePath(curr.toString()))); |
| 1452 | status.setExtendedState(ex_state); |
| 1453 | status.setState(extendedStateToBasic(ex_state)); |
| 1454 | processedFiles.append(status.url()); |
| 1455 | |
| 1456 | qCDebug(PLUGIN_GIT) << "Checking git status for " << line << curr << status.state(); |
| 1457 | |
| 1458 | statuses.append(QVariant::fromValue<VcsStatusInfo>(status)); |
| 1459 | } |
| 1460 | QStringList paths; |
| 1461 | QStringList oldcmd=job->dvcsCommand(); |
| 1462 | QStringList::const_iterator it=oldcmd.constBegin()+oldcmd.indexOf(QStringLiteral("--"))+1, itEnd=oldcmd.constEnd(); |
| 1463 | paths.reserve(oldcmd.size()); |
| 1464 | for(; it!=itEnd; ++it) |
| 1465 | paths += *it; |
| 1466 | |
| 1467 | //here we add the already up to date files |
| 1468 | const QStringList files = getLsFiles(job->directory(), QStringList{QStringLiteral("-c"), QStringLiteral("--")} << paths, OutputJob::Silent); |
| 1469 | for (const QString& file : files) { |
| 1470 | QUrl fileUrl = QUrl::fromLocalFile(workingDir.absoluteFilePath(file)); |
nothing calls this directly
no test coverage detected