prefs: allow opting-out of the published commit check
[git-cola.git] / test / short_branch_overlapping.sh
blob77421cf94e4b755c237b2f2e4d898334b8906645
1 #!/bin/bash
2 folder=tmp/a_repo
4 nodeI=0
6 function node() {
7 n=$nodeI
8 nodeI=$((nodeI+1))
10 touch $n >> /dev/null
11 git add $n >> /dev/null
12 if ! [ "$1" == "" ] ; then
13 n=$1
15 git commit -m node-$n- >> /dev/null
16 if ! [ "$1" == "" ] ; then
17 git tag -m "" $n >> /dev/null
21 function get_SHA1() {
22 git log --all --grep node-$1- | grep commit | sed -e 's/commit //'
25 function goto() {
26 SHA1=$(get_SHA1 $1)
27 git checkout $SHA1 -b $2 >> /dev/null
30 function merge() {
31 n=$nodeI
32 nodeI=$((nodeI+1))
34 SHA1=$(get_SHA1 $1)
35 git merge --no-ff $SHA1 -m node-$n- >> /dev/null
38 function range() {
39 i=$1
40 I=$2
41 res=$i
42 while [[ i -lt I ]] ; do
43 i=$((i+1))
44 res="$res $i"
45 done
46 echo $res
49 function nodes() {
50 I=$(($1-1))
51 for i in $(range 0 $I) ; do
52 node
53 done
56 rm -rf "$folder"
57 mkdir "$folder"
58 cd "$folder"
60 git init
62 # Tags are used to get difference between row and generation values.
63 # Branches master & b2 occupied 2 rows per generation because of tags.
64 # Branches b0 is at the left of tags. Therefore, b0 uses 1 row per generation.
65 # The same is for b1 too. The b1 is short but tag 'b1' cannot be placed
66 # right at the row the branch ends, because the tags at the right were already
67 # placed (they have less generation value). Hence, a gap between last two
68 # commits of b1 is big. Let b0 forks at a row inside the gap. The fork commit
69 # have greater generation than last commit of b1. Hence, it is placed after.
70 # Because of the bug, making many enough branches starting from the fork will
71 # manage to overlapping of last commit of b1 and a commit of a branch.
73 node tag0
74 node tag1
75 node tag2
76 node tag3
77 node tag4
78 nodes 1
80 goto tag0 b0
81 nodes 8
82 b0_head=$n
84 goto tag0 b1
85 nodes 5
87 goto tag0 b2
88 nodes 10
90 git checkout b0
91 nodes 5
93 goto $b0_head b5
94 nodes 5
96 goto $b0_head b6
97 nodes 5
99 goto $b0_head b7
100 nodes 5
102 git checkout b2
104 ../../../bin/git-dag --all &