Skip to content

Should we say the repository’s default branch is usually main? #20963

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wolfogre opened this issue Aug 26, 2022 · 2 comments
Closed

Should we say the repository’s default branch is usually main? #20963

wolfogre opened this issue Aug 26, 2022 · 2 comments
Labels
type/bug type/proposal The new feature has not been accepted yet but needs to be discussed first.

Comments

@wolfogre
Copy link
Member

Feature Description

Gitea tends to use main as the default branch now according to #19354, shall we update the API doc or wait until main is more popular?

"description": "The name of the commit/branch/tag. Default the repository’s default branch (usually master)",

Screenshots

No response

@wolfogre wolfogre added type/feature Completely new functionality. Can only be merged if feature freeze is not active. type/proposal The new feature has not been accepted yet but needs to be discussed first. labels Aug 26, 2022
@delvh delvh added type/bug and removed type/feature Completely new functionality. Can only be merged if feature freeze is not active. labels Aug 26, 2022
@delvh
Copy link
Member

delvh commented Aug 26, 2022

The problem is far worse than what you expected:
I just did a search where master is still used (ag 'master' | wc -l), and there are 555 instances where we still use master (some are false positives, however).
The worst thing: There is even a bug I found in cmd/hook.go where we still default to master instead of main!

@wxiaoguang
Copy link
Contributor

I just did a search where master is still used (ag 'master' | wc -l), and there are 555 instances where we still use master (some are false positives, however).

There are some cases for the master still being used:

  • test code (most cases)
  • wiki (wiki code hard-coded the master branch name)
  • mirror/pull/push (master and main are processed together)
  • the post-receive hook (below)

The worst thing: There is even a bug I found in cmd/hook.go where we still default to master instead of main!

The logic is if wasEmpty && masterPushed: then set default branch to master, it looks safe and I think it could be consider as a fallback for users who still uses "master" branch name.


I did some tests about creating an empty repo with master as the default branch and push the a git repo with main branch into it, I think in most cases it works fine. If we still need the logic like if wasEmpty && masterPushed, the related code could also be improved to cover the main branch name.

@wolfogre wolfogre closed this as not planned Won't fix, can't repro, duplicate, stale Feb 5, 2023
@go-gitea go-gitea locked and limited conversation to collaborators May 3, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
type/bug type/proposal The new feature has not been accepted yet but needs to be discussed first.
Projects
None yet
Development

No branches or pull requests

3 participants