* [PATCH] t3200: replace hardcoded null OID with $ZERO_OID
@ 2026-03-11 10:58 Siddharth Shrimali
2026-03-11 11:20 ` Patrick Steinhardt
0 siblings, 1 reply; 5+ messages in thread
From: Siddharth Shrimali @ 2026-03-11 10:58 UTC (permalink / raw)
To: git; +Cc: gitster, ps, r.siddharth.shrimali
Taking into consideration the SHA-256 transition, the test suite must
be updated to support the length of the underlying hash algorithm.
Tests that rely on hardcoded 40-character strings to represent the
null object ID will fail when run in a SHA-256 environment, which
expects a 64-character hash.
Replace the hardcoded 40-zero string in the 'git branch --merged' test
with the '$ZERO_OID' variable which is provided by the test framework.
This ensures the test dynamically adapts to the correct null OID
length and functions correctly regardless of the active hash
algorithm.
Signed-off-by: Siddharth Shrimali <r.siddharth.shrimali@gmail.com>
---
t/t3200-branch.sh | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/t/t3200-branch.sh b/t/t3200-branch.sh
index c58e505c43..ed317a75f5 100755
--- a/t/t3200-branch.sh
+++ b/t/t3200-branch.sh
@@ -1494,7 +1494,7 @@ test_expect_success 'refuse --edit-description on unborn branch for now' '
'
test_expect_success '--merged catches invalid object names' '
- test_must_fail git branch --merged 0000000000000000000000000000000000000000
+ test_must_fail git branch --merged $ZERO_OID
'
test_expect_success '--list during rebase' '
--
2.51.2
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] t3200: replace hardcoded null OID with $ZERO_OID
2026-03-11 10:58 [PATCH] t3200: replace hardcoded null OID with $ZERO_OID Siddharth Shrimali
@ 2026-03-11 11:20 ` Patrick Steinhardt
2026-03-11 17:41 ` [PATCH v2] " Siddharth Shrimali
0 siblings, 1 reply; 5+ messages in thread
From: Patrick Steinhardt @ 2026-03-11 11:20 UTC (permalink / raw)
To: Siddharth Shrimali; +Cc: git, gitster
On Wed, Mar 11, 2026 at 04:28:10PM +0530, Siddharth Shrimali wrote:
> Taking into consideration the SHA-256 transition, the test suite must
> be updated to support the length of the underlying hash algorithm.
> Tests that rely on hardcoded 40-character strings to represent the
> null object ID will fail when run in a SHA-256 environment, which
> expects a 64-character hash.
>
> Replace the hardcoded 40-zero string in the 'git branch --merged' test
> with the '$ZERO_OID' variable which is provided by the test framework.
> This ensures the test dynamically adapts to the correct null OID
> length and functions correctly regardless of the active hash
> algorithm.
>
> Signed-off-by: Siddharth Shrimali <r.siddharth.shrimali@gmail.com>
> ---
> t/t3200-branch.sh | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/t/t3200-branch.sh b/t/t3200-branch.sh
> index c58e505c43..ed317a75f5 100755
> --- a/t/t3200-branch.sh
> +++ b/t/t3200-branch.sh
> @@ -1494,7 +1494,7 @@ test_expect_success 'refuse --edit-description on unborn branch for now' '
> '
>
> test_expect_success '--merged catches invalid object names' '
> - test_must_fail git branch --merged 0000000000000000000000000000000000000000
> + test_must_fail git branch --merged $ZERO_OID
> '
I expect that the failure reason before and after this change is
different, right? And likewise, I expect that before the change, the
failure with SHA1 is likely different than the one with SHA256.
Taking a peek, that's indeed the case. With SHA1 we get:
error: option `merged' must point to a commit
But with SHA256 we get:
fatal: malformed object name 0000000000000000000000000000000000000000
So the only reason why we didn't detect that the test is broken with
SHA256 is that we didn't verify the error message. Do we maybe want to
make the test a bit less fragile by using something like `test_grep
"must point to a commit"` on the error message?
Patrick
^ permalink raw reply [flat|nested] 5+ messages in thread* [PATCH v2] t3200: replace hardcoded null OID with $ZERO_OID
2026-03-11 11:20 ` Patrick Steinhardt
@ 2026-03-11 17:41 ` Siddharth Shrimali
2026-03-11 21:17 ` brian m. carlson
2026-03-12 6:07 ` Patrick Steinhardt
0 siblings, 2 replies; 5+ messages in thread
From: Siddharth Shrimali @ 2026-03-11 17:41 UTC (permalink / raw)
To: Patrick Steinhardt; +Cc: git, Junio C Hamano, Siddharth Shrimali
To support the SHA-256 transition, replace the hardcoded 40-zero string
in 'git branch --merged' with '$ZERO_OID'. The current 40-character
string causes the test to fail prematurely in SHA-256 environments
because Git identifies a "malformed object name" (due to the 40 vs 64
character mismatch) before it even validates the object type.
By using '$ZERO_OID', we ensure the hash length is always correct for
the active algorithm. Additionally, use 'test_grep' to verify the
"must point to a commit" error message, ensuring the test validates
the object type logic rather than just string syntax.
Suggested-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Siddharth Shrimali <r.siddharth.shrimali@gmail.com>
---
Changes in V2:
- Updated the test to capture stderr and use 'test_grep' to verify the
error message. This ensures the failure is due to the object type
check ("must point to a commit") rather than a hash length mismatch.
- Improved the commit message to add detail to the 40 vs 64 character
mismatch and the "premature failure" in SHA-256.
t/t3200-branch.sh | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/t/t3200-branch.sh b/t/t3200-branch.sh
index c58e505c43..e7829c2c4b 100755
--- a/t/t3200-branch.sh
+++ b/t/t3200-branch.sh
@@ -1494,7 +1494,8 @@ test_expect_success 'refuse --edit-description on unborn branch for now' '
'
test_expect_success '--merged catches invalid object names' '
- test_must_fail git branch --merged 0000000000000000000000000000000000000000
+ test_must_fail git branch --merged $ZERO_OID 2>err &&
+ test_grep "must point to a commit" err
'
test_expect_success '--list during rebase' '
--
2.51.2
^ permalink raw reply related [flat|nested] 5+ messages in thread* Re: [PATCH v2] t3200: replace hardcoded null OID with $ZERO_OID
2026-03-11 17:41 ` [PATCH v2] " Siddharth Shrimali
@ 2026-03-11 21:17 ` brian m. carlson
2026-03-12 6:07 ` Patrick Steinhardt
1 sibling, 0 replies; 5+ messages in thread
From: brian m. carlson @ 2026-03-11 21:17 UTC (permalink / raw)
To: Siddharth Shrimali; +Cc: Patrick Steinhardt, git, Junio C Hamano
[-- Attachment #1: Type: text/plain, Size: 805 bytes --]
On 2026-03-11 at 17:41:20, Siddharth Shrimali wrote:
> diff --git a/t/t3200-branch.sh b/t/t3200-branch.sh
> index c58e505c43..e7829c2c4b 100755
> --- a/t/t3200-branch.sh
> +++ b/t/t3200-branch.sh
> @@ -1494,7 +1494,8 @@ test_expect_success 'refuse --edit-description on unborn branch for now' '
> '
>
> test_expect_success '--merged catches invalid object names' '
> - test_must_fail git branch --merged 0000000000000000000000000000000000000000
> + test_must_fail git branch --merged $ZERO_OID 2>err &&
> + test_grep "must point to a commit" err
> '
Yeah, this seems reasonable. It's failing, but for the wrong reasons,
so checking the error message in addition to switching to `$ZERO_OID`
seems like the right thing to do.
--
brian m. carlson (they/them)
Toronto, Ontario, CA
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 262 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v2] t3200: replace hardcoded null OID with $ZERO_OID
2026-03-11 17:41 ` [PATCH v2] " Siddharth Shrimali
2026-03-11 21:17 ` brian m. carlson
@ 2026-03-12 6:07 ` Patrick Steinhardt
1 sibling, 0 replies; 5+ messages in thread
From: Patrick Steinhardt @ 2026-03-12 6:07 UTC (permalink / raw)
To: Siddharth Shrimali; +Cc: git, Junio C Hamano
On Wed, Mar 11, 2026 at 11:11:20PM +0530, Siddharth Shrimali wrote:
> To support the SHA-256 transition, replace the hardcoded 40-zero string
> in 'git branch --merged' with '$ZERO_OID'. The current 40-character
> string causes the test to fail prematurely in SHA-256 environments
> because Git identifies a "malformed object name" (due to the 40 vs 64
> character mismatch) before it even validates the object type.
>
> By using '$ZERO_OID', we ensure the hash length is always correct for
> the active algorithm. Additionally, use 'test_grep' to verify the
> "must point to a commit" error message, ensuring the test validates
> the object type logic rather than just string syntax.
>
> Suggested-by: Patrick Steinhardt <ps@pks.im>
"Suggested-by" is a bit strong, as it indicates that I have suggested
to work on this in the first place. "Helped-by" would have been a bit of
a better fit.
No reason to reroll though, this patch looks good to me. Thanks!
Patrick
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2026-03-12 6:07 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-11 10:58 [PATCH] t3200: replace hardcoded null OID with $ZERO_OID Siddharth Shrimali
2026-03-11 11:20 ` Patrick Steinhardt
2026-03-11 17:41 ` [PATCH v2] " Siddharth Shrimali
2026-03-11 21:17 ` brian m. carlson
2026-03-12 6:07 ` Patrick Steinhardt
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox