Crash when changing branches #1391

Closed
opened 2025-11-02 03:59:08 -06:00 by GiteaMirror · 2 comments
Owner

Originally created by @trebonian on GitHub (Dec 20, 2017).

  • Gitea version (or commit ref): 7b28154e8b
  • 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

...

Screenshots

Originally created by @trebonian on GitHub (Dec 20, 2017). <!-- 1. Please speak English, this is the language all of us can speak and write. 2. Please ask questions or configuration/deploy problems on our Discord server (https://discord.gg/NsatcWJ) or forum (https://discourse.gitea.io). 3. Please take a moment to check that your issue doesn't already exist. 4. Please give all relevant information below for bug reports, because incomplete details will be handled as an invalid report. --> - Gitea version (or commit ref): 7b28154e8b412a7d83aa53359950cf76751e74c2 - 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 -- <path>" 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 ... ## Screenshots <!-- **If this issue involves the Web Interface, please include a screenshot** -->
GiteaMirror added the type/bug label 2025-11-02 03:59:08 -06:00
Author
Owner

@lunny commented on GitHub (Dec 20, 2017):

https://github.com/go-gitea/git/pull/98 will fix this.

@lunny commented on GitHub (Dec 20, 2017): https://github.com/go-gitea/git/pull/98 will fix this.
Author
Owner

@lunny commented on GitHub (Dec 20, 2017):

still be fixed by #3240

@lunny commented on GitHub (Dec 20, 2017): still be fixed by #3240
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/gitea#1391