My tests are passing and I’m ready to move on to the final boss, but I have a question about this stage first. The instructions state that:
To verify your changes, the tester will read the commit object from the .git directory. It’ll use the git show command to do this.
However, when I try to do this, I’m faced with the following error:
$ (.venv) ➜ codecrafters-git-python git:(master) ✗ ./your_program.sh commit-tree f4da0838ff124bba2d5cde001f06bbc385f8ac2b -p 6319856f159ed3cd81accc2b90f0588f5c69b92d -m foo
9bb4ff8afb2938012d54d827e63fb65ab699b7da
$ (.venv) ➜ codecrafters-git-python git:(master) ✗ git show 9bb4ff8afb2938012d54d827e63fb65ab699b7da
fatal: unable to read tree b9a79a4d7bd66d94054627b64f20d3c2496749b3
Should this work locally? What am I missing here?
Here’s my code btw:
https://github.com/eaverdeja/codecrafters-git-python
Hi @eaverdeja , your commit-tree seems to be working fine:
fatal: unable to read tree b9a79a4d7bd66d94054627b64f20d3c2496749b3
Could you try looking into .git/objects/b9/a79a4d7bd66d94054627b64f20d3c2496749b3?
The issue seems to be caused by write-tree:
Looks like children of the root were not written to disk by write-tree:
1 Like
Ah! Silly mistake on my side, thank you for catching it.
It’s almost perfect now, expect for a strange alert at the top. I’m not sure what this hash represents. I tried looking in .git/objects but didn’t find anything.
$ git show 2592405c5231b7ffa064954be7977610c9a7c8fc
fatal: unable to read f7208da358e6ca5f313f75fa765c7a677bf9d8da
commit 2592405c5231b7ffa064954be7977610c9a7c8fc
Author: me <me@gmail.com>
Date: Fri Feb 7 07:24:22 2025 -0300
foo
(END)
1 Like
andy1li
February 7, 2025, 10:16pm
8
Could you try locating f7208da358e6ca5f313f75fa765c7a677bf9d8da by running git ls-tree [tree-hash] for the known trees?
For example:
I managed to recreate the issue in a smaller repository.
I followed similar steps from your previous post:
Created a foobar dir
Git init
Touched a file foo with contents foo!
Used git commit-tree for the 1st commit
Touched a file bar with contents bar!
Used my own commit-tree for the 2nd commit
git show screams saying it can’t bar’s hash
Since there were only 2 trees it was easy to find the faulty object. But I still can’t figure out what’s the issue.
(.venv) ➜ foobar git:(main) ✗ g ls-tree 0ed3b46ade56ae892ab7888621471fce26509a64
100644 blob 929efb30534598535198700b994ee438d441d1af foo
(.venv) ➜ foobar git:(main) ✗ g ls-tree 4e2e00e78d5e3ba51ad9f1846890328fb74d94a3
100644 blob e50a49f9558d09d4d3bfc108363bb24c127ed263 bar
100644 blob 929efb30534598535198700b994ee438d441d1af foo
Hmmm something is def wrong with bar
(.venv) ➜ foobar git:(main) ✗ g cat-file blob 929efb30534598535198700b994ee438d441d1af
foo!
(.venv) ➜ foobar git:(main) ✗ g cat-file blob e50a49f9558d09d4d3bfc108363bb24c127ed263
fatal: git cat-file e50a49f9558d09d4d3bfc108363bb24c127ed263: bad file
Ok, I got it. I was not writing the blob objects to disk when handling write-tree. It’s clearer to me how it should work.
Thanks again for your help debugging Andy!
1 Like
system
Closed
February 12, 2025, 10:37pm
12
This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.