#39448·gitea

Commit API returns the commit ID as the tree SHA

Author: HardMax71Created Sep 26, 2026Updated Sep 26, 2026
Labelstype/bug

Gitea Version

1.27.0+dev-954-g1f3981a301 on gitea.com; the code is the same on main (ea91028).

What happened?

GET /repos/{owner}/{repo}/git/commits/{sha} puts the commit's own ID in commit.tree.sha, and commit.tree.url points at /git/trees/{commit sha}. It should be the ID of the commit's tree, which is what GitHub returns there. The commit list endpoint goes through the same converter and has the same problem.

On gitea.com:

$ git clone --depth 1 https://gitea.com/gitea/awesome-gitea.git && cd awesome-gitea
$ git rev-parse HEAD HEAD^{tree}
7535fa0448a93af02bbc6076e752e5a230fc3bca
5d2bc2741c1bd612253765c601e83c2d52aad4c3
$ curl -s https://gitea.com/api/v1/repos/gitea/awesome-gitea/git/commits/7535fa0448a93af02bbc6076e752e5a230fc3bca | jq -r .commit.tree.sha
7535fa0448a93af02bbc6076e752e5a230fc3bca

The cause is ToCommit in services/convert/git_commit.go, which fills Tree from commit.ID instead of commit.TreeID. A client that checks the reported tree against the tree it reads from the repository sees a mismatch on every commit.

How are you running Gitea?

Reproduced on gitea.com as shown above.