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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 2019-08-08 at 06:56:14, Jonathan Nieder wrote:
> 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

Attachment: signature.asc
Description: PGP signature


[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux