public inbox for git@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] t1006: fix %(rest) test for object names with whitespace
@ 2026-02-19 15:24 Deveshi Dwivedi
  2026-02-19 19:50 ` Junio C Hamano
  0 siblings, 1 reply; 6+ messages in thread
From: Deveshi Dwivedi @ 2026-02-19 15:24 UTC (permalink / raw)
  To: git; +Cc: Deveshi Dwivedi

The '--batch-check with %(rest)' test in run_tests() used
$object_name directly as input to git cat-file. When the
object name contained whitespace (e.g., "HEAD:path with spaces"),
this led to ambiguity between the object name and the %(rest)
placeholder.

As a result, git cat-file could not reliably determine where
the object name ended and %(rest) began.

Fix this by using the resolved object ID (OID) instead of the
raw object name as input. OIDs are hexadecimal strings and
never contain whitespace, making the split unambiguous. This
also removes the need for the existing FIXME comment and the
test_expect_failure workaround.

Signed-off-by: Deveshi Dwivedi <deveshigurgaon@gmail.com>
---
 t/t1006-cat-file.sh | 15 ++++-----------
 1 file changed, 4 insertions(+), 11 deletions(-)

diff --git a/t/t1006-cat-file.sh b/t/t1006-cat-file.sh
index 0eee3bb878..cac88acf65 100755
--- a/t/t1006-cat-file.sh
+++ b/t/t1006-cat-file.sh
@@ -194,18 +194,11 @@ $content"
 	test_cmp expect actual
     '
 
-    # FIXME: %(rest) is incompatible with object names that include whitespace,
-    # e.g. HEAD:path/to/a/file with spaces. Use the resolved OID as input to
-    # test this instead of the raw object name.
-    if echo "$object_name" | grep -q " "; then
-	test_rest=test_expect_failure
-    else
-	test_rest=test_expect_success
-    fi
-
-    $test_rest '--batch-check with %(rest)' '
+    # Use the resolved OID so %(rest) parsing is independent of whitespace
+    # in object names (e.g. HEAD:path with spaces).
+    test_expect_success '--batch-check with %(rest)' '
 	echo "$type this is some extra content" >expect &&
-	echo "$object_name    this is some extra content" |
+	echo "$oid    this is some extra content" |
 		git cat-file --batch-check="%(objecttype) %(rest)" >actual &&
 	test_cmp expect actual
     '
-- 
2.52.0.230.gd8af7cadaa


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

end of thread, other threads:[~2026-02-20 16:59 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-02-19 15:24 [PATCH] t1006: fix %(rest) test for object names with whitespace Deveshi Dwivedi
2026-02-19 19:50 ` Junio C Hamano
2026-02-19 20:23   ` Victoria Dye
2026-02-19 20:48     ` Junio C Hamano
2026-02-20  3:30       ` Junio C Hamano
2026-02-20 16:59         ` Deveshi Dwivedi

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