Closed
Description
- Gitea version (or commit ref): 7b28154
- Git version: 2.15.0
- Operating system: Alpine Linux
- Database (use
[x]
):- PostgreSQL
- MySQL
- MSSQL
- [ X] SQLite
- Can you reproduce the bug at https://try.gitea.io:
- Yes (provide example URL)
- [ X] No
- Not relevant
- Log gist:
Description
Apologies for not making a small reproducible example.
The new git commit info from Faster Commit Lookup #91 causes crashes when changing branches in gitea from the default branch.
In the file vendor/code.gitea.io/git/commit_info.go:
This is because the "git rev-list HEAD -- " uses the HEAD from the default branch. If the entryPath contains a file, or directory that is not present in the default branch - then the rev-list returns no files and this causes a crash.
I believe the line should be changed from:
command := NewCommand("rev-list", "-1", "HEAD", "--", entryPath)
to:
command := NewCommand("rev-list", "-1", state.headCommit.ID.String(), "--", entryPath)
Making this change seems to have fixed the issue for me
...