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

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:

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!

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:

It should be in hex format, not binary:

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!!

1 Like

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