File indexing completed on 2024-05-12 05:51:44
0001 /* 0002 SPDX-FileCopyrightText: 2021 Waqar Ahmed <waqar.17a@gmail.com> 0003 0004 SPDX-License-Identifier: LGPL-2.0-or-later 0005 */ 0006 #pragma once 0007 0008 #include <QList> 0009 #include <QSet> 0010 #include <QString> 0011 0012 namespace GitUtils 0013 { 0014 enum GitStatus { 0015 Unmerge_BothDeleted, 0016 Unmerge_AddedByUs, 0017 Unmerge_DeletedByThem, 0018 Unmerge_AddedByThem, 0019 Unmerge_DeletedByUs, 0020 Unmerge_BothAdded, 0021 Unmerge_BothModified, 0022 0023 Index_Modified, 0024 Index_Added, 0025 Index_Deleted, 0026 Index_Renamed, 0027 Index_Copied, 0028 0029 WorkingTree_Modified, 0030 WorkingTree_Deleted, 0031 WorkingTree_IntentToAdd, 0032 0033 Untracked, 0034 Ignored 0035 }; 0036 0037 enum StatusXY { 0038 DD = 0x4444, 0039 AU = 0x4155, 0040 UD = 0x5544, 0041 UA = 0x5541, 0042 DU = 0x4455, 0043 AA = 0x4141, 0044 UU = 0x5555, 0045 0046 //?? 0047 QQ = 0x3f3f, 0048 //!! 0049 II = 0x2121, 0050 }; 0051 0052 struct StatusItem { 0053 QByteArray file; 0054 GitStatus status; 0055 char statusChar = 0; 0056 int linesAdded = 0; 0057 int linesRemoved = 0; 0058 }; 0059 0060 struct GitParsedStatus { 0061 QList<StatusItem> untracked; 0062 QList<StatusItem> unmerge; 0063 QList<StatusItem> staged; 0064 QList<StatusItem> changed; 0065 QSet<QString> nonUniqueFileNames; 0066 }; 0067 0068 GitParsedStatus parseStatus(const QByteArray &raw, const QString &workingDir); 0069 0070 void parseDiffNumStat(QList<GitUtils::StatusItem> &items, const QByteArray &raw); 0071 0072 QList<StatusItem> parseDiffNameStatus(const QByteArray &raw); 0073 0074 QString statusString(GitStatus s); 0075 }