git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH] t0410: modernize delete_object helper

From
Siddharth Shrimali <r.siddharth.shrimali@gmail.com>
Date
Mar 12, 2026, 12:50 UTC
Message-ID
<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 we're at it, add a call to 'test_path_is_file' so that the test fails early and clearly if we try to delete an object that isn't there, rather than failing silently.

Signed-off-by: Siddharth Shrimali <r.siddharth.shrimali@gmail.com>
---
 t/t0410-partial-clone.sh | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/t/t0410-partial-clone.sh b/t/t0410-partial-clone.sh
index 2a5bdbeeb8..eca113f0f8 100755
--- a/t/t0410-partial-clone.sh
+++ b/t/t0410-partial-clone.sh
@@ -11,7 +11,11 @@ test_description='partial clone'
 GIT_TEST_COMMIT_GRAPH=0
 
 delete_object () {
-	rm $1/.git/objects/$(echo $2 | sed -e 's|^..|&/|')
+	repo=$1
+	obj=$2
+	path="$repo/.git/objects/$(test_oid_to_path $obj)" &&
+	test_path_is_file "$path" &&
+	rm "$path"
 }
 
 pack_as_from_promisor () {
-- 
2.51.2
Next: Pushkar Singh
Message 1 of 13 in “t0410: modernize delete_object helper”
  1. t0410: modernize delete_object helperSiddharth Shrimali, Mar 12, 2026
  2. Pushkar SinghMar 12, 2026
  3. Eric SunshineMar 12, 2026
  4. Junio C HamanoMar 12, 2026
  5. Jeff KingMar 12, 2026
  6. Junio C HamanoMar 12, 2026
  7. t0410: modernize delete_object helperSiddharth Shrimali, Mar 13, 2026
  8. Jeff KingMar 13, 2026
  9. Junio C HamanoMar 13, 2026
  10. Jeff KingMar 18, 2026
  11. t0410: modernize delete_object helperSiddharth Shrimali, Mar 13, 2026
  12. Junio C HamanoMar 13, 2026
  13. Junio C HamanoMar 13, 2026

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.