git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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

From
Junio C Hamano <gitster@pobox.com>
Date
Jun 10, 2019, 16:46 UTC
Message-ID
<xmqqftoho0bg.fsf@gitster-ct.c.googlers.com>
In-Reply-To
<20190609092259.GB24208@szeder.dev>
SZEDER Gábor <szeder.dev@gmail.com> writes:
Show 17 quoted lines
> 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.

Previous: Christian CouderNext: Jeff King
Message 8 of 14 in “Test oidmap”
  1. 0/3 Test oidmapChristian Couder, Jun 9, 2019
  2. 1/3 t/helper: add test-oidmap.cChristian Couder, Jun 9, 2019
  3. 2/3 t: add t0016-oidmap.shChristian Couder, Jun 9, 2019
  4. SZEDER GáborJun 9, 2019
  5. Christian CouderJun 9, 2019
  6. SZEDER GáborJun 9, 2019
  7. Christian CouderJun 9, 2019
  8. Junio C HamanoJun 10, 2019
  9. Jeff KingJun 13, 2019
  10. SZEDER GáborJun 13, 2019
  11. Jeff KingJun 13, 2019
  12. Junio C HamanoJun 13, 2019
  13. Christian CouderJun 14, 2019
  14. 3/3 oidmap: use sha1hash() instead of static hash() functionChristian Couder, Jun 9, 2019

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.