diff options
author | Eelco Dolstra <edolstra@gmail.com> | 2020-06-26 08:46:46 +0200 |
---|---|---|
committer | Eelco Dolstra <edolstra@gmail.com> | 2020-06-26 08:46:46 +0200 |
commit | adf2fbbdc2c94644b0d1023d844c7dc0e485a20f (patch) | |
tree | 5999d2c223cb24402995747d79a3de6d6aaebb73 /src/nix/hash.cc | |
parent | 09fc06daab280735dd2ec94276f00a9c5bffd9b2 (diff) | |
parent | b7ccf7ae2af3d7eaf3696358ecbbce5a2bcfe652 (diff) |
Merge remote-tracking branch 'origin/master' into flakes
Diffstat (limited to 'src/nix/hash.cc')
-rw-r--r-- | src/nix/hash.cc | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/src/nix/hash.cc b/src/nix/hash.cc index 7f646ad53..b94751e45 100644 --- a/src/nix/hash.cc +++ b/src/nix/hash.cc @@ -1,5 +1,6 @@ #include "command.hh" #include "hash.hh" +#include "content-address.hh" #include "legacy.hh" #include "shared.hh" #include "references.hh" @@ -83,12 +84,12 @@ static RegisterCommand r2("hash-path", [](){ return make_ref<CmdHash>(FileIngest struct CmdToBase : Command { Base base; - HashType ht = htUnknown; + std::optional<HashType> ht; std::vector<std::string> args; CmdToBase(Base base) : base(base) { - addFlag(Flag::mkHashTypeFlag("type", &ht)); + addFlag(Flag::mkHashTypeOptFlag("type", &ht)); expectArgs("strings", &args); } @@ -136,8 +137,6 @@ static int compatNixHash(int argc, char * * argv) else if (*arg == "--type") { string s = getArg(*arg, arg, end); ht = parseHashType(s); - if (ht == htUnknown) - throw UsageError("unknown hash type '%1%'", s); } else if (*arg == "--to-base16") op = opTo16; else if (*arg == "--to-base32") op = opTo32; |