Skip to content

[Bug] Content in branch 'c' completely unsearchable despite indexing #960

Closed as not planned

Description

@huanlongzhou

‌Description‌:

Created a repository with branch c and added a new file makabaka
Confirmed the repository is indexed in Zoekt
Search returns no results for content in branch c
Same scenario works normally for branch cc (file makabaka is searchable)
Image
Image
Image
但是我搜索的时候确搜索不到其内容,我是已经给这个仓库创建了索引了

This appears to be a branch-specific indexing issue where single-character branch names (like c) may not be properly handled. The problem persists even after reindexing, while multi-character branches (like cc) function as expected.
Image
Image
Image

Activity

  1. keegancsmith commented on May 26, 2025

    @keegancsmith
    Member

    based on your screenshots you are using a system on top of zoekt to manage indexing/etc? I don't know why zoekt wouldn't index the branch.

    Can you reproduce via directly running zoekt-git-index? Can you share the commands you run then?

    Note: it seems the branch name here is cc not c like in your title.

  2. huanlongzhou commented on May 29, 2025

    @huanlongzhou
    Author

    从你的截图来看,你是在 zoekt 上使用了一个系统来管理索引之类的吗?我不明白为什么 zoekt 无法索引这个分支。

    你能通过直接运行来复现吗zoekt-git-index?你能分享一下你运行的命令吗?

    注意:这里的分支名称似乎与您的标题cc不一样。c

    Yes, that's right. I built a system on zoekt. I used log printing to rule out the problem with my system. The system only fills the searched content with a layer of data. However, I always find that the searched content always lacks branches. Is there any command that can let me confirm whether the zoekt index is created successfully without using API requests?

    My directory hierarchy is like this
    Image

  3. keegancsmith commented on May 29, 2025

    @keegancsmith
    Member

    Please share the zoekt-git-index command you run so I can validate it makes sense.

  4. huanlongzhou commented on May 29, 2025

    @huanlongzhou
    Author

    请分享您运行的 zoekt-git-index 命令,以便我验证它是否有意义。
    I built it using the API, this is the code I built
    func (b DefaultIndexBuilder) BuildGitIndex(ctx context.Context, r RepoMap, callbackFunc callback.CallbackFunc) (err error) {
    resp := IndexResponse{Success: true}
    if r.Branches == "" {
    resp.Success = false
    return errors.New("branches null")
    }
    opts := build.Options{
    IndexDir: "./data",
    RepositoryDescription: zoekt.Repository{
    ID: r.RepoID,
    Name: strconv.FormatUint(uint64(r.RepoID), 10),
    },
    SizeMax: 2097152,
    }
    opts.SetDefaults()
    cloneUsername, _ := os.LookupEnv("CLONE_USERNAME")
    clonePassword, _ := os.LookupEnv("CLONE_PASSWORD")
    can, _ := os.LookupEnv("CAN_PULL")
    path := "./data/repo/" + strconv.FormatUint(uint64(r.RepoID), 10)

    var ok bool
    canPull := can == "true"
    if canPull {
    	ok, err = git_index.Fetch(path, cloneUsername, clonePassword)
    	if err != nil && err.Error() != "already up-to-date" {
    		os.RemoveAll(path)
    		err = git_index.Clone(r.URL, cloneUsername, clonePassword, r.RepoID)
    		if err != nil {
    			resp.Success = false
    		}
    	}
    }
    
    defer func() {
    	if !canPull {
    		os.RemoveAll(path)
    	}
    	railsCallback := r.Callback
    
    	if err != nil {
    		if railsCallback != nil {
    			callbackFunc.OnFailure(*railsCallback, err)
    		}
    	}
    
    	if railsCallback != nil {
    		callbackFunc.OnSuccess(*railsCallback)
    	}
    }()
    
    if !ok {
    	err = git_index.Clone(r.URL, cloneUsername, clonePassword, r.RepoID)
    	if err != nil {
    		resp.Success = false
    	}
    }
    
    gitOpts := gitindex.Options{
    	BranchPrefix:       "refs/heads/",
    	BuildOptions:       opts,
    	Branches:           strings.Split(r.Branches, ","),
    	RepoDir:            path,
    	AllowMissingBranch: true,
    }
    
    err = gitindex.IndexGitRepo(gitOpts)
    if err != nil {
    	resp.Success = false
    }
    
    return
    

    }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions