# Question about #JM9 and \`git show\`

**URL:** <https://forum.codecrafters.io/t/question-about-jm9-and-git-show/4712>\
**Category:** Challenges\
**Tags:** challenge:git\
**Created:** [February 7, 2025, 10:17am UTC](https://forum.codecrafters.io/t/question-about-jm9-and-git-show/4712 "2025-02-07T10:17:19Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![eaverdeja](https://yyz1.discourse-cdn.com/flex003/user_avatar/forum.codecrafters.io/eaverdeja/32/4167_2.png) [@eaverdeja](https://forum.codecrafters.io/u/eaverdeja)\
**Post date:** [February 7, 2025, 10:17am UTC](https://forum.codecrafters.io/t/question-about-jm9-and-git-show/4712/1 "2025-02-07T10:17:19Z")

</div>

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:

```auto
$ (.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](https://github.com/eaverdeja/codecrafters-git-python)

---

<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:** [February 7, 2025, 5:47pm UTC](https://forum.codecrafters.io/t/question-about-jm9-and-git-show/4712/3 "2025-02-07T17:47:16Z")

</div>

Hi @eaverdeja, your `commit-tree` seems to be working fine:

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

> fatal: unable to read tree b9a79a4d7bd66d94054627b64f20d3c2496749b3

Could you try looking into `.git/objects/b9/a79a4d7bd66d94054627b64f20d3c2496749b3`?

---

<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:** [February 7, 2025, 5:52pm UTC](https://forum.codecrafters.io/t/question-about-jm9-and-git-show/4712/4 "2025-02-07T17:52:41Z")

</div>

The issue seems to be caused by `write-tree`:

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

---

<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:** [February 7, 2025, 5:57pm UTC](https://forum.codecrafters.io/t/question-about-jm9-and-git-show/4712/5 "2025-02-07T17:57:17Z")

</div>

Looks like children of the root were not written to disk by `write-tree`:

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

---

<div class="post-metadata">

**Author:** ![eaverdeja](https://yyz1.discourse-cdn.com/flex003/user_avatar/forum.codecrafters.io/eaverdeja/32/4167_2.png) [@eaverdeja](https://forum.codecrafters.io/u/eaverdeja)\
**Post date:** [February 7, 2025, 10:11pm UTC](https://forum.codecrafters.io/t/question-about-jm9-and-git-show/4712/7 "2025-02-07T22:11:40Z")

</div>

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.

```auto
$ 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)

```

---

<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:** [February 7, 2025, 10:16pm UTC](https://forum.codecrafters.io/t/question-about-jm9-and-git-show/4712/8 "2025-02-07T22:16:26Z")

</div>

Could you try locating `f7208da358e6ca5f313f75fa765c7a677bf9d8da` by running `git ls-tree [tree-hash]` for the known trees?

For example:

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

---

<div class="post-metadata">

**Author:** ![eaverdeja](https://yyz1.discourse-cdn.com/flex003/user_avatar/forum.codecrafters.io/eaverdeja/32/4167_2.png) [@eaverdeja](https://forum.codecrafters.io/u/eaverdeja)\
**Post date:** [February 7, 2025, 10:25pm UTC](https://forum.codecrafters.io/t/question-about-jm9-and-git-show/4712/9 "2025-02-07T22:25:13Z")

</div>

I managed to recreate the issue in a smaller repository.

I followed similar steps from your previous post:

1. Created a `foobar` dir
2. Git init
3. Touched a file `foo` with contents `foo!`
4. Used `git commit-tree` for the 1st commit
5. Touched a file `bar` with contents `bar!`
6. Used my own `commit-tree` for the 2nd commit
7. `git show` screams saying it can’t `bar`’s hash

 ![image](https://canada1.discourse-cdn.com/flex003/uploads/codecrafters/original/2X/3/3169b1e1308eb4f9b24f335383ac1f83098ce354.jpeg)

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.

```auto
(.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

```

---

<div class="post-metadata">

**Author:** ![eaverdeja](https://yyz1.discourse-cdn.com/flex003/user_avatar/forum.codecrafters.io/eaverdeja/32/4167_2.png) [@eaverdeja](https://forum.codecrafters.io/u/eaverdeja)\
**Post date:** [February 7, 2025, 10:28pm UTC](https://forum.codecrafters.io/t/question-about-jm9-and-git-show/4712/10 "2025-02-07T22:28:08Z")

</div>

Hmmm something is def wrong with `bar` 😅

```auto
(.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

```

---

<div class="post-metadata">

**Author:** ![eaverdeja](https://yyz1.discourse-cdn.com/flex003/user_avatar/forum.codecrafters.io/eaverdeja/32/4167_2.png) [@eaverdeja](https://forum.codecrafters.io/u/eaverdeja)\
**Post date:** [February 7, 2025, 10:36pm UTC](https://forum.codecrafters.io/t/question-about-jm9-and-git-show/4712/11 "2025-02-07T22:36:51Z")

</div>

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!

---

<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:** [February 12, 2025, 10:37pm UTC](https://forum.codecrafters.io/t/question-about-jm9-and-git-show/4712/12 "2025-02-12T22:37:19Z")

</div>

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