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 <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Johannes Schindelin committed Feb 10, 2021 at 18:01 UTC 8c891eed3a89ff945b7957cdf62037b2e2b6eca7
1 file changed +6 -10
t/t1450-fsck.sh
+6 -10
@@ -40,17 +40,13 @@ test_expect_success 'HEAD is part of refs, valid objects appear valid' '
40 # specific corruption you test afterwards, lest a later test trip over
41 # it.
42
43 -test_expect_success 'setup: helpers for corruption tests' '
44 - sha1_file() {
45 - remainder=${1#??} &&
46 - firsttwo=${1%$remainder} &&
47 - echo ".git/objects/$firsttwo/$remainder"
48 - } &&
43 +sha1_file () {
44 + git rev-parse --git-path objects/$(test_oid_to_path "$1")
45 +}
46
50 - remove_object() {
51 - rm "$(sha1_file "$1")"
52 - }
53 -'
47 +remove_object () {
48 + rm "$(sha1_file "$1")"
49 +}
50
51 test_expect_success 'object with bad sha1' '
52 sha=$(echo blob | git hash-object -w --stdin) &&