Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add option to generate hashes from list of files #971

Open
wants to merge 8 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,14 @@ tmp*
tests/*.unicode
tests/unicode_test*
*.txt
!CMakeLists.txt
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There may be a topic about improving the .gitignore content,
but I would prefer to keep it separate from this topic (i.e. a different PR),
so that we can then focus the review on why the .gitignore would benefit an update.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shall i just revert and repush - or some rebase type thing (which is where I have previously created some unlikley tangles due to my newness with using git)?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In theory, one should go back to the commit that made the unwanted change,
and either remove it from the chain if that's all it does,
or modify it to remove the change, if it's part of a larger commit, and rebase everything on top of it.

But playing with the block chain can be complex and error prone.
So at this point, it's also somewhat simpler to just erase the unwanted changes manually and make that a new commit.

What matter is that, as a whole, this multi-commits PR doesn't modify .gitignore (and we can have a separate PR for that).

*.xxhsum

# editor artifacts
.clang_complete
*.swp
.vscode/
.vs/

# Doxygen
doxygen/
29 changes: 25 additions & 4 deletions cli/xxhsum.1.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ SYNOPSIS
--------

`xxhsum` [*OPTION*]... [*FILE*]...

`xxhsum -b` [*OPTION*]...

`xxh32sum` is equivalent to `xxhsum -H0`,
Expand Down Expand Up @@ -56,16 +57,23 @@ OPTIONS
* `-h`, `--help`:
Displays help and exits

### The following options are useful only when verifying checksums (-c):
### The following options are useful only when using lists in *FILE* (-c and -g):

* `-c`, `--check` *FILE*:
Read xxHash sums from *FILE* and check them

* `-g`, `--generate` *FILE*:
Read filenames from *FILE* and generate hashes for them.
Valid *FILE*s have one filename per line, which can include embedded spaces, etc with no need for quotes, escapes, etc.
Note that a line commencing with '\\' will enable the convention used in the encoding of filenames against output hashes,
whereby subsequent \\\\, \n and \r seqeuences are converted to the single
character 0x5C, 0x0A and 0x0D respectively.

* `-q`, `--quiet`:
Don't print OK for each successfully verified file
Don't print OK for each successfully processed line of *FILE*

* `--strict`:
Return an error code if any line in the file is invalid,
Return an error code if any line in *FILE** is invalid,
not just if some checksums are wrong.
This policy is disabled by default,
though UI will prompt an informational message
Expand All @@ -75,7 +83,7 @@ OPTIONS
Don't output anything. Status code shows success.

* `-w`, `--warn`:
Emit a warning message about each improperly formatted checksum line.
Emit a warning message about each improperly formatted line in *FILE*.

### The following options are useful only benchmark purpose:

Expand Down Expand Up @@ -119,6 +127,19 @@ Read xxHash sums from specific files and check them

$ xxhsum -c xyz.xxh32 qux.xxh64

Produce a list of files, then generate hashes for that list

$ find . -type f -name '*.[ch]' > c-files.txt
$ xxhsum --quiet -g c-files.txt

Read the list of files from standard input to avoid the need for an intermediate file

$ find . -type f -name '*.[ch]' | xxhsum --quiet -g -

Note that if shell expansion, length of argument list, clarity of use of spaces in filenames, etc allow it then the same output as the previous example can be generated like this

$ xxhsum `find . -name '*.[ch]'`

Benchmark xxHash algorithm.
By default, `xxhsum` benchmarks xxHash main variants
on a synthetic sample of 100 KB,
Expand Down
Loading
Loading