# \#JM9 tests git cat-file commit \<sha\> (in Go)

**URL:** <https://forum.codecrafters.io/t/jm9-tests-git-cat-file-commit-sha-in-go/9255>\
**Category:** Challenges\
**Tags:** challenge:git\
**Created:** [April 23, 2025, 7:22pm UTC](https://forum.codecrafters.io/t/jm9-tests-git-cat-file-commit-sha-in-go/9255 "2025-04-23T19:22:35Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![ptrhcpang](https://yyz1.discourse-cdn.com/flex003/user_avatar/forum.codecrafters.io/ptrhcpang/32/1054_2.png) [@ptrhcpang](https://forum.codecrafters.io/u/ptrhcpang)\
**Post date:** [April 23, 2025, 7:22pm UTC](https://forum.codecrafters.io/t/jm9-tests-git-cat-file-commit-sha-in-go/9255/1 "2025-04-23T19:22:36Z")

</div>

I’m stuck on Stage #JM9.

I believe I have written a commit, and it generates a commit sha. However, when I push my code to Codecrafters, I get the following odd error:

 ![Screenshot from 2025-04-23 21-04-45](https://canada1.discourse-cdn.com/flex003/uploads/codecrafters/original/2X/9/92c90d8a6d586814642026db6d9a5e5e183097c6.png)

It appears that my program is generating a commit sha correctly. If I run an additional snippet of code (that will cause the test to fail) trying to retrieve and read the object stored using the commit sha generated, I get output that begins with “commit \0tree \<tree\_sha\>…”, and “\<tree\_sha\>” is not all zeros.

My guess was that the tester is using the sha key generated by the commit step to retrieve and read a commit object to see if the tree sha at the top of that file is the same as the one used to make the commit. But somehow the tester is reading an all-zero key. I do not really understand what is going on. Regardless of whether the commit file is written entirely correctly, I do not see why the tree\_sha that is read is all zeros.

Would love to be enlightened here. Cheers!

---

<div class="post-metadata">

**Author:** ![andy1li](https://yyz1.discourse-cdn.com/flex003/user_avatar/forum.codecrafters.io/andy1li/32/10_2.png) [@andy1li](https://forum.codecrafters.io/u/andy1li)\
**Post date:** [April 24, 2025, 7:57am UTC](https://forum.codecrafters.io/t/jm9-tests-git-cat-file-commit-sha-in-go/9255/4 "2025-04-24T07:57:33Z")

</div>

Hey @ptrhcpang, there might be a few things at play here. The first one I noticed is that `tree_sha` is not in the correct format:

 ![image](https://canada1.discourse-cdn.com/flex003/uploads/codecrafters/original/2X/2/2e3a58714193c27870c4cfde20c5d745a069f895.png)

It should be in hex format, not binary:

 ![image](https://canada1.discourse-cdn.com/flex003/uploads/codecrafters/original/2X/d/de609d0d87ecaa1f0bf33c3ba6b0a3d3a36ca161.png)

---

<div class="post-metadata">

**Author:** ![ptrhcpang](https://yyz1.discourse-cdn.com/flex003/user_avatar/forum.codecrafters.io/ptrhcpang/32/1054_2.png) [@ptrhcpang](https://forum.codecrafters.io/u/ptrhcpang)\
**Post date:** [April 24, 2025, 11:12am UTC](https://forum.codecrafters.io/t/jm9-tests-git-cat-file-commit-sha-in-go/9255/6 "2025-04-24T11:12:23Z")

</div>

Ah, I see, thank you so much! I misunderstood — I though the tree\_sha has to be converted back into binary and goes in as a 20-character byte string. I have further problems, but at least this one seems resolved. Thank you!!

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex003/uploads/codecrafters/original/3X/7/0/700657133935c15703e22c7c8870394f6e6dc27d.svg) [@system](https://forum.codecrafters.io/u/system)\
**Post date:** [April 29, 2025, 11:12am UTC](https://forum.codecrafters.io/t/jm9-tests-git-cat-file-commit-sha-in-go/9255/7 "2025-04-29T11:12:45Z")

</div>

Closed on April 29, 2025, 11:12am UTC

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.
