-
Notifications
You must be signed in to change notification settings - Fork 540
Conversation
Signed-off-by: kuba-- <[email protected]>
@jfontan - this is how it works. Imagine we have following repo:
so
without
|
Signed-off-by: kuba-- <[email protected]>
plumbing/object/commit_walker.go
Outdated
// NewCommitAllIter returns a new commit iterator for all refs. | ||
// s is a repo Storer used to get commits and references. | ||
// fn is a commit iterator function, used to iterate through ref commits in chosen order | ||
func NewCommitAllIter(s storage.Storer, fn func(*Commit) CommitIter) (CommitIter, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is similar to revlist.Objects
but for commits.
This is just a note that, in the future, we might want to deprecate revlist.Objects
in favor of NewObjectAllIter
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe worth to do it now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed, but it should go in another PR (IMO)
plumbing/object/commit_walker.go
Outdated
return nil, err | ||
} | ||
defer refIter.Close() | ||
err = refIter.ForEach(func(r *plumbing.Reference) error { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
will be great if we can split this function in something more readable
} | ||
|
||
// NewCommitFileIterFromIter returns a commit iterator which performs diffTree between | ||
// successive trees returned from the commit iterator from the argument. The purpose of this is | ||
// to find the commits that explain how the files that match the path came to be. | ||
func NewCommitFileIterFromIter(fileName string, commitIter CommitIter) CommitIter { | ||
func NewCommitFileIterFromIter(fileName string, commitIter CommitIter, all bool) CommitIter { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Propagating here the word all
maybe is not the best option since is not very meaningful
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah, actually it should be something like checkParents
} | ||
|
||
// filename matches, now check if source iterator contains all commits (from all refs) | ||
if c.all { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This snippet need a refactor
repository.go
Outdated
default: | ||
return nil, fmt.Errorf("invalid Order=%v", o.Order) | ||
} | ||
|
||
if o.FileName == nil { | ||
return commitIter, nil | ||
if o.All { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this code can be move to a function
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What exactly do you suggest to extract?
switch-case? else-branch?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know exactly the problem is that I think is very nested and complicated code with a high cyclomatic complexity
Signed-off-by: kuba-- <[email protected]>
@mcuadros - I've refined Log function. PTAL. |
Signed-off-by: kuba-- [email protected]
This PR implements git log --all.
It closes #1024
It's also related to #1023
git log --all
pretends as if all the refs in refs/, along with HEAD, are listed on the command line as . We start from the HEAD, soFrom
hash is ignored for--all
option.Please take a look carefully if it can be done in more optimal way.
For filter by file (
git log --all --filename
) we have to double check if the parent commit comes from the real commit (not just the next object returned by iterator).