Thread (1 message) 1 message, 1 author, 2019-06-10

Re: [PATCH 2/3] t: add t0016-oidmap.sh

From: Junio C Hamano <hidden>
Date: 2019-06-10 16:46:36

SZEDER Gábor [off-list ref] writes:
So, 'test oidmap' from the previous patch prints the value we want to
check with:

    printf("%u\n", sha1hash(oid.hash));

First, since object ids inherently make more sense as hex values, it
would be more appropriate to print that hash with the '%x' format
specifier, and then we wouldn't need Perl's hex() anymore, and thus
could swap the order of the first four bytes in oidmap's hash without
relying on Perl, e.g. with:

  sed -e 's/^\(..\)\(..\)\(..\)\(..\).*/\4\3\2\1/'

Second, and more importantly, the need for swapping the byte order
indicates that this test would fail on big-endian systems, I'm afraid.
So I think we need an additional bswap32() on the printing side, and
then could further simplify 'test_oidhash':
Yup, if we are doing an ad-hoc t/helper/ command, we should strive
to make it help the driving scripts around it to become simpler, and
your suggestion to do s/%u/%x/ is a good example of doing so.

Thanks for a dose of sanity.  The goal of the series may be
worthwhile, and helping hands in improving its execution is very
much appreciated.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help