Commit Search is Returning Incorrect Results #9503

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

Originally created by @115ek on GitHub (Sep 3, 2022).

Description

The commit search in a repository is not working as expected. It is not respecting the checkbox to search "All Branches", instead it always searches all branches.
Example:

Branch main :

image

Branch test (containing one additional commit)

image

When searching for this additional commit (78b2fc0b51d7245ee02bf506b250fbe641785d3f) while being on branch main, the search still returns it although it is not part of this branch:
image

The endpoint returning the wrong result seems to be:
gitea | 2022/09/03 08:36:43 [6312f5fb] router: completed GET /tester/test_repo/commits/branch/main/search?q=78b2fc0b51d7245ee02bf506b250fbe641785d3f for 172.18.0.1:46558, 200 OK in 22.9ms @ repo/commit.go:37(repo.RefCommits)

I was also able to reproduce the behaviour on the gitea demo website: https://try.gitea.io/115ek/commit_search

Gitea Version

1.18.0+dev-372-g96a9e15df (docker)

Can you reproduce the bug on the Gitea demo site?

Yes

Log Gist

No response

Screenshots

No response

Git Version

2.36.2, Wire Protocol Version 2 Enabled

Operating System

Gitea running as Docker container

How are you running Gitea?

Running with docker using the following docker-compose file. Started with docker compose up

version: "3"

networks:
  gitea:
    external: false

services:
  server:
    image: gitea/gitea:dev
    container_name: gitea
    environment:
      - USER_UID=1000
      - USER_GID=1000
    restart: always
    networks:
      - gitea
    volumes:
      - ./gitea:/data
      - /etc/timezone:/etc/timezone:ro
      - /etc/localtime:/etc/localtime:ro
    ports:
      - "3000:3000"
      - "222:22"

Database

SQLite

Originally created by @115ek on GitHub (Sep 3, 2022). ### Description The commit search in a repository is not working as expected. It is not respecting the checkbox to search "All Branches", instead it always searches all branches. Example: ### Branch _main_ : ![image](https://user-images.githubusercontent.com/11771774/188258723-0f932456-6ba3-4cfb-acf9-1bc0cac5a02b.png) ### Branch _test_ (containing one additional commit) ![image](https://user-images.githubusercontent.com/11771774/188258767-897704a3-bafb-44b5-a4a7-886549b8bbed.png) When searching for this additional commit (78b2fc0b51d7245ee02bf506b250fbe641785d3f) while being on branch main, the search still returns it although it is not part of this branch: ![image](https://user-images.githubusercontent.com/11771774/188258827-95f748ae-80a6-4b0a-85c5-b23bf111ccb0.png) The endpoint returning the wrong result seems to be: `gitea | 2022/09/03 08:36:43 [6312f5fb] router: completed GET /tester/test_repo/commits/branch/main/search?q=78b2fc0b51d7245ee02bf506b250fbe641785d3f for 172.18.0.1:46558, 200 OK in 22.9ms @ repo/commit.go:37(repo.RefCommits) ` I was also able to reproduce the behaviour on the gitea demo website: https://try.gitea.io/115ek/commit_search ### Gitea Version 1.18.0+dev-372-g96a9e15df (docker) ### Can you reproduce the bug on the Gitea demo site? Yes ### Log Gist _No response_ ### Screenshots _No response_ ### Git Version 2.36.2, Wire Protocol Version 2 Enabled ### Operating System Gitea running as Docker container ### How are you running Gitea? Running with docker using the following docker-compose file. Started with `docker compose up` ```yml version: "3" networks: gitea: external: false services: server: image: gitea/gitea:dev container_name: gitea environment: - USER_UID=1000 - USER_GID=1000 restart: always networks: - gitea volumes: - ./gitea:/data - /etc/timezone:/etc/timezone:ro - /etc/localtime:/etc/localtime:ro ports: - "3000:3000" - "222:22" ``` ### Database SQLite
GiteaMirror added the type/bug label 2025-11-02 08:41:03 -06:00
Author
Owner

@115ek commented on GitHub (Sep 3, 2022):

The search itself is implemented here

@115ek commented on GitHub (Sep 3, 2022): The search itself is implemented [here](https://github.com/go-gitea/gitea/blob/18046eb91e21e03d475f3990e59516b46b6f67e2/modules/git/repo_commit.go#L100)
Author
Owner

@CypherpunkSamurai commented on GitHub (Sep 10, 2022):

I think this is happening cause branch test was branched from main after the second commit. Thus the commit Initial commit and first test have reference to the commit from main.

I'm not sure how github handles this, probably generate new reference hashes for branched commits or un-reference?

@CypherpunkSamurai commented on GitHub (Sep 10, 2022): I think this is happening cause branch `test` was branched from `main` after the second commit. Thus the commit `Initial commit` and `first test` have reference to the commit from main. I'm not sure how github handles this, probably generate new reference hashes for branched commits or un-reference?
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/gitea#9503