Skip to content

Commit 7f12569

Browse files
committed
fix
1 parent 53b5522 commit 7f12569

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

routers/web/repo/search.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,13 @@ func Search(ctx *context.Context) {
6565
ctx.Data["CodeIndexerUnavailable"] = !code_indexer.IsAvailable(ctx)
6666
}
6767
} else {
68-
res, err := git.GrepSearch(ctx, ctx.Repo.GitRepo, keyword, git.GrepOptions{ContextLineNumber: 3, IsFuzzy: isFuzzy})
68+
res, err := git.GrepSearch(ctx, ctx.Repo.GitRepo, keyword, git.GrepOptions{
69+
ContextLineNumber: 1,
70+
IsFuzzy: isFuzzy,
71+
RefName: git.RefNameFromBranch(ctx.Repo.BranchName).String(), // BranchName should be default branch or the first existing branch
72+
})
6973
if err != nil {
74+
// TODO: if no branch exists, it reports: exit status 128, fatal: this operation must be run in a work tree.
7075
ctx.ServerError("GrepSearch", err)
7176
return
7277
}

0 commit comments

Comments
 (0)