File tree 1 file changed +105
-0
lines changed
1 file changed +105
-0
lines changed Original file line number Diff line number Diff line change
1
+ #! /bin/bash
2
+ folder=tmp/a_repo
3
+
4
+ nodeI=0
5
+
6
+ function node() {
7
+ n=$nodeI
8
+ nodeI=$(( nodeI+ 1 ))
9
+
10
+ touch $n >> /dev/null
11
+ git add $n >> /dev/null
12
+ if ! [ " $1 " == " " ] ; then
13
+ n=$1
14
+ fi
15
+ git commit -m node-$n - >> /dev/null
16
+ if ! [ " $1 " == " " ] ; then
17
+ git tag -m " " $n >> /dev/null
18
+ fi
19
+ }
20
+
21
+ function get_SHA1() {
22
+ git log --all --grep node-$1 - | grep commit | sed -e ' s/commit //'
23
+ }
24
+
25
+ function goto() {
26
+ SHA1=$( get_SHA1 $1 )
27
+ git checkout $SHA1 -b $2 >> /dev/null
28
+ }
29
+
30
+ function merge() {
31
+ n=$nodeI
32
+ nodeI=$(( nodeI+ 1 ))
33
+
34
+ SHA1=$( get_SHA1 $1 )
35
+ git merge --no-ff $SHA1 -m node-$n - >> /dev/null
36
+ }
37
+
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
47
+ }
48
+
49
+ function nodes() {
50
+ I=$(( $1 - 1 ))
51
+ for i in $( range 0 $I ) ; do
52
+ node
53
+ done
54
+ }
55
+
56
+ rm -rf " $folder "
57
+ mkdir " $folder "
58
+ cd " $folder "
59
+
60
+ git init
61
+
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.
72
+
73
+ node tag0
74
+ node tag1
75
+ node tag2
76
+ node tag3
77
+ node tag4
78
+ nodes 1
79
+
80
+ goto tag0 b0
81
+ nodes 8
82
+ b0_head=$n
83
+
84
+ goto tag0 b1
85
+ nodes 5
86
+
87
+ goto tag0 b2
88
+ nodes 10
89
+
90
+ git checkout b0
91
+ nodes 5
92
+
93
+ goto $b0_head b5
94
+ nodes 5
95
+
96
+ goto $b0_head b6
97
+ nodes 5
98
+
99
+ goto $b0_head b7
100
+ nodes 5
101
+
102
+ git checkout b2
103
+
104
+ ../../../bin/git-dag --all &
105
+
You can’t perform that action at this time.
0 commit comments