MCPcopy Create free account
hub / github.com/TortoiseGit/TortoiseGit / ParserFromLsFile

Method ParserFromLsFile

src/Git/TGitPath.cpp:1046–1101  ·  view source on GitHub ↗

similar code in CGit::ParseConflictHashesFromLsFile

Source from the content-addressed store, hash-verified

1044
1045// similar code in CGit::ParseConflictHashesFromLsFile
1046int CTGitPathList::ParserFromLsFile(const BYTE_VECTOR& out)
1047{
1048 size_t pos = 0;
1049 const size_t end = out.size();
1050 CTGitPath path;
1051 this->Clear();
1052 while (pos < end)
1053 {
1054 const size_t lineStart = pos;
1055
1056 // m_Action is never used and propably never worked (needs to be set after path.SetFromGit)
1057 // also dropped LOGACTIONS_CACHE for 'H'
1058 // path.m_Action=path.ParserAction(out[pos]);
1059 pos = out.find(' ', pos); // advance to mode
1060 if (pos == CGitByteArray::npos)
1061 return -1;
1062
1063 const size_t modestart = pos + 1;
1064
1065 pos = out.find(' ', pos + 1); // advance to hash
1066 if (pos == CGitByteArray::npos)
1067 return -1;
1068
1069 pos = out.find(' ', pos + 1); // advance to Stage
1070 if (pos == CGitByteArray::npos)
1071 return -1;
1072
1073 const size_t stagestart = pos + 1;
1074
1075 pos = out.find('\t', pos + 1); // advance to filename
1076 if (pos == CGitByteArray::npos)
1077 return -1;
1078
1079 ++pos;
1080 const size_t fileNameEnd = out.find(0, pos);
1081 if (fileNameEnd == CGitByteArray::npos || fileNameEnd == pos || pos - lineStart != strlen("H 100644 ") + 2 * GIT_HASH_SIZE + strlen(" 0\t")) // <tag> <mode> <object> <stage>\t<file>
1082 return -1;
1083 CString pathstring = CUnicodeUtils::GetUnicode(std::string_view(&out[pos], fileNameEnd - pos));
1084 // SetFromGit resets the path
1085 path.SetFromGit(pathstring, (strtol(&out[modestart], nullptr, 8) & S_IFDIR) == S_IFDIR);
1086 if (strtol(&out[stagestart], nullptr, 10) != 0)
1087 {
1088 if (!IsEmpty() && path == m_paths[m_paths.size() - 1])
1089 {
1090 pos = out.findNextString(pos);
1091 continue;
1092 }
1093 path.m_Action = CTGitPath::LOGACTIONS_UNMERGED;
1094 }
1095
1096 this->AddPath(path);
1097
1098 pos=out.findNextString(pos);
1099 }
1100 return 0;
1101}
1102
1103void CTGitPathList::UpdateStagingStatusFromPath(const CString& path, CTGitPath::StagingStatus status)

Callers 3

TESTFunction · 0.80
GetInitAddListMethod · 0.80
GetWorkingTreeChangesMethod · 0.80

Calls 6

ClearMethod · 0.95
AddPathMethod · 0.95
SetFromGitMethod · 0.80
findNextStringMethod · 0.80
sizeMethod · 0.45
findMethod · 0.45

Tested by 1

TESTFunction · 0.64