From 8c891eed3a89ff945b7957cdf62037b2e2b6eca7 Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Wed, 10 Feb 2021 18:01:29 +0000 Subject: t1450: robustify `remove_object()` This function can be simplified by using the `test_oid_to_path()` helper, which incidentally also makes it more robust by not relying on the exact file system layout of the loose object files. While at it, do not define those functions in a test case, it buys us nothing. Signed-off-by: Johannes Schindelin Signed-off-by: Junio C Hamano --- t/t1450-fsck.sh | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) (limited to 't/t1450-fsck.sh') diff --git a/t/t1450-fsck.sh b/t/t1450-fsck.sh index b17f5c21fb..0c58cb349b 100755 --- a/t/t1450-fsck.sh +++ b/t/t1450-fsck.sh @@ -40,17 +40,13 @@ test_expect_success 'HEAD is part of refs, valid objects appear valid' ' # specific corruption you test afterwards, lest a later test trip over # it. -test_expect_success 'setup: helpers for corruption tests' ' - sha1_file() { - remainder=${1#??} && - firsttwo=${1%$remainder} && - echo ".git/objects/$firsttwo/$remainder" - } && +sha1_file () { + git rev-parse --git-path objects/$(test_oid_to_path "$1") +} - remove_object() { - rm "$(sha1_file "$1")" - } -' +remove_object () { + rm "$(sha1_file "$1")" +} test_expect_success 'object with bad sha1' ' sha=$(echo blob | git hash-object -w --stdin) && -- cgit v1.2.3