8000 plumbing: object, Optimize logging with file. by onee-only · Pull Request #1046 · go-git/go-git · GitHub
[go: up one dir, main page]

Skip to content

plumbing: object, Optimize logging with file. #1046

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

Merged
merged 2 commits into from
Mar 10, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
plumbing: object, Optimize getNextFileCommit to reuse parent tree.
  • Loading branch information
onee-only committed Mar 10, 2024
commit c1002494eb389b703731c5267561a2703a8cd3b1
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
0