Skip to content

Commit 8c891ee

Browse files
dschogitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 773e25a commit 8c891ee

File tree

1 file changed

+6
-10
lines changed

1 file changed

+6
-10
lines changed

t/t1450-fsck.sh

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -40,17 +40,13 @@ test_expect_success 'HEAD is part of refs, valid objects appear valid' '
4040
# specific corruption you test afterwards, lest a later test trip over
4141
# it.
4242

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+
}
4946

50-
remove_object() {
51-
rm "$(sha1_file "$1")"
52-
}
53-
'
47+
remove_object () {
48+
rm "$(sha1_file "$1")"
49+
}
5450

5551
test_expect_success 'object with bad sha1' '
5652
sha=$(echo blob | git hash-object -w --stdin) &&

0 commit comments

Comments
 (0)