1
0
Fork 0
mirror of https://github.com/NixOS/nix synced 2025-06-25 10:41:16 +02:00

Add newHashAllowEmpty helper function

This replaces the copy&paste with a helper function in hash.hh.
This commit is contained in:
Matthew Bauer 2020-06-12 10:09:42 -05:00
parent 19aa892f20
commit b260c9ee03
6 changed files with 24 additions and 38 deletions

View file

@ -205,6 +205,16 @@ Hash::Hash(const std::string & s, HashType type)
throw BadHash("hash '%s' has wrong length for hash type '%s'", s, printHashType(type));
}
Hash newHashAllowEmpty(std::string hashStr, HashType ht)
{
if (hashStr.empty())
{
Hash h(ht);
warn("found empty hash, assuming you wanted '%s'", h.to_string());
} else
return Hash(hashStr, ht);
}
union Ctx
{