| 111 | } |
| 112 | |
| 113 | void parseTree( |
| 114 | FileSystemObjectSink & sink, |
| 115 | const CanonPath & sinkPath, |
| 116 | Source & source, |
| 117 | HashAlgorithm hashAlgo, |
| 118 | fun<SinkHook> hook, |
| 119 | const ExperimentalFeatureSettings & xpSettings) |
| 120 | { |
| 121 | const unsigned long long size = std::stoi(getStringUntil(source, 0)); |
| 122 | unsigned long long left = size; |
| 123 | |
| 124 | sink.createDirectory(sinkPath); |
| 125 | |
| 126 | while (left) { |
| 127 | std::string perms = getStringUntil(source, ' '); |
| 128 | left -= perms.size(); |
| 129 | left -= 1; |
| 130 | |
| 131 | RawMode rawMode = std::stoi(perms, 0, 8); |
| 132 | auto modeOpt = decodeMode(rawMode); |
| 133 | if (!modeOpt) |
| 134 | throw Error("Unknown Git permission: %o", rawMode); |
| 135 | auto mode = std::move(*modeOpt); |
| 136 | |
| 137 | std::string name = getStringUntil(source, '\0'); |
| 138 | left -= name.size(); |
| 139 | left -= 1; |
| 140 | |
| 141 | const auto hashSize = regularHashSize(hashAlgo); |
| 142 | std::string hashs = getString(source, hashSize); |
| 143 | left -= hashSize; |
| 144 | |
| 145 | if (!(hashAlgo == HashAlgorithm::SHA1 || hashAlgo == HashAlgorithm::SHA256)) { |
| 146 | throw Error("Unsupported hash algorithm for git trees: %s", printHashAlgo(hashAlgo)); |
| 147 | } |
| 148 | |
| 149 | Hash hash(hashAlgo); |
| 150 | std::copy(hashs.begin(), hashs.end(), hash.hash); |
| 151 | |
| 152 | hook( |
| 153 | CanonPath{name}, |
| 154 | TreeEntry{ |
| 155 | .mode = mode, |
| 156 | .hash = hash, |
| 157 | }); |
| 158 | } |
| 159 | } |
| 160 | |
| 161 | ObjectType parseObjectType(Source & source, const ExperimentalFeatureSettings & xpSettings) |
| 162 | { |
no test coverage detected