-
Notifications
You must be signed in to change notification settings - Fork 869
Closed
Labels
bugSomething isn't workingSomething isn't workinggood first issueGood for newcomersGood for newcomershelp wantedExtra attention is neededExtra attention is neededperformance
Description
I am trying to get a list of commits in which a given file has been modified.
Therefore, I'm doing a Log and I set FileName to my file in the LogOptions.
But this process is very slow. In the following example, it takes about a minute to return, whereas using git in command line returns immediately.
package main
import (
"fmt"
"github.com/go-git/go-billy/v5/memfs"
git "github.com/go-git/go-git/v5"
"github.com/go-git/go-git/v5/plumbing/object"
"github.com/go-git/go-git/v5/storage/memory"
)
func main() {
fs := memfs.New()
fmt.Println("Cloning repository")
rep, _ := git.Clone(memory.NewStorage(), fs, &git.CloneOptions{
URL: "https://www.github.com/sigmahq/sigma",
})
f := "README.md"
fmt.Println("git log")
cIter, _ := rep.Log(&git.LogOptions{FileName: &f})
_ = cIter.ForEach(func(c *object.Commit) error {
return nil
})
fmt.Println("Finished")
}Also, the same example just browsing all the commits, not filtering on a given file returns immediately.
package main
import (
"fmt"
"github.com/go-git/go-billy/v5/memfs"
git "github.com/go-git/go-git/v5"
"github.com/go-git/go-git/v5/plumbing/object"
"github.com/go-git/go-git/v5/storage/memory"
)
func main() {
fs := memfs.New()
fmt.Println("Cloning repository")
rep, _ := git.Clone(memory.NewStorage(), fs, &git.CloneOptions{
URL: "https://www.github.com/sigmahq/sigma",
})
//f := "README.md"
fmt.Println("git log")
cIter, _ := rep.Log(&git.LogOptions{})
_ = cIter.ForEach(func(c *object.Commit) error {
return nil
})
fmt.Println("Finished")
}Can this be improved? If not, what workaround can I use to get the list of commits that modified a given file with better performance?
mostafa
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't workinggood first issueGood for newcomersGood for newcomershelp wantedExtra attention is neededExtra attention is neededperformance