-
Notifications
You must be signed in to change notification settings - Fork 534
plumbing: object, commit.Parent() method #534
Conversation
First parents are somewhat special in git. There's even a --first-parent flag to 'git log'. Add a helper method to look them up. This avoids boilerplate and spares the client from having to arrange for a handle to the Storer, which is stored in the unexported field Commit.s.
plumbing/object/commit.go
Outdated
var ErrNoParents = errors.New("commit has no parents") | ||
|
||
// FirstParent returns the first parent of c. | ||
func (c *Commit) FirstParent() (*Commit, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you create create test or this?
@ajnavarro @orirawlings what do you thing about this? |
I agree it needs a test, but I think it can be useful. Perhaps it would be more useful to generalize further:
|
|
@orirawlings this is the signature from "git2go" and I must to say that for me wasn't clear that the first commit has any special meaning. But it's because doesn't have it, the order of the parents is something relevant when you are flattering the tree (like in So yes, I prefer the signature
@joshbetz can you update the PR with the request? Thanks! |
I think you mean @josharian :) |
Yup, sorry. |
Thanks for the review. Will add a test and update docs a bit later; distracted by other matters at the moment. |
@josharian ping |
813f4f0
to
e09fa24
Compare
Signed-off-by: Máximo Cuadros <mcuadros@gmail.com>
First parents are somewhat special in git.
There's even a --first-parent flag to 'git log'.
Add a helper method to look them up.
This avoids boilerplate and spares the client from
having to arrange for a handle to the Storer,
which is stored in the unexported field Commit.s.