Skip to content
This repository was archived by the owner on Sep 11, 2020. It is now read-only.

repository.Log: add alternatives for commit traversal order #771

Merged
merged 3 commits into from
Mar 12, 2018
Merged

repository.Log: add alternatives for commit traversal order #771

merged 3 commits into from
Mar 12, 2018

Conversation

ilius
Copy link
Contributor

@ilius ilius commented Mar 5, 2018

The new option Order to repo.Log allows customizing the order of commits.
Specially because the current algorithm is not compatible with git log, the current algorithm use a stack (Depth-first Search?), while git log uses timestamp of commit (committer time).

So if we want to have the same order as git log we specify Order: git.LogOrderCommitterTime.
In the CommitterTime implementation, the stack of iterators is replaced with a BinaryHeap of commits (to avoid sorting the commits every time a commit is added). Also start property is removed (we start with a heap of length 1) so the code is simpler and cleaner.

For the BinaryHeap we use this library: https://github.com/emirpasic/gods

The default behavior (commits order) of repo.Log is unchanged.

@ilius ilius changed the title all alternatives for commit traversal order in repo.Log Add alternatives for commit traversal order in repo.Log Mar 5, 2018
@ilius
Copy link
Contributor Author

ilius commented Mar 6, 2018

The failing test does not seem to be related to my changes

/home/travis/gopath/src/gopkg.in/src-d/go-git.v4/plumbing/transport/test/upload_pack.go:55:
    c.Assert(err, Equals, transport.ErrRepositoryNotFound)
... obtained *errors.errorString = &errors.errorString{s:"unexpected EOF"} ("unexpected EOF")
... expected *errors.errorString = &errors.errorString{s:"repository not found"} ("repository not found")

@mcuadros mcuadros changed the title Add alternatives for commit traversal order in repo.Log repository.Log: add alternatives for commit traversal order Mar 12, 2018
@mcuadros mcuadros merged commit 1d28459 into src-d:master Mar 12, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants