Skip to content

Commit

Permalink
Merge pull request #1046 from onee-only/optimize-commit-worker-path
Browse files Browse the repository at this point in the history
plumbing: object, Optimize logging with file.
  • Loading branch information
pjbgf committed Mar 10, 2024
2 parents f3113d2 + b274b22 commit ca05e2c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
16 changes: 11 additions & 5 deletions plumbing/object/commit_walker_path.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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()
Expand Down
4 changes: 3 additions & 1 deletion plumbing/object/treenoder.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit ca05e2c

Please sign in to comment.