Hi Junio, On Mon, 23 May 2022, Junio C Hamano wrote: > "Jeff Hostetler via GitGitGadget" <gitgitgadget@xxxxxxxxx> writes: > > A devil's advocate suggestion is to go in the completely opposite > side of the spectrum. Perhaps if we are willing to limit the tool's > utility to the tests done in this script file, it might be a good > idea to combine the latter two elements in the pipeline, i.e. > > ls | test-tool hexgrep 63 5f c3 a9 > > that exits with 0 when the output from "ls" has the 4-byte sequence, > exits with 1 when it does not, and exits with 139 when it segfauls ;-) I like the idea, but from what I recall of the Knuth-Pratt algorithm [*1*], the implementation might get a bit more involved than the current `test-hexdump.c`. With non-repetitive patterns like you wrote above, you can simply re-set the needle's offset to 0 if a mismatch was seen. It's partially-repetitive patterns such as `01 02 01 02 01 ff` that make things tricker: After encountering a `01 02 01 02 01`, if the next character is a `02`, we must not reset the needle's offset completely, as the next two characters might be `01 ff`, i.e. a match. Since the purpose of this already-long, already well-iterated patch series is not necessarily to improve the test suite in such an involved manner, it should be left as an excercise for another patch series whose purpose _is_ to improve Git's test framework. Don't get me wrong, I am very much in favor of that `hexgrep` idea. Just in its own, dedicated patch series. Ciao, Dscho Footnote *1*: I actually had to look at Wikipedia page at https://en.wikipedia.org/wiki/Knuth%E2%80%93Morris%E2%80%93Pratt_algorithm to realize that I did unjustice to James Morris by forgetting that they had discovered the algorithm independently.