From abcd998d737f9cf77ac9f7b3154f78f350ed533e Mon Sep 17 00:00:00 2001 From: Charles Duffy Date: Tue, 22 Mar 2022 17:53:34 -0500 Subject: [PATCH] Hash1: Make comment more precisely describe how to emulate logic from shell The shell command previously given as an example emits paths starting with `./`, and without an added prefix. Also, previously, `sha256` was run against the sorted list of filenames, not against the _contents_ of those files (`xargs` is needed to perform the latter). This does introduce a GNUism; working with POSIX `find` might involve adding a `sed` pipeline element. --- sumdb/dirhash/hash.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/sumdb/dirhash/hash.go b/sumdb/dirhash/hash.go index ef5df6f..96f2d86 100644 --- a/sumdb/dirhash/hash.go +++ b/sumdb/dirhash/hash.go @@ -33,7 +33,9 @@ type Hash func(files []string, open func(string) (io.ReadCloser, error)) (string // Hash1 is "h1:" followed by the base64-encoded SHA-256 hash of a summary // prepared as if by the Unix command: // -// find . -type f | sort | sha256sum +// find . -type f -printf 'prefix/%P\n' | sort | xargs sha256sum +// +// (where prefix is something like foo/bar@v1.2.3) // // More precisely, the hashed summary contains a single line for each file in the list, // ordered by sort.Strings applied to the file names, where each line consists of