Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion plumbing/object/commit_walker_path.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,8 @@ func (c *commitPathIter) hasFileChange(changes Changes, parent *Commit) bool {

// filename matches, now check if source iterator contains all commits (from all refs)
if c.checkParent {
if parent != nil && isParentHash(parent.Hash, c.currentCommit) {
// Check if parent is beyond the initial commit
if parent == nil || isParentHash(parent.Hash, c.currentCommit) {
return true
}
continue
Expand Down
26 changes: 26 additions & 0 deletions plumbing/object/commit_walker_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -228,3 +228,29 @@ func (s *CommitWalkerSuite) TestCommitBSFIteratorWithIgnore(c *C) {
c.Assert(commit.Hash.String(), Equals, expected[i])
}
}

func (s *CommitWalkerSuite) TestCommitPathIteratorInitialCommit(c *C) {
commit := s.commit(c, plumbing.NewHash(s.Fixture.Head))

fileName := "LICENSE"

var commits []*Commit
NewCommitPathIterFromIter(
func(path string) bool { return path == fileName },
NewCommitIterCTime(commit, nil, nil),
true,
).ForEach(func(c *Commit) error {
commits = append(commits, c)
return nil
})

expected := []string{
"b029517f6300c2da0f4b651b8642506cd6aaf45d",
}

c.Assert(commits, HasLen, len(expected))

for i, commit := range commits {
c.Assert(commit.Hash.String(), Equals, expected[i])
}
}