Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

plumbing: object, Optimize logging with file. #1046

Merged
merged 2 commits into from
Mar 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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