interplane.Get Omega
Read in your language

git

[Ported from github.com/git/git] Sync with Git 2.56.1

Brought by drakestapleton

branch master Branches Tags History

git / t / perf / p6010-merge-base.sh

105 lines · 2569 bytes Raw Blame History
1#!/bin/sh
2
3test_description='Test git merge-base'
4
5. ./perf-lib.sh
6
7test_perf_fresh_repo
8
9#
10# Creates lots of merges to make history traversal costly. In
11# particular it creates 2^($max_level-1)-1 2-way merges on top of
12# 2^($max_level-1) root commits. E.g., the commit history looks like
13# this for a $max_level of 3:
14#
15# _1_
16# / \
17# 2 3
18# / \ / \
19# 4 5 6 7
20#
21# The numbers are the fast-import marks, which also are the commit
22# messages. 1 is the HEAD commit and a merge, 2 and 3 are also merges,
23# 4-7 are the root commits.
24#
25build_history () {
26 local max_level="$1" &&
27 local level="${2:-1}" &&
28 local mark="${3:-1}" &&
29 if test $level -eq $max_level
30 then
31 echo "reset refs/heads/master" &&
32 echo "from $ZERO_OID" &&
33 echo "commit refs/heads/master" &&
34 echo "mark :$mark" &&
35 echo "committer C <c@example.com> 1234567890 +0000" &&
36 echo "data <<EOF" &&
37 echo "$mark" &&
38 echo "EOF"
39 else
40 local level1=$((level+1)) &&
41 local mark1=$((2*mark)) &&
42 local mark2=$((2*mark+1)) &&
43 build_history $max_level $level1 $mark1 &&
44 build_history $max_level $level1 $mark2 &&
45 echo "commit refs/heads/master" &&
46 echo "mark :$mark" &&
47 echo "committer C <c@example.com> 1234567890 +0000" &&
48 echo "data <<EOF" &&
49 echo "$mark" &&
50 echo "EOF" &&
51 echo "from :$mark1" &&
52 echo "merge :$mark2"
53 fi
54}
55
56#
57# Creates a new merge history in the same shape as build_history does,
58# while reusing the same root commits. This way the two top commits
59# have 2^($max_level-1) merge bases between them.
60#
61build_history2 () {
62 local max_level="$1" &&
63 local level="${2:-1}" &&
64 local mark="${3:-1}" &&
65 if test $level -lt $max_level
66 then
67 local level1=$((level+1)) &&
68 local mark1=$((2*mark)) &&
69 local mark2=$((2*mark+1)) &&
70 build_history2 $max_level $level1 $mark1 &&
71 build_history2 $max_level $level1 $mark2 &&
72 echo "commit refs/heads/master" &&
73 echo "mark :$mark" &&
74 echo "committer C <c@example.com> 1234567890 +0000" &&
75 echo "data <<EOF" &&
76 echo "$mark II" &&
77 echo "EOF" &&
78 echo "from :$mark1" &&
79 echo "merge :$mark2"
80 fi
81}
82
83test_expect_success 'setup' '
84 max_level=15 &&
85 build_history $max_level | git fast-import --export-marks=marks &&
86 git branch one &&
87 build_history2 $max_level | git fast-import --import-marks=marks --force &&
88 git branch two &&
89 git gc &&
90 git log --format=%H --no-merges >expect
91'
92
93test_perf 'git merge-base' '
94 git merge-base --all one two >actual
95'
96
97test_expect_success 'verify result' '
98 test_cmp expect actual
99'
100
101test_perf 'git show-branch' '
102 git show-branch one two
103'
104
105test_done