mirror of
https://github.com/go-gitea/git.git
synced 2026-07-19 14:33:37 -04:00
[PR #39] [MERGED] Return empty list of branches if repository is bare. #47
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/go-gitea/git/pull/39
Author: @cybe
Created: 3/24/2017
Status: ✅ Merged
Merged: 5/26/2017
Merged by: @lunny
Base:
master← Head:handle_bare_repos📝 Commits (1)
98a4dfbReturn empty list of branches if repository is bare.📊 Changes
1 file changed (+5 additions, -9 deletions)
View changed files
📝
repo_branch.go(+5 -9)📄 Description
This pull request enables the git module to handle bare (empty) repositories when getting all branches of a repository. This failed previously, because the command to retrieve the branches
git show-ref --headsexited with return code1which resulted in a non-nil error.The new implementation uses
git for-each-refto iterate over all branches and outputs nothing in case the repository is bare while using a return code of0. As the output format changed (and now is much simpler), the parsing of that output had to be changed as well.This is in preparation of a coming pull request to gitea itself to gracefully handle bare repositories on various API operations instead of throwing HTTP-500 errors.
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.