Skip to content

Commit abcd998

Browse files
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.
1 parent 9b9b3d8 commit abcd998

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

sumdb/dirhash/hash.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,9 @@ type Hash func(files []string, open func(string) (io.ReadCloser, error)) (string
3333
// Hash1 is "h1:" followed by the base64-encoded SHA-256 hash of a summary
3434
// prepared as if by the Unix command:
3535
//
36-
// find . -type f | sort | sha256sum
36+
// find . -type f -printf 'prefix/%P\n' | sort | xargs sha256sum
37+
//
38+
// (where prefix is something like foo/[email protected])
3739
//
3840
// More precisely, the hashed summary contains a single line for each file in the list,
3941
// ordered by sort.Strings applied to the file names, where each line consists of

0 commit comments

Comments
 (0)