From 0f2cf531f705d370321843e5ba9135b2ebdb5d19 Mon Sep 17 00:00:00 2001 From: Vincent Ambo Date: Sun, 17 May 2020 16:31:57 +0100 Subject: style(3p/nix): Reformat project in Google C++ style Reformatted with: fd . -e hh -e cc | xargs clang-format -i --- third_party/nix/src/nix/add-to-store.cc | 90 ++++++++++++++------------------- 1 file changed, 38 insertions(+), 52 deletions(-) (limited to 'third_party/nix/src/nix/add-to-store.cc') diff --git a/third_party/nix/src/nix/add-to-store.cc b/third_party/nix/src/nix/add-to-store.cc index e86b96e3f3f2..cc85cc02ea6e 100644 --- a/third_party/nix/src/nix/add-to-store.cc +++ b/third_party/nix/src/nix/add-to-store.cc @@ -1,61 +1,47 @@ +#include "archive.hh" #include "command.hh" #include "common-args.hh" #include "store-api.hh" -#include "archive.hh" using namespace nix; -struct CmdAddToStore : MixDryRun, StoreCommand -{ - Path path; - std::optional namePart; - - CmdAddToStore() - { - expectArg("path", &path); - - mkFlag() - .longName("name") - .shortName('n') - .description("name component of the store path") - .labels({"name"}) - .dest(&namePart); - } - - std::string name() override - { - return "add-to-store"; - } - - std::string description() override - { - return "add a path to the Nix store"; - } - - Examples examples() override - { - return { - }; - } - - void run(ref store) override - { - if (!namePart) namePart = baseNameOf(path); - - StringSink sink; - dumpPath(path, sink); - - ValidPathInfo info; - info.narHash = hashString(htSHA256, *sink.s); - info.narSize = sink.s->size(); - info.path = store->makeFixedOutputPath(true, info.narHash, *namePart); - info.ca = makeFixedOutputCA(true, info.narHash); - - if (!dryRun) - store->addToStore(info, sink.s); - - std::cout << fmt("%s\n", info.path); - } +struct CmdAddToStore : MixDryRun, StoreCommand { + Path path; + std::optional namePart; + + CmdAddToStore() { + expectArg("path", &path); + + mkFlag() + .longName("name") + .shortName('n') + .description("name component of the store path") + .labels({"name"}) + .dest(&namePart); + } + + std::string name() override { return "add-to-store"; } + + std::string description() override { return "add a path to the Nix store"; } + + Examples examples() override { return {}; } + + void run(ref store) override { + if (!namePart) namePart = baseNameOf(path); + + StringSink sink; + dumpPath(path, sink); + + ValidPathInfo info; + info.narHash = hashString(htSHA256, *sink.s); + info.narSize = sink.s->size(); + info.path = store->makeFixedOutputPath(true, info.narHash, *namePart); + info.ca = makeFixedOutputCA(true, info.narHash); + + if (!dryRun) store->addToStore(info, sink.s); + + std::cout << fmt("%s\n", info.path); + } }; static RegisterCommand r1(make_ref()); -- cgit 1.4.1