From: Jonathan Nieder <jrnieder@gmail.com>
To: "brian m. carlson" <sandals@crustytoothpaste.net>
Cc: git@vger.kernel.org, Jeff King <peff@peff.net>,
Duy Nguyen <pclouds@gmail.com>,
Johannes Schindelin <Johannes.Schindelin@gmx.de>,
Jonathan Tan <jonathantanmy@google.com>,
Eric Sunshine <sunshine@sunshineco.com>,
Junio C Hamano <gitster@pobox.com>
Subject: [PATCH bc/hash-independent-tests-part-4] t: decrease nesting in test_oid_to_path
Date: Wed, 7 Aug 2019 23:56:14 -0700 [thread overview]
Message-ID: <20190808065614.GA209195@google.com> (raw)
In-Reply-To: <20190628225928.622372-2-sandals@crustytoothpaste.net>
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.
[*] Fixed by v0.5.8~13 ("[EXPAND] Propagate EXP_QPAT in subevalvar, 2013-08-23).
Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
---
t/test-lib-functions.sh | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/t/test-lib-functions.sh b/t/test-lib-functions.sh
index 7860491660..de58e8b502 100644
--- a/t/test-lib-functions.sh
+++ b/t/test-lib-functions.sh
@@ -1337,7 +1337,8 @@ test_oid () {
# Insert a slash into an object ID so it can be used to reference a location
# under ".git/objects". For example, "deadbeef..." becomes "de/adbeef..".
test_oid_to_path () {
- echo "${1%${1#??}}/${1#??}"
+ local basename=${1#??}
+ echo "${1%$basename}/$basename"
}
# Choose a port number based on the test script's number and store it in
--
2.23.0.rc1.153.gdeed80330f
next prev parent reply other threads:[~2019-08-08 6:56 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-06-28 22:59 [PATCH v3 00/10] Hash-independent tests, part 4 brian m. carlson
2019-06-28 22:59 ` [PATCH v3 01/10] t: add helper to convert object IDs to paths brian m. carlson
2019-08-08 6:56 ` Jonathan Nieder [this message]
2019-08-08 9:37 ` [PATCH bc/hash-independent-tests-part-4] t: decrease nesting in test_oid_to_path Jeff King
2019-08-08 11:35 ` brian m. carlson
2019-08-08 12:58 ` SZEDER Gábor
2019-08-08 17:22 ` Junio C Hamano
2019-08-08 11:25 ` brian m. carlson
2019-06-28 22:59 ` [PATCH v3 02/10] t1410: make hash size independent brian m. carlson
2019-06-28 22:59 ` [PATCH v3 03/10] t1450: " brian m. carlson
2019-06-28 22:59 ` [PATCH v3 04/10] t5000: make hash independent brian m. carlson
2019-06-28 22:59 ` [PATCH v3 05/10] t6030: make test work with SHA-256 brian m. carlson
2019-06-28 22:59 ` [PATCH v3 06/10] t0027: make hash size independent brian m. carlson
2019-06-28 22:59 ` [PATCH v3 07/10] t0090: make test pass with SHA-256 brian m. carlson
2019-06-28 22:59 ` [PATCH v3 08/10] t1007: remove SHA1 prerequisites brian m. carlson
2019-06-28 22:59 ` [PATCH v3 09/10] t1710: make hash independent brian m. carlson
2019-06-28 22:59 ` [PATCH v3 10/10] t2203: avoid hard-coded object ID values brian m. carlson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190808065614.GA209195@google.com \
--to=jrnieder@gmail.com \
--cc=Johannes.Schindelin@gmx.de \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=jonathantanmy@google.com \
--cc=pclouds@gmail.com \
--cc=peff@peff.net \
--cc=sandals@crustytoothpaste.net \
--cc=sunshine@sunshineco.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).