From: Siddharth Shrimali Date: Fri, 13 Mar 2026 02:58:52 GMT Subject: [PATCH v2] t0410: modernize delete_object helper Message-ID: <20260313025852.30010-1-r.siddharth.shrimali@gmail.com> In-Reply-To: <20260312125030.7799-1-r.siddharth.shrimali@gmail.com> 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 Suggested-by: Jeff King Signed-off-by: Siddharth Shrimali --- Thanks to Pushkar for initially testing the patch locally and suggesting improvements. Thanks also to Jeff, Eric, and Junio for the technical feedback regarding 'local' variables and the redundancy of 'test_path_is_file'. Changes in v2: - Added 'local' to variables and ensured they are properly quoted. - Removed 'test_path_is_file' as 'rm' provides sufficient error reporting. t/t0410-partial-clone.sh | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/t/t0410-partial-clone.sh b/t/t0410-partial-clone.sh index 2a5bdbeeb8..d36d1c3a5f 100755 --- a/t/t0410-partial-clone.sh +++ b/t/t0410-partial-clone.sh @@ -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 () { -- 2.51.2