revwalk: introduce tests that hide old commits#3838
Conversation
Introduce some tests that show some commits, while hiding some commits that have a timestamp older than the common ancestors of these two commits.
|
The priority queue is only supposed to make the order of the traversal more likely to be efficient and should not dictate when we stop looking for the merge bases. This is indeed troubling. |
We want to loop until there are no more interesting commits in the array. The reversed logic will stop prematurely leading to incorrect results in cases with nonmonotonic timestamps.
|
One of the issues was a reversed logic. The second one seems to be that we do in fact perform the marking until we run out of interesting commits, but that means we never get to the uninterested commit that got pushed and thus never end up hiding it. It looks like we might have to make sure to go and mark commits uninteresting, but it's starting to look a lot like special-casing so I'm reluctant to just add another loop to |
Failing to do so can mean the priority queue never gets around to the unintersting commits that are older than the rest of the history.
c3e011a to
ee0c8b5
Compare
|
Both of these revwalk tests are now passing (CI failure comes down to the extra objects this adds). But I would still like to make sure this isn't just because we've ended up special-casing this exact situation. The main premark loop might still need a change. |
We're now close to the way git itself does it, and most of the logic goes into mark_parents_uninteresting so we can remove our own loop from premark_uninteresting. This function then becomes so simple we should extract its loop and make it part of loop we're running over the same input in its caller.
|
Fixed via #3921 |
Introduce some tests that show some commits, while hiding some commits that have a timestamp older than the common ancestors of these two commits.
For example, I've introduced 43e968a and 8e73b76 with timestamps from 2010 (earlier than 5b5b025), and bd75801 with a timestamp from today:
Note that they have an obvious common ancestor of 763d71a, and:
However, when hiding 8e73b76 and showing bd75801, our revwalk does not hide 8e73b76's ancestors. Ours returns:
As best I can tell, this is because we're using a time-based priority queue in
premark_uninteresting, which premarks the (timewise) new commit and all its parents, deciding that they're interesting, before dealing with the (timewise) old commit, and the common ancestors that should be uninteresting are not.I spend some time poking around here but I'm afraid that I need to defer to the mad revwalk skills.
/cc @carlosmn