[PR #113] [MERGED] GetCommit() returns a ErrNotExist if short commit ID does not exists #117

Closed
opened 2026-02-16 10:24:10 -05:00 by yindo · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/go-gitea/git/pull/113
Author: @agrn
Created: 4/14/2018
Status: Merged
Merged: 2/2/2019
Merged by: @techknowlogick

Base: masterHead: al/short-commit-error


📝 Commits (2)

  • ceeb8f4 GetCommit() returns a ErrNotExist if short commit ID does not exists
  • d08a180 GetCommit(): change the comparison for short commit messages

📊 Changes

1 file changed (+3 additions, -0 deletions)

View changed files

📝 repo_commit.go (+3 -0)

📄 Description

Currently, GetCommit() returns a generic error if a short commit ID
does not exists in a repository.

When a commit is not found by git-rev-parse, it returns an errors
which contains "fatal: ambiguous argument". GetCommit() now search if
the error contains this string, and, if it does, returns an
ErrNotExist.

The idea is to allow commits to be accessed from gitea with a short
commit ID. Without this change, it would return a 500 Internal Server
Error when a short ID does not exists in the repository.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/go-gitea/git/pull/113 **Author:** [@agrn](https://github.com/agrn) **Created:** 4/14/2018 **Status:** ✅ Merged **Merged:** 2/2/2019 **Merged by:** [@techknowlogick](https://github.com/techknowlogick) **Base:** `master` ← **Head:** `al/short-commit-error` --- ### 📝 Commits (2) - [`ceeb8f4`](https://github.com/go-gitea/git/commit/ceeb8f4dc9ddf75b122d8aab87449289735e32a2) GetCommit() returns a ErrNotExist if short commit ID does not exists - [`d08a180`](https://github.com/go-gitea/git/commit/d08a18027bd1b20936968413c0a4dd9051dd6f73) GetCommit(): change the comparison for short commit messages ### 📊 Changes **1 file changed** (+3 additions, -0 deletions) <details> <summary>View changed files</summary> 📝 `repo_commit.go` (+3 -0) </details> ### 📄 Description Currently, GetCommit() returns a generic error if a short commit ID does not exists in a repository. When a commit is not found by git-rev-parse, it returns an errors which contains "fatal: ambiguous argument". GetCommit() now search if the error contains this string, and, if it does, returns an ErrNotExist. The idea is to allow commits to be accessed from gitea with a short commit ID. Without this change, it would return a 500 Internal Server Error when a short ID does not exists in the repository. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
yindo added the pull-request label 2026-02-16 10:24:10 -05:00
yindo closed this issue 2026-02-16 10:24:10 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: go-gitea/git#117