Skip to content
This repository was archived by the owner on Sep 11, 2020. It is now read-only.

git: Worktree.Grep() support multiple patterns and pathspecs #695

Merged
merged 1 commit into from
Dec 19, 2017

Conversation

darkowlzz
Copy link
Contributor

@darkowlzz darkowlzz commented Dec 17, 2017

Signed-off-by: Sunny me@darkowlzz.space

Fixes #693

worktree.go Outdated
@@ -771,8 +771,24 @@ func findMatchInFiles(fileiter *object.FileIter, treeName string, opts *GrepOpti

// Iterate through the files and look for any matches.
err := fileiter.ForEach(func(file *object.File) error {
Copy link
Contributor

Choose a reason for hiding this comment

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

can we move this to his own fuction, is getting big

worktree.go Outdated
@@ -785,15 +801,22 @@ func findMatchInFiles(fileiter *object.FileIter, treeName string, opts *GrepOpti
contentByLine := strings.Split(content, "\n")
for lineNum, cnt := range contentByLine {
addToResult := false
Copy link
Contributor

Choose a reason for hiding this comment

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

same here

Signed-off-by: Sunny <me@darkowlzz.space>
@darkowlzz darkowlzz force-pushed the grep-multiple-patterns-pathspec branch from 3d6d549 to 4ead334 Compare December 19, 2017 19:03
@darkowlzz
Copy link
Contributor Author

Divided the huge block of code into 2 separate functions, findMatchInFiles() and findMatchInFile().

findMatchInFiles() iterates on all the files and calls findMatchInFile() on every file to find matches.

Looks small and simple now. Hope this works.

@mcuadros mcuadros merged commit 55b5d73 into src-d:master Dec 19, 2017
# for free to subscribe to this conversation on GitHub. Already have an account? #.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants