public inbox for git@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] t0410: modernize delete_object helper
@ 2026-03-12 12:50 Siddharth Shrimali
  2026-03-12 14:17 ` Pushkar Singh
                   ` (3 more replies)
  0 siblings, 4 replies; 13+ messages in thread
From: Siddharth Shrimali @ 2026-03-12 12:50 UTC (permalink / raw)
  To: git
  Cc: gitster, jonathantanmy, christian.couder, karthik.188,
	r.siddharth.shrimali

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


^ permalink raw reply related	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2026-03-18  2:37 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-12 12:50 [PATCH] t0410: modernize delete_object helper Siddharth Shrimali
2026-03-12 14:17 ` Pushkar Singh
2026-03-12 19:05 ` Eric Sunshine
2026-03-12 19:09   ` Junio C Hamano
2026-03-12 20:33 ` Jeff King
2026-03-12 22:03   ` Junio C Hamano
2026-03-13  2:58 ` [PATCH v2] " Siddharth Shrimali
2026-03-13  4:58   ` Jeff King
2026-03-13 15:29     ` Junio C Hamano
2026-03-18  2:37       ` Jeff King
2026-03-13  5:31   ` [PATCH v3] " Siddharth Shrimali
2026-03-13 15:20     ` Junio C Hamano
2026-03-13 15:19   ` [PATCH v2] " Junio C Hamano

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox