diff options
author | Eelco Dolstra <edolstra@gmail.com> | 2022-04-14 14:55:27 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-04-14 14:55:27 +0200 |
commit | d6effddd3b9657988d1e86e1258c33de6ae4af2b (patch) | |
tree | a330ae3334165b5430b394eafaf7f3d2bebf9dc7 /src/libfetchers/git.cc | |
parent | 0e58affd3967d113e43811311db9ee090778a756 (diff) | |
parent | 2769e43f61d827e1b8fe46257450986d76319243 (diff) |
Merge pull request #6387 from Uthar/fix
assert hash types for Git and Mercurial
Diffstat (limited to 'src/libfetchers/git.cc')
-rw-r--r-- | src/libfetchers/git.cc | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/src/libfetchers/git.cc b/src/libfetchers/git.cc index 91dd332a2..34b1342a0 100644 --- a/src/libfetchers/git.cc +++ b/src/libfetchers/git.cc @@ -187,8 +187,16 @@ struct GitInputScheme : InputScheme if (submodules) cacheType += "-submodules"; if (allRefs) cacheType += "-all-refs"; + auto checkHashType = [&](const std::optional<Hash> & hash) + { + if (hash.has_value() && !(hash->type == htSHA1 || hash->type == htSHA256)) + throw Error("Hash '%s' is not supported by Git. Supported types are sha1 and sha256.", hash->to_string(Base16, true)); + }; + auto getLockedAttrs = [&]() { + checkHashType(input.getRev()); + return Attrs({ {"type", cacheType}, {"name", name}, |