-
Notifications
You must be signed in to change notification settings - Fork 534
plumbing: object, add APIs for traversing over commit graphs #1132
Conversation
3ab40da
to
ec65d90
Compare
Signed-off-by: Filip Navara <[email protected]>
ae0150e
to
9eb627f
Compare
Signed-off-by: Filip Navara <[email protected]>
Signed-off-by: Filip Navara <[email protected]>
Signed-off-by: Filip Navara <[email protected]>
Signed-off-by: Filip Navara <[email protected]>
Signed-off-by: Filip Navara <[email protected]>
Signed-off-by: Filip Navara <[email protected]>
Signed-off-by: Filip Navara <[email protected]>
func NewCommitNodeIterCTime( | ||
c CommitNode, | ||
seenExternal map[plumbing.Hash]bool, | ||
ignore []plumbing.Hash, |
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.
This mimics the interface from NewCommitIterCTime
. As far as I can see ignore
and seenExternal
essentially serve the same purpose, perhaps with different performance characteristics. I'd be fine with keeping it this way or removing one of them.
Signed-off-by: Filip Navara <[email protected]>
acf7800
to
a47126b
Compare
plumbing/object/commitnode.go
Outdated
|
||
// CommitNode is generic interface encapsulating a lightweight commit object retrieved | ||
// from CommitNodeIndex | ||
type CommitNode interface { |
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.
Is it possible to get the generation of the commit? This information is interesting to compare two commits or to stop walking at a certain level.
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.
It is available at the format level, but I didn't propagate it here and it is not exposed through API at this level. I will look into it. One thing to consider though is that the Git folks are looking into replacing generation numbers with "corrected commit date". I will link to the relevent discussion once I get back to my computer...
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.
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.
Yep, V3 was the one I most recently read about. There's no final decision about any particular approach, but I didn't feel confident about designing API around something that is likely to change.
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.
Looks like there are three things we can expose with a reasonable level of forward compatibility with the new proposals:
Generation() uint64
API onCommitNode
that will uphold the property that ifA.Generation() < B.Generation()
thenB
is unreachable byA
. While the current format allows the generation to be only 30-bit integer extending it to 64-bit should account for any of the other proposals to work with the same API (except maybe the FELINE version), including the 34-bit corrected commit dates.- A high-level API like
IsUnreachableFrom(a, b CommitNode)
. The idea is to abstract away the concept of the generations from the user and just expose the most useful underlying property. This may need some thinking since we basically have three states: a) definitely unreachable (property coming from the generations) b) definitely reachable (not in the commit-graph, but perhaps something that is stored in reachability bitmap for some subset of commits?) c) we don't know. - High-level API for priority heaps for traversing the graph in topological order by reusing the Generation property without directly exposing it.
Thoughts? I don't feel like implementing the last one since I currently have no use case for it, but maybe it would be useful for merge-base or something of that sort.
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.
I didn't feel confident enough to establish API shape for two of the above options. I've added the Generation()
method to CommitNode
in a fashion similar to what git
uses internally. It should be fairly easy to expand on it later.
Signed-off-by: Filip Navara <[email protected]>
Any news about this one? I have the next PR in the pipeline and this one is approved... /cc @mcuadros |
I rather not add new objects for unstable APIs to the object package, maybe make sense add this to any package called commitgraph, and mark this as EXPERIMENTAL, I am not very sure about this API or where is going. |
I was considering that. The reason I put it into the I do consider this somewhat experimental which is one of the reasons why it's designed to be quite independent of the rest of the code. As for where it's going I plan to write it up all the way to the
Additionally I may rewrite the |
I understand the situation that's why I rather keep this package and his usage limited to some packages until we reach the v5 of the library. Meanwhile, we can place all the code in a package. |
Fine with me. The only problem with the |
The format is used inside of the object/commitgraph, so it's not a problem. |
Signed-off-by: Filip Navara <[email protected]>
Signed-off-by: Filip Navara <[email protected]>
Awesome thanks! Can you add a |
Sure. I'll add the |
Signed-off-by: Filip Navara <[email protected]>
Signed-off-by: Filip Navara <[email protected]>
I added basic documentation and one high-level usage example. |
Signed-off-by: Filip Navara <[email protected]>
Signed-off-by: Filip Navara <[email protected]>
Signed-off-by: Filip Navara <[email protected]>
@mcuadros Anything else that is missing and needs to be addressed? |
Follow-up to #1128.
Only the last commit is relevant, rest will be disapper with rebase eventually.This wires up the commit-graph API on the object layer. It introduces a concept of a lightweight
CommitNode
interface that is used to encapsulate either realCommit
or a node loaded from the commit graph. A second interface calledCommitNodeIndex
is introduced to access the graph ofCommitNode
objects.Two implementations of
CommitNode
andCommitNodeIndex
are provided. One of them operates on top ofstorer.EncodedObjectStorer
and regular git objects. The other one operates on commit-graph files and has fallback tostorer.EncodedObjectStorer
for cases where the commit-graph file doesn't cover the entire repository.NewCommitNodeIterCTime
iterator is added, analogous toNewCommitIterCTime
, that can operate on theCommitNodeIndex
implementations.