summaryrefslogtreecommitdiff
path: root/git-mergetool.sh
diff options
context:
space:
mode:
authorDerrick Stolee <dstolee@microsoft.com>2018-11-02 13:14:45 (GMT)
committerJunio C Hamano <gitster@pobox.com>2018-11-02 15:12:06 (GMT)
commitfcb2c0769db54022b5bf3ed134623fbab48cdc20 (patch)
tree2ea20d682272fe4dd99009167c344271c3e62faa /git-mergetool.sh
parentd582ea202b626dcc6c3b01e1e11a296d9badd730 (diff)
downloadgit-fcb2c0769db54022b5bf3ed134623fbab48cdc20.zip
git-fcb2c0769db54022b5bf3ed134623fbab48cdc20.tar.gz
git-fcb2c0769db54022b5bf3ed134623fbab48cdc20.tar.bz2
commit-reach: implement get_reachable_subset
The existing reachability algorithms in commit-reach.c focus on finding merge-bases or determining if all commits in a set X can reach at least one commit in a set Y. However, for two commits sets X and Y, we may also care about which commits in Y are reachable from at least one commit in X. Implement get_reachable_subset() which answers this question. Given two arrays of commits, 'from' and 'to', return a commit_list with every commit from the 'to' array that is reachable from at least one commit in the 'from' array. The algorithm is a simple walk starting at the 'from' commits, using the PARENT2 flag to indicate "this commit has already been added to the walk queue". By marking the 'to' commits with the PARENT1 flag, we can determine when we see a commit from the 'to' array. We remove the PARENT1 flag as we add that commit to the result list to avoid duplicates. The order of the resulting list is a reverse of the order that the commits are discovered in the walk. There are a couple shortcuts to avoid walking more than we need: 1. We determine the minimum generation number of commits in the 'to' array. We do not walk commits with generation number below this minimum. 2. We count how many distinct commits are in the 'to' array, and decrement this count when we discover a 'to' commit during the walk. If this number reaches zero, then we can terminate the walk. Tests will be added using the 'test-tool reach' helper in a subsequent commit. Signed-off-by: Derrick Stolee <dstolee@microsoft.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'git-mergetool.sh')
0 files changed, 0 insertions, 0 deletions