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:
parent
19aa892f20
commit
b260c9ee03
6 changed files with 24 additions and 38 deletions
|
@ -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
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue