8000 Expose git log --all equivalent · Issue #1024 · src-d/go-git · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
This repository was archived by the owner on Sep 11, 2020. It is now read-only.
This repository was archived by the owner on Sep 11, 2020. It is now read-only.
Expose git log --all equivalent #1024
Closed
@smola

Description

@smola

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.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions

    0