Skip to content

Commit d39cef3

Browse files
SiddharthShrimaligitster
authored andcommitted
t0410: modernize delete_object helper
The delete_object helper currently relies on a manual sed command to calculate object paths. This works, but it's a bit brittle and forces us to maintain shell logic that Git's own test suite can already handle more elegantly. Switch to 'test_oid_to_path' to let Git handle the path logic. This makes the helper hash independent, which is much cleaner than manual string manipulation. While at it, use 'local' to declare helper-specific variables and quote them to follow Git's coding style. This prevents them from leaking into global shell scope and avoids potential naming conflicts with other parts of the test suite. Helped-by: Pushkar Singh <pushkarkumarsingh1970@gmail.com> Suggested-by: Jeff King <peff@peff.net> Signed-off-by: Siddharth Shrimali <r.siddharth.shrimali@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent 67ad421 commit d39cef3

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

t/t0410-partial-clone.sh

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,10 @@ test_description='partial clone'
1111
GIT_TEST_COMMIT_GRAPH=0
1212

1313
delete_object () {
14-
rm $1/.git/objects/$(echo $2 | sed -e 's|^..|&/|')
14+
local repo="$1"
15+
local obj="$2"
16+
local path="$repo/.git/objects/$(test_oid_to_path "$obj")" &&
17+
rm "$path"
1518
}
1619

1720
pack_as_from_promisor () {

0 commit comments

Comments
 (0)