This repository was archived by the owner on Sep 11, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 534
This repository was archived by the owner on Sep 11, 2020. It is now read-only.
Expose git log --all equivalent #1024
Copy link
Copy link
Closed
Description
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:
- 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). - 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.
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.