URL to tag goes to branch if they have the same name #3821

Closed
opened 2025-11-02 05:26:31 -06:00 by GiteaMirror · 2 comments
Owner

Originally created by @davidsvantesson on GitHub (Aug 22, 2019).

  • Gitea version (or commit ref): 1.10.0+dev-198-g111d31d68
  • Git version:
  • Operating system:
  • Database (use [x]):
    • PostgreSQL
    • MySQL
    • MSSQL
    • SQLite
  • Can you reproduce the bug at https://try.gitea.io:
    • Yes (provide example URL)
    • No
    • Not relevant

Description

When a branch and a tag has the same name, entering the URL to the tag shows the branch instead.

Example: https://try.gitea.io/merle_noir/TestName/src/tag/BranchAndTagNameSame is URL to tag but it shows the content of the branch with the same name.

Originally created by @davidsvantesson on GitHub (Aug 22, 2019). - Gitea version (or commit ref): 1.10.0+dev-198-g111d31d68 - Git version: - Operating system: - Database (use `[x]`): - [ ] PostgreSQL - [ ] MySQL - [ ] MSSQL - [x] SQLite - Can you reproduce the bug at https://try.gitea.io: - [x] Yes (provide example URL) - [ ] No - [ ] Not relevant ## Description When a branch and a tag has the same name, entering the URL to the tag shows the branch instead. Example: https://try.gitea.io/merle_noir/TestName/src/tag/BranchAndTagNameSame is URL to tag but it shows the content of the branch with the same name.
GiteaMirror added the type/enhancement label 2025-11-02 05:26:31 -06:00
Author
Owner

@lunny commented on GitHub (Aug 22, 2019):

What do you think the proper behaviour?

@lunny commented on GitHub (Aug 22, 2019): What do you think the proper behaviour?
Author
Owner

@davidsvantesson commented on GitHub (Aug 22, 2019):

Expected behavior:

  • {Repo}/src/branch/{refname}: 404 if branch {refname} doesn't exist. If exist show branch.
  • {Repo}/src/tag/{refname}: 404 if tag {refname} doesn't exist. If exist show tag.

Actual behavior:

  • {Repo}/src/branch/{refname}: 404 if branch {refname} doesn't exist. If exist show branch.
  • {Repo}/src/tag/{refname}: 404 if tag {refname} doesn't exist. If exist show branch (in first case, if it exist) otherwise show tag.

The reason for this is in /modules/context/repo.go, func RepoRefByType, the code first correctly determines if the branch or tag exist (depending on what is requested), but then first check if branch exist (line 610) regardless if branch or tag was requested.

@davidsvantesson commented on GitHub (Aug 22, 2019): Expected behavior: - _{Repo}/src/branch/{refname}_: 404 if branch {refname} doesn't exist. If exist show branch. - _{Repo}/src/tag/{refname}_: 404 if tag {refname} doesn't exist. If exist show tag. Actual behavior: - _{Repo}/src/branch/{refname}_: 404 if branch {refname} doesn't exist. If exist show branch. - _{Repo}/src/tag/{refname}_: 404 if tag {refname} doesn't exist. If exist show **branch (in first case, if it exist)** otherwise show tag. The reason for this is in _/modules/context/repo.go, func RepoRefByType_, the code first correctly determines if the branch or tag exist (depending on what is requested), but then first check if branch exist (line 610) regardless if branch or tag was requested.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/gitea#3821