Skip to content

Commit ca05e2c

Browse files
authored
Merge pull request go-git#1046 from onee-only/optimize-commit-worker-path
plumbing: object, Optimize logging with file.
2 parents f3113d2 + b274b22 commit ca05e2c

File tree

2 files changed

+14
-6
lines changed

2 files changed

+14
-6
lines changed

plumbing/object/commit_walker_path.go

+11-5
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,8 @@ func (c *commitPathIter) Next() (*Commit, error) {
5757
}
5858

5959
func (c *commitPathIter) getNextFileCommit() (*Commit, error) {
60+
var parentTree, currentTree *Tree
61+
6062
for {
6163
// Parent-commit can be nil if the current-commit is the initial commit
6264
parentCommit, parentCommitErr := c.sourceIter.Next()
@@ -68,13 +70,17 @@ func (c *commitPathIter) getNextFileCommit() (*Commit, error) {
6870
parentCommit = nil
6971
}
7072

71-
// Fetch the trees of the current and parent commits
72-
currentTree, currTreeErr := c.currentCommit.Tree()
73-
if currTreeErr != nil {
74-
return nil, currTreeErr
73+
if parentTree == nil {
74+
var currTreeErr error
75+
currentTree, currTreeErr = c.currentCommit.Tree()
76+
if currTreeErr != nil {
77+
return nil, currTreeErr
78+
}
79+
} else {
80+
currentTree = parentTree
81+
parentTree = nil
7582
}
7683

77-
var parentTree *Tree
7884
if parentCommit != nil {
7985
var parentTreeErr error
8086
parentTree, parentTreeErr = parentCommit.Tree()

plumbing/object/treenoder.go

+3-1
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,9 @@ func (t *treeNoder) Children() ([]noder.Noder, error) {
8888
}
8989
}
9090

91-
return transformChildren(parent)
91+
var err error
92+
t.children, err = transformChildren(parent)
93+
return t.children, err
9294
}
9395

9496
// Returns the children of a tree as treenoders.

0 commit comments

Comments
 (0)