-
Notifications
You must be signed in to change notification settings - Fork 538
git rev-list command #757
Comments
The best place is the Also maybe we can keep the |
@mcuadros : That sounds good to me, I can do that with just adding a new method as opposed to break compatibility with the old one. I also have the filtering mechanism for files in place so I'll add that. Thanks for the input. |
If we implement rev-list I would like to be able to see the amount of commits ahead and behind a local branch compared to its remote, for example equivalent of the following git command:
|
Here is my revlist implementation: It works fine except performance issue. The problem is; Can't get it work with one // RevListOptions defines the rules of rev-list func
type RevListOptions struct {
// Ref1 is the first reference hash to link
Ref1 string
// Ref2 is the second reference hash to link
Ref2 string
}
// RevList is native implemetation of git rev-list command
func RevList(r *git.Repository, opts RevListOptions) ([]*object.Commit, error) {
commits := make([]*object.Commit, 0)
ref1hist, err := revlist.Objects(r.Storer, []plumbing.Hash{plumbing.NewHash(opts.Ref1)}, nil)
if err != nil {
return nil, err
}
ref2hist, err := revlist.Objects(r.Storer, []plumbing.Hash{plumbing.NewHash(opts.Ref2)}, ref1hist)
if err != nil {
return nil, err
}
for _, h := range ref2hist {
c, err := r.CommitObject(h)
if err != nil {
continue
}
commits = append(commits, c)
}
// Basically sorts by date
sort.Sort(CommitTime(commits))
return commits, err
} |
I wanted to reproduce the behavior of
git rev-list HEAD my_file
with the help ofgo-git
.As this feature was not here out of the box, I tried my best to do a clean implementation for it with the library and it looks like this :
I'd like to share this with the community and potentially have it in the
go-git
library so I'm wondering what would be the best place for this to live in.Thanks !
The text was updated successfully, but these errors were encountered: