From fd47f76da9752d0bec35e58525e5aacfd3e7dd26 Mon Sep 17 00:00:00 2001 From: Yueh-Shun Li Date: Mon, 26 Feb 2024 02:04:20 +0800 Subject: [PATCH] treewide: hash type -> hash algorithm "hash type" -> "hash algorithm" in all comments, documentation, and messages. ht -> ha, [Hh]ashType -> [HhashAlgo] for all local variables and function arguments. No API change is made. Continuation of 5334c9c792a2 and 837b889c4154. --- src/libstore/content-address.cc | 6 +++--- src/libstore/content-address.hh | 8 ++++---- src/libstore/derivations.cc | 2 +- src/libstore/globals.hh | 4 ++-- src/libutil/file-content-address.cc | 4 ++-- src/libutil/file-content-address.hh | 4 ++-- src/libutil/hash.cc | 2 +- src/libutil/hash.hh | 4 ++-- 8 files changed, 17 insertions(+), 17 deletions(-) diff --git a/src/libstore/content-address.cc b/src/libstore/content-address.cc index 2091f8e0267..4e3d2f64dc9 100644 --- a/src/libstore/content-address.cc +++ b/src/libstore/content-address.cc @@ -111,10 +111,10 @@ static std::pair parseContentAddressMethodP } auto parseHashAlgorithm_ = [&](){ - auto hashTypeRaw = splitPrefixTo(rest, ':'); - if (!hashTypeRaw) + auto hashAlgoRaw = splitPrefixTo(rest, ':'); + if (!hashAlgoRaw) throw UsageError("content address hash must be in form ':', but found: %s", wholeInput); - HashAlgorithm hashAlgo = parseHashAlgo(*hashTypeRaw); + HashAlgorithm hashAlgo = parseHashAlgo(*hashAlgoRaw); return hashAlgo; }; diff --git a/src/libstore/content-address.hh b/src/libstore/content-address.hh index 80538df5018..5925f8e01a2 100644 --- a/src/libstore/content-address.hh +++ b/src/libstore/content-address.hh @@ -91,17 +91,17 @@ struct ContentAddressMethod std::string_view renderPrefix() const; /** - * Parse a content addressing method and hash type. + * Parse a content addressing method and hash algorithm. */ static std::pair parseWithAlgo(std::string_view rawCaMethod); /** - * Render a content addressing method and hash type in a + * Render a content addressing method and hash algorithm in a * nicer way, prefixing both cases. * * The rough inverse of `parse()`. */ - std::string renderWithAlgo(HashAlgorithm ht) const; + std::string renderWithAlgo(HashAlgorithm ha) const; /** * Get the underlying way to content-address file system objects. @@ -127,7 +127,7 @@ struct ContentAddressMethod * ‘text:sha256:’ * * - `FixedIngestionMethod`: - * ‘fixed:::’ + * ‘fixed:::’ */ struct ContentAddress { diff --git a/src/libstore/derivations.cc b/src/libstore/derivations.cc index 36042c06c39..305ed5b4291 100644 --- a/src/libstore/derivations.cc +++ b/src/libstore/derivations.cc @@ -701,7 +701,7 @@ DerivationType BasicDerivation::type() const floatingHashAlgo = dof.hashAlgo; } else { if (*floatingHashAlgo != dof.hashAlgo) - throw Error("all floating outputs must use the same hash type"); + throw Error("all floating outputs must use the same hash algorithm"); } }, [&](const DerivationOutput::Deferred &) { diff --git a/src/libstore/globals.hh b/src/libstore/globals.hh index 8330d6571d5..e6544976a5a 100644 --- a/src/libstore/globals.hh +++ b/src/libstore/globals.hh @@ -1094,8 +1094,8 @@ public: this, {}, "hashed-mirrors", R"( A list of web servers used by `builtins.fetchurl` to obtain files by - hash. Given a hash type *ht* and a base-16 hash *h*, Nix will try to - download the file from *hashed-mirror*/*ht*/*h*. This allows files to + hash. Given a hash algorithm *ha* and a base-16 hash *h*, Nix will try to + download the file from *hashed-mirror*/*ha*/*h*. This allows files to be downloaded even if they have disappeared from their original URI. For example, given an example mirror `http://tarballs.nixos.org/`, when building the derivation diff --git a/src/libutil/file-content-address.cc b/src/libutil/file-content-address.cc index 6753e0f490b..2339024a270 100644 --- a/src/libutil/file-content-address.cc +++ b/src/libutil/file-content-address.cc @@ -63,10 +63,10 @@ void restorePath( HashResult hashPath( SourceAccessor & accessor, const CanonPath & path, - FileIngestionMethod method, HashAlgorithm ht, + FileIngestionMethod method, HashAlgorithm ha, PathFilter & filter) { - HashSink sink { ht }; + HashSink sink { ha }; dumpPath(accessor, path, sink, method, filter); return sink.finish(); } diff --git a/src/libutil/file-content-address.hh b/src/libutil/file-content-address.hh index 41f23f2af16..9a7dae8c6a8 100644 --- a/src/libutil/file-content-address.hh +++ b/src/libutil/file-content-address.hh @@ -63,11 +63,11 @@ void restorePath( * Compute the hash of the given file system object according to the * given method. * - * The hash is defined as (essentially) hashString(ht, dumpPath(path)). + * The hash is defined as (essentially) hashString(ha, dumpPath(path)). */ HashResult hashPath( SourceAccessor & accessor, const CanonPath & path, - FileIngestionMethod method, HashAlgorithm ht, + FileIngestionMethod method, HashAlgorithm ha, PathFilter & filter = defaultPathFilter); } diff --git a/src/libutil/hash.cc b/src/libutil/hash.cc index d067da969b0..d4c9d65337b 100644 --- a/src/libutil/hash.cc +++ b/src/libutil/hash.cc @@ -274,7 +274,7 @@ Hash newHashAllowEmpty(std::string_view hashStr, std::optional ha { if (hashStr.empty()) { if (!ha) - throw BadHash("empty hash requires explicit hash type"); + throw BadHash("empty hash requires explicit hash algorithm"); Hash h(*ha); warn("found empty hash, assuming '%s'", h.to_string(HashFormat::SRI, true)); return h; diff --git a/src/libutil/hash.hh b/src/libutil/hash.hh index f7e8eb265f0..e14aae43c08 100644 --- a/src/libutil/hash.hh +++ b/src/libutil/hash.hh @@ -58,7 +58,7 @@ struct Hash * Parse the hash from a string representation in the format * "[:]" or "-" (a * Subresource Integrity hash expression). If the 'type' argument - * is not present, then the hash type must be specified in the + * is not present, then the hash algorithm must be specified in the * string. */ static Hash parseAny(std::string_view s, std::optional optAlgo); @@ -200,7 +200,7 @@ std::optional parseHashFormatOpt(std::string_view hashFormatName); std::string_view printHashFormat(HashFormat hashFormat); /** - * Parse a string representing a hash type. + * Parse a string representing a hash algorithm. */ HashAlgorithm parseHashAlgo(std::string_view s);