diff options
author | Paulo Gomes <pjbgf@linux.com> | 2024-03-10 07:24:38 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-03-10 07:24:38 +0000 |
commit | ca05e2c4d8cb1801d3a8c12773bac206774871a3 (patch) | |
tree | f786702c615d0a096750246e1156bd0b91a39fca | |
parent | f3113d2e83ca99face9285a117cb6d93951a7406 (diff) | |
parent | b274b225bf92f086d8e59d023ed436e97ed14062 (diff) | |
download | go-git-ca05e2c4d8cb1801d3a8c12773bac206774871a3.tar.gz |
Merge pull request #1046 from onee-only/optimize-commit-worker-path
plumbing: object, Optimize logging with file.
-rw-r--r-- | plumbing/object/commit_walker_path.go | 16 | ||||
-rw-r--r-- | plumbing/object/treenoder.go | 4 |
2 files changed, 14 insertions, 6 deletions
diff --git a/plumbing/object/commit_walker_path.go b/plumbing/object/commit_walker_path.go index e054966..c1ec8ba 100644 --- a/plumbing/object/commit_walker_path.go +++ b/plumbing/object/commit_walker_path.go @@ -57,6 +57,8 @@ func (c *commitPathIter) Next() (*Commit, error) { } func (c *commitPathIter) getNextFileCommit() (*Commit, error) { + var parentTree, currentTree *Tree + for { // Parent-commit can be nil if the current-commit is the initial commit parentCommit, parentCommitErr := c.sourceIter.Next() @@ -68,13 +70,17 @@ func (c *commitPathIter) getNextFileCommit() (*Commit, error) { parentCommit = nil } - // Fetch the trees of the current and parent commits - currentTree, currTreeErr := c.currentCommit.Tree() - if currTreeErr != nil { - return nil, currTreeErr + if parentTree == nil { + var currTreeErr error + currentTree, currTreeErr = c.currentCommit.Tree() + if currTreeErr != nil { + return nil, currTreeErr + } + } else { + currentTree = parentTree + parentTree = nil } - var parentTree *Tree if parentCommit != nil { var parentTreeErr error parentTree, parentTreeErr = parentCommit.Tree() diff --git a/plumbing/object/treenoder.go b/plumbing/object/treenoder.go index 6e7b334..2adb645 100644 --- a/plumbing/object/treenoder.go +++ b/plumbing/object/treenoder.go @@ -88,7 +88,9 @@ func (t *treeNoder) Children() ([]noder.Noder, error) { } } - return transformChildren(parent) + var err error + t.children, err = transformChildren(parent) + return t.children, err } // Returns the children of a tree as treenoders. |