]> git.ipfire.org Git - thirdparty/git.git/commitdiff
t0410: modernize delete_object helper
authorSiddharth Shrimali <r.siddharth.shrimali@gmail.com>
Fri, 13 Mar 2026 05:31:59 +0000 (11:01 +0530)
committerJunio C Hamano <gitster@pobox.com>
Fri, 13 Mar 2026 15:20:15 +0000 (08:20 -0700)
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>
t/t0410-partial-clone.sh

index 2a5bdbeeb87f6e86599489b818b870eccf8cee17..52e19728a3fca03496900e62a73b1088825bf6c0 100755 (executable)
@@ -11,7 +11,10 @@ test_description='partial clone'
 GIT_TEST_COMMIT_GRAPH=0
 
 delete_object () {
-       rm $1/.git/objects/$(echo $2 | sed -e 's|^..|&/|')
+       local repo="$1"
+       local obj="$2"
+       local path="$repo/.git/objects/$(test_oid_to_path "$obj")" &&
+       rm "$path"
 }
 
 pack_as_from_promisor () {