1
1
Fork 0
mirror of https://github.com/NixOS/nix.git synced 2025-11-22 18:29:36 +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

@ -12,21 +12,23 @@
#include <iostream>
#include <cerrno>
namespace nix::fs { using namespace std::filesystem; }
namespace nix::fs {
using namespace std::filesystem;
}
using namespace nix;
std::string deleteOlderThan;
bool dryRun = false;
/* If `-d' was specified, remove all old generations of all profiles.
* Of course, this makes rollbacks to before this point in time
* impossible. */
void removeOldGenerations(std::filesystem::path dir)
{
if (access(dir.string().c_str(), R_OK) != 0) return;
if (access(dir.string().c_str(), R_OK) != 0)
return;
bool canWrite = access(dir.string().c_str(), W_OK) == 0;
@ -41,7 +43,8 @@ void removeOldGenerations(std::filesystem::path dir)
try {
link = readLink(path);
} catch (std::filesystem::filesystem_error & e) {
if (e.code() == std::errc::no_such_file_or_directory) continue;
if (e.code() == std::errc::no_such_file_or_directory)
continue;
throw;
}
if (link.find("link") != std::string::npos) {
@ -58,7 +61,7 @@ void removeOldGenerations(std::filesystem::path dir)
}
}
static int main_nix_collect_garbage(int argc, char * * argv)
static int main_nix_collect_garbage(int argc, char ** argv)
{
{
bool removeOld = false;
@ -70,12 +73,13 @@ static int main_nix_collect_garbage(int argc, char * * argv)
showManPage("nix-collect-garbage");
else if (*arg == "--version")
printVersion("nix-collect-garbage");
else if (*arg == "--delete-old" || *arg == "-d") removeOld = true;
else if (*arg == "--delete-old" || *arg == "-d")
removeOld = true;
else if (*arg == "--delete-older-than") {
removeOld = true;
deleteOlderThan = getArg(*arg, arg, end);
}
else if (*arg == "--dry-run") dryRun = true;
} else if (*arg == "--dry-run")
dryRun = true;
else if (*arg == "--max-freed")
options.maxFreed = std::max(getIntArg<int64_t>(*arg, arg, end, true), (int64_t) 0);
else