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

Re: [PATCH bc/hash-independent-tests-part-4] t: decrease nesting in test_oid_to_path

From
brian m. carlson <sandals@crustytoothpaste.net>
Date
Aug 8, 2019, 11:25 UTC
Message-ID
<20190808112545.GJ118825@genre.crustytoothpaste.net>
In-Reply-To
<20190808065614.GA209195@google.com>
On 2019-08-08 at 06:56:14, Jonathan Nieder wrote:
Show 31 quoted lines
> t1410.3 ("corrupt and checks") fails when run using dash versions
> before 0.5.8, with a cryptic message:
> 
> 	mv: cannot stat '.git/objects//e84adb2704cbd49549e52169b4043871e13432': No such file or directory
> 
> The function generating that path:
> 
> 	test_oid_to_path () {
> 		echo "${1%${1#??}}/${1#??}"
> 	}
> 
> which is supposed to produce a result like
> 
> 	12/3456789....
> 
> But a dash bug[*] causes it to instead expand to
> 
> 	/3456789...
> 
> The stream of symbols that makes up this function is hard for humans
> to follow, too.  The complexity mostly comes from the repeated use of
> the expression ${1#??} for the basename of the loose object.  Use a
> variable instead --- nowadays, the dialect of shell used by Git
> permits local variables, so this is cheap.
> 
> An alternative way to work around [*] is to remove the double-quotes
> around test_oid_to_path's return value.  That makes the expression
> easier for dash to read, but harder for humans.  Let's prefer the
> rephrasing that's helpful for humans, too.
> 
> Noticed by building on Ubuntu trusty, which uses dash 0.5.7.

This seems like a sane, well-reasoned fix. I don't know if we care about building on Ubuntu trusty (since it is EOL), but if we do, then we should definitely take this patch.

I agree it makes things easier to follow as well, which is also nice, and it preserves the shell-only nature that's so desirable on Windows.

-- 
brian m. carlson: Houston, Texas, US
OpenPGP: https://keybase.io/bk2204
Previous: Junio C HamanoNext: brian m. carlson
Message 8 of 17 in “Hash-independent tests, part 4”
  1. 00/10 Hash-independent tests, part 4brian m. carlson, Jun 28, 2019
  2. 01/10 t: add helper to convert object IDs to pathsbrian m. carlson, Jun 28, 2019
  3. t: decrease nesting in test_oid_to_pathJonathan Nieder, Aug 8, 2019
  4. Jeff KingAug 8, 2019
  5. brian m. carlsonAug 8, 2019
  6. SZEDER GáborAug 8, 2019
  7. Junio C HamanoAug 8, 2019
  8. brian m. carlsonAug 8, 2019
  9. 03/10 t1450: make hash size independentbrian m. carlson, Jun 28, 2019
  10. 04/10 t5000: make hash independentbrian m. carlson, Jun 28, 2019
  11. 02/10 t1410: make hash size independentbrian m. carlson, Jun 28, 2019
  12. 05/10 t6030: make test work with SHA-256brian m. carlson, Jun 28, 2019
  13. 06/10 t0027: make hash size independentbrian m. carlson, Jun 28, 2019
  14. 07/10 t0090: make test pass with SHA-256brian m. carlson, Jun 28, 2019
  15. 08/10 t1007: remove SHA1 prerequisitesbrian m. carlson, Jun 28, 2019
  16. 09/10 t1710: make hash independentbrian m. carlson, Jun 28, 2019
  17. 10/10 t2203: avoid hard-coded object ID valuesbrian m. carlson, Jun 28, 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.