Implement git log --all#1045
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]>
| // 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.
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.
Agreed, but it should go in another PR (IMO)
| return nil, err | ||
| } | ||
| defer refIter.Close() | ||
| err = refIter.ForEach(func(r *plumbing.Reference) error { |
There was a problem hiding this comment.
will be great if we can split this function in something more readable
| // 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.
Propagating here the word all maybe is not the best option since is not very meaningful
There was a problem hiding this comment.
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.
This snippet need a refactor
|
|
||
| if o.FileName == nil { | ||
| return commitIter, nil | ||
| if o.All { |
There was a problem hiding this comment.
this code can be move to a function
There was a problem hiding this comment.
What exactly do you suggest to extract?
switch-case? else-branch?
There was a problem hiding this comment.
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 --allpretends as if all the refs in refs/, along with HEAD, are listed on the command line as . We start from the HEAD, soFromhash is ignored for--alloption.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).