gitea icon indicating copy to clipboard operation
gitea copied to clipboard

Commit Search is Returning Incorrect Results

Open 115ek opened this issue 2 years ago • 2 comments

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

115ek avatar Sep 03 '22 06:09 115ek

The search itself is implemented here

115ek avatar Sep 03 '22 06:09 115ek

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 avatar Sep 10 '22 20:09 CypherpunkSamurai