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

Expose git log --all equivalent #1024

Closed
smola opened this issue Nov 19, 2018 · 0 comments · Fixed by #1045
Closed

Expose git log --all equivalent #1024

smola opened this issue Nov 19, 2018 · 0 comments · Fixed by #1045

Comments

@smola
Copy link
Collaborator

smola commented Nov 19, 2018

Currently, our main way to access all commits is CommitObjects, which iterates all commits in a repository, no matter if they are reachable from references or not. This leads to two problems:

  1. It is sometimes confusing to iterate over dangling commits. These are very frequent on local repositories that have been subject to local work, rebases, etc. In git, it is pretty hard to iterate over dangling commits. AFAIK there is no porcelain command exposing all of them together (git reflog exposes some of them from reflog, git verify-pack exposes them in packfiles, etc).
  2. On large repositories, iterating over all commits is significantly slower than getting all reachable commits. The former requires decoding all object headers in every packfile, which on large repositories is slower than just traversing history from all references.

Changing CommitObjects behaviour would not be backwards compatible, but we could expose an equivalent to git log --all in Repository.Log by adding an All bool option, which would return an iterator over all commits reachable from any reference.

go-git/options.go

Lines 323 to 338 in 7853ab6

// LogOptions describes how a log action should be performed.
type LogOptions struct {
// When the From option is set the log will only contain commits
// reachable from it. If this option is not set, HEAD will be used as
// the default From.
From plumbing.Hash
// The default traversal algorithm is Depth-first search
// set Order=LogOrderCommitterTime for ordering by committer time (more compatible with `git log`)
// set Order=LogOrderBSF for Breadth-first search
Order LogOrder
// Show only those commits in which the specified file was inserted/updated.
// It is equivalent to running `git log -- <file-name>`.
FileName *string
}

We would then add a note to CommitObjects godoc, since users will usually want to use Log instead.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants