Added FindMergeBases on the ObjectDatabase class, equivalent to git merge-base --all. - #1149
Added FindMergeBases on the ObjectDatabase class, equivalent to git merge-base --all.#1149otac0n wants to merge 3 commits into
git merge-base --all.#1149Conversation
…merge-base --all`.
|
Oh, I had trouble getting my new test to run in NCrunch, but it ran fine in the VS Test Runner. NCrunch wasn't copying all of the files that are specified in the test project's Additional Files to Include. I'm not sure if this is typical, but since it worked fine in VS, I decided it was worth submitting. |
|
/cc'ing @Zoltu as he made the NCrunch magic happened Any hint? |
|
I'll clone the repo and see if I can reproduce the nCrunch failure and/or give any hints at a fix. |
|
Works for me, all tests pass except the one ignored one. Here are my steps:
Perhaps try:
|
|
I re-cloned and everything worked fine. Must have been a bug in NCrunch. So, how soon can this go into a pre-release package? I need this feature in my projects. |
There was a problem hiding this comment.
Can you please change the return type into an IEnumerable<Commit>?
There was a problem hiding this comment.
Would IList<Commit> be acceptable? I feel like losing the Count when it is readily available is a bad idea.
There was a problem hiding this comment.
As long as we're internally using a IList<> (ie. the ToList() call), returning an IEnumerable<> will not enumerate the wole collection and directly leverage the .Count property of the returned collection.
So returning IEnumerable<> shouldn't hurt on that topic.
There was a problem hiding this comment.
But IEnumerable<> doesn't have a Count property, and I feel like people will want it.
There was a problem hiding this comment.
There is an extension method Count() on IEnumerable so you can count it if you need to without returning a list. If it is backed by a list, then count will just return the value of the Count property. That being said, the user should assume that counting will result in enumeration and act accordingly (possibly calling ToList() first to avoid multiple enumeration.
That being said, ICollection is probably what you really want if you just want the ability to count (but not index into the list). So really, the discussion is between ICollection and IEnumerable. Not that I have any say in anything, but I am with @nulltoken on using IEnumerable unless there is a strong belief that the end-user will need to call count in a performant way. I don't know this area of code or how big the resulting enumerable will be but is anyone really going to care about the cost of a ToList or an enumeration? If not, then returning IEnumerable makes it more clear to the user that the thing they are getting is not something they should modify, it is something they can iterate over (possibly getting the count via iteration).
There was a problem hiding this comment.
Currently, IEnumerable<> is used when returning a collection of things, API wide. I'd rather stick with this principle.
There was a problem hiding this comment.
Could you please revert this? ^^
There was a problem hiding this comment.
I made it align better; was it intentionally misaligned?
Or would you just rather not have that change in this pull request?
There was a problem hiding this comment.
Was it intentionally misaligned?
I don't think it was 😉
Or would you just rather not have that change in this pull request?
We tend to prefer beautification changes to live in their own commits. If you're ok with extracting it in a different commit, it'd be glorious.
|
@otac0n In the original SO question you were using a command line that was both using The rationale behind my question is that by reviewing your PR, I've started to wonder if your method shouldn't actually be favored with regards to the current /cc @carlosmn |
|
@nulltoken I don't know when an However, looking over the docs a bit further, it seems that this is an explicitly called-out case (in the synopsis). I'll do a bit more research tonight, to see what difference (if any) exists between the two configurations. |
|
@nulltoken @carlosmn It looks like libgit2 lacks the ability to specify See: |
|
@peff Is there a case where The doc is a bit confusing regarding this. It looks like it's valid to combine the two switches, but I'm not sure to understand what's the expected result Would we get only one? Should we get all the best ones? Or the best one in first position and all the others merge bases after that? |
|
@nulltoken You generally get multiple merge bases as a result of criss-cross merges. So I think you could have an octopus with at least one pair-wise criss-cross, and as long as those commits work as a base for the other parts of the octopus, you still get multiple bases. For example: |
This should fix #1147.