| 295 | } |
| 296 | |
| 297 | static void parseNumStat(const QByteArray &raw, std::vector<GitFileItem> *items) |
| 298 | { |
| 299 | const auto splitter = ByteArraySplitter(raw, '\0'); |
| 300 | for (auto it = splitter.begin(); it != splitter.end(); ++it) { |
| 301 | const auto line = *it; |
| 302 | // format: 12(adds)\t10(subs)\tFileName |
| 303 | auto lineSplitter = ByteArraySplitter(line, '\t'); |
| 304 | const auto cols = lineSplitter.toContainer<QVarLengthArray<strview, 3>>(); |
| 305 | if (cols.length() < 3) { |
| 306 | continue; |
| 307 | } |
| 308 | |
| 309 | int add = 0; |
| 310 | int sub = 0; |
| 311 | if (cols[0] == "-") { |
| 312 | add = sub = 0; |
| 313 | } else { |
| 314 | auto col0 = cols[0].to<int>(); |
| 315 | auto col1 = cols[1].to<int>(); |
| 316 | if (!col0 || !col1) { |
| 317 | continue; |
| 318 | } |
| 319 | add = col0.value(); |
| 320 | sub = col1.value(); |
| 321 | } |
| 322 | |
| 323 | if (cols[2].empty()) { |
| 324 | it++; // skip this |
| 325 | if (it == splitter.end()) { |
| 326 | qWarning() << "Unexpected EOF when parsing numstat"; |
| 327 | break; |
| 328 | } |
| 329 | auto oldFileName = (*it).toByteArray().trimmed(); |
| 330 | it++; |
| 331 | if (it == splitter.end()) { |
| 332 | qWarning() << "Unexpected EOF when parsing numstat"; |
| 333 | break; |
| 334 | } |
| 335 | auto file = (*it).toByteArray().trimmed(); |
| 336 | items->push_back(GitFileItem{ |
| 337 | .oldFileName = oldFileName, |
| 338 | .file = file, |
| 339 | .linesAdded = add, |
| 340 | .linesRemoved = sub, |
| 341 | }); |
| 342 | } else { |
| 343 | items->push_back(GitFileItem{ |
| 344 | .oldFileName = {}, |
| 345 | .file = cols[2].toByteArray(), |
| 346 | .linesAdded = add, |
| 347 | .linesRemoved = sub, |
| 348 | }); |
| 349 | } |
| 350 | } |
| 351 | } |
| 352 | |
| 353 | class CommitDiffTreeView : public QWidget |
| 354 | { |
no test coverage detected