Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add -F to commit search to treat keywords as strings #28744

Merged
merged 2 commits into from
Jan 10, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions modules/git/repo_commit.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,9 @@ func (repo *Repository) searchCommits(id ObjectID, opts SearchCommitsOptions) ([
cmd.AddArguments("--all")
}

// interpret search string keywords as string instead of regex
cmd.AddArguments("-F")
Copy link
Contributor

@wxiaoguang wxiaoguang Jan 10, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe it could use the long argument, it reads easier.

       -F, --fixed-strings
           Consider the limiting patterns to be fixed strings (don’t interpret pattern as a regular expression).
Suggested change
cmd.AddArguments("-F")
cmd.AddArguments("--fixed-strings")

ps: tests don't seem very necessary this time, good to have, while it also LGTM without test since it is quite simple and won't cause serious regression.


// add remaining keywords from search string
// note this is done only for command created above
for _, v := range opts.Keywords {
Expand Down