1
1
Fork 0
mirror of https://github.com/NixOS/nix.git synced 2025-12-19 07:21:07 +01:00

Apply clang-format universally.

* It is tough to contribute to a project that doesn't use a formatter,
* It is extra hard to contribute to a project which has configured the formatter, but ignores it for some files
* Code formatting makes it harder to hide obscure / weird bugs by accident or on purpose,

Let's rip the bandaid off?

Note that PRs currently in flight should be able to be merged relatively easily by applying `clang-format` to their tip prior to merge.
This commit is contained in:
Graham Christensen 2025-07-18 12:47:27 -04:00
parent 41bf87ec70
commit e4f62e4608
587 changed files with 23258 additions and 23135 deletions

View file

@ -25,7 +25,6 @@ FileSerialisationMethod parseFileSerialisationMethod(std::string_view input)
throw UsageError("Unknown file serialiation method '%s', expect `flat` or `nar`", input);
}
FileIngestionMethod parseFileIngestionMethod(std::string_view input)
{
if (input == "git") {
@ -39,7 +38,6 @@ FileIngestionMethod parseFileIngestionMethod(std::string_view input)
}
}
std::string_view renderFileSerialisationMethod(FileSerialisationMethod method)
{
switch (method) {
@ -52,14 +50,12 @@ std::string_view renderFileSerialisationMethod(FileSerialisationMethod method)
}
}
std::string_view renderFileIngestionMethod(FileIngestionMethod method)
{
switch (method) {
case FileIngestionMethod::Flat:
case FileIngestionMethod::NixArchive:
return renderFileSerialisationMethod(
static_cast<FileSerialisationMethod>(method));
return renderFileSerialisationMethod(static_cast<FileSerialisationMethod>(method));
case FileIngestionMethod::Git:
return "git";
default:
@ -67,12 +63,7 @@ std::string_view renderFileIngestionMethod(FileIngestionMethod method)
}
}
void dumpPath(
const SourcePath & path,
Sink & sink,
FileSerialisationMethod method,
PathFilter & filter)
void dumpPath(const SourcePath & path, Sink & sink, FileSerialisationMethod method, PathFilter & filter)
{
switch (method) {
case FileSerialisationMethod::Flat:
@ -84,12 +75,7 @@ void dumpPath(
}
}
void restorePath(
const Path & path,
Source & source,
FileSerialisationMethod method,
bool startFsync)
void restorePath(const Path & path, Source & source, FileSerialisationMethod method, bool startFsync)
{
switch (method) {
case FileSerialisationMethod::Flat:
@ -101,22 +87,15 @@ void restorePath(
}
}
HashResult hashPath(
const SourcePath & path,
FileSerialisationMethod method, HashAlgorithm ha,
PathFilter & filter)
HashResult hashPath(const SourcePath & path, FileSerialisationMethod method, HashAlgorithm ha, PathFilter & filter)
{
HashSink sink { ha };
HashSink sink{ha};
dumpPath(path, sink, method, filter);
return sink.finish();
}
std::pair<Hash, std::optional<uint64_t>> hashPath(
const SourcePath & path,
FileIngestionMethod method, HashAlgorithm ht,
PathFilter & filter)
std::pair<Hash, std::optional<uint64_t>>
hashPath(const SourcePath & path, FileIngestionMethod method, HashAlgorithm ht, PathFilter & filter)
{
switch (method) {
case FileIngestionMethod::Flat:
@ -130,4 +109,4 @@ std::pair<Hash, std::optional<uint64_t>> hashPath(
assert(false);
}
}
} // namespace nix