plan9fox/sys/src/cmd/git
Michael Forney 2e47badb88 git/query: refactor graph painting algorithm (findtwixt, lca)
We now keep track of 3 sets during traversal:
- keep: commits we've reached from head commits
- drop: commits we've reached from tail commits
- skip: ancestors of commits in both 'keep' and 'drop'

Commits in 'keep' and/or 'drop' may be added later to the 'skip' set
if we discover later that they are part of a common subgraph of the
head and tail commits.

From these sets we can calculate the commits we are interested in:
lca commits are those in 'keep' and 'drop', but not in 'skip'.
findtwixt commits are those in 'keep', but not in 'drop' or 'skip'.

The "LCA" commit returned is a common ancestor such that there are no
other common ancestors that can reach that commit.  Although there can
be multiple commits that meet this criteria, where one is technically
lower on the commit-graph than the other, these cases only happen in
complex merge arrangements and any choice is likely a decent merge
base.

Repainting is now done in paint() directly.  When we find a boundary
commit, we switch our paint color to 'skip'.  'skip' painting does
not stop when it hits another color; we continue until we are left
with only 'skip' commits on the queue.

This fixes several mishandled cases in the current algorithm:
1. If we hit the common subgraph from tail commits first (if the tail
   commit was newer than the head commit), we ended up traversing the
   entire commit graph.  This is because we couldn't distinguish
   between 'drop' commits that were part of the common subgraph, and
   those that were still looking for it.
2. If we traversed through an initial part of the common subgraph from
   head commits before reaching it from tail commits, these commits
   were returned from findtwixt even though they were also reachable
   from tail commits.
3. In the same case as 2, we might end up choosing an incorrect
   commit as the LCA, which is an ancestor of the real LCA.
2022-03-16 21:41:59 +00:00
..
add git: better handling of absolute paths, regex metachars 2021-08-17 04:31:15 +00:00
branch git/branch: fix order of operations (thanks qwx) 2022-02-10 01:33:36 +00:00
clone git: better handling of absolute paths, regex metachars 2021-08-17 04:31:15 +00:00
commit git/commit: squelch error when run outside repository 2022-01-09 17:37:29 +00:00
compat git/compat: add support for ls-remote [-d] 2021-08-25 02:24:15 +00:00
conf.c git/conf: check in /sys/lib/git/config as a fallback to user-wide config 2021-06-08 20:13:57 +00:00
delta.c
diff git/diff: clean up diffs 2021-08-23 01:22:04 +00:00
export git/export: use 'date -f' instead of 'date -m' 2021-08-12 14:42:47 +00:00
fetch.c git: revert c947bf808 -- it triggers a bug. 2021-12-22 00:48:09 +00:00
fs.c git/fs: remove trailing null bytes from parent file (thanks mcf) 2022-01-07 01:43:52 +00:00
git.h git/query: refactor graph painting algorithm (findtwixt, lca) 2022-03-16 21:41:59 +00:00
import git: separate author and committer 2021-09-03 02:47:18 +00:00
init git: create .git/objects/ on git/init 2021-07-06 16:21:18 +00:00
log.c git/query: refactor graph painting algorithm (findtwixt, lca) 2022-03-16 21:41:59 +00:00
merge git: separate author and committer 2021-09-03 02:47:18 +00:00
mkfile
objset.c
ols.c
pack.c git: size cache in bytes, not objects 2022-01-02 03:37:23 +00:00
proto.c git: allow local repository directories as remote uri's 2021-06-04 17:47:26 +02:00
pull git: revert c947bf808 -- it triggers a bug. 2021-12-22 00:48:09 +00:00
push git/push, git/send: get better about erroring out early 2021-06-13 12:48:49 +00:00
query.c git/query: fix spurious merge requests 2021-09-11 17:46:26 +00:00
rebase distproto: sync with hg 2021-06-06 13:21:53 -04:00
ref.c git/query: refactor graph painting algorithm (findtwixt, lca) 2022-03-16 21:41:59 +00:00
repack.c
revert git/revert: update modification time on revert 2022-02-27 04:27:56 +00:00
rm
save.c git: separate author and committer 2021-09-03 02:47:18 +00:00
send.c git/send: allow the remote to have refs that we don't 2021-06-06 13:07:51 -04:00
serve.c git/serve: add a '\n' after HEAD 2021-08-25 22:15:34 +00:00
util.c git/query: refactor graph painting algorithm (findtwixt, lca) 2022-03-16 21:41:59 +00:00
walk.c