summaryrefslogtreecommitdiff
path: root/sys/src/cmd/git/save.c
diff options
context:
space:
mode:
authorMichael Forney <mforney@mforney.org>2022-03-14 02:09:47 +0000
committerOri Bernstein <ori@eigenstate.org>2022-03-14 02:09:47 +0000
commit00759994ca46451eba88037ebe1697461ea43437 (patch)
tree8397b0db346e2e008b0f0f7a3aa40be382ef4315 /sys/src/cmd/git/save.c
parenta1d252ff9b58c9c9bf3bf8765e4cf2c988ed51d4 (diff)
git/query: implement range using paint()
The current range algorithm does not work correctly when merge commits are involved with an ancestor of the base commit. For example, consider the graph b ↙ ↖ a d ← e ← f ↖ ↙ c where b is d's first parent, and c is d's second parent. This graph is symmetrical, so we should get the same results for b..f and c..d (modulo the symmetry), but currently range() returns [d] for b..f and [d, e, f] for c..f. In the first case, we traverse to b, our base, then unwind to d and add [d] to our results. Then, we traverse [c, a], but don't find b this time, so unwind back to f. In the second case, we traverse all the way to a through b, unwind to d, then find our base, c, and unwind back to f and add [d, e, f] to our results. The problem here is that the determining factor for whether a commit is pushed during unwinding is whether the *last* parent reached the base commit, when it should be if *any* parent reached the base commit. Also, when a is not an ancestor of b, the current algorithm traverses the entire graph then returns an empty list, despite git's behavior and git9's documentation ("Between is defined as the set of all commits which are reachable from b but not reachable from a"). For the above example, we'd expect that b..f contain c, since c is not reachable from b. Range is almost identical to findtwixt, so to fix this we can reuse the same paint() algorithm for both operations. The only difference is that we want results in traversal order (rather than an arbitrary ordering). Add a third mode to paint() to save 'keep' commits in an array in the order we reach them, then return the non-dropped and non-skipped commits, preserving that order.
Diffstat (limited to 'sys/src/cmd/git/save.c')
0 files changed, 0 insertions, 0 deletions