[PATCH 1/2] t1450: robustify `remove_object()`
- From
Johannes Schindelin via GitGitGadget <gitgitgadget@gmail.com>
- Date
- Feb 10, 2021, 18:01 UTC
- Message-ID
- <24d43d121162a9052f31c760a5fc929fdaad76b5.1612980090.git.gitgitgadget@gmail.com>
- In-Reply-To
- <pull.874.git.1612980090.gitgitgadget@gmail.com>
From: Johannes Schindelin <johannes.schindelin@gmx.de>
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 <johannes.schindelin@gmx.de> --- t/t1450-fsck.sh | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-)
diff --git a/t/t1450-fsck.sh b/t/t1450-fsck.sh index 02478bc4ece2..779f700ac4a0 100755 --- a/t/t1450-fsck.sh +++ b/t/t1450-fsck.sh @@ -41,17 +41,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) &&
-- gitgitgadget