]> git.ipfire.org Git - thirdparty/git.git/commitdiff
t1450: robustify `remove_object()`
authorJohannes Schindelin <johannes.schindelin@gmx.de>
Wed, 10 Feb 2021 18:01:29 +0000 (18:01 +0000)
committerJunio C Hamano <gitster@pobox.com>
Wed, 10 Feb 2021 20:38:00 +0000 (12:38 -0800)
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>
t/t1450-fsck.sh

index b17f5c21fbce789c9a9bdd42f2f337b24675e099..0c58cb349b6ee75214843ae2534bf9533f9831e7 100755 (executable)
@@ -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) &&