tg.sh: handle help -h
[topgit/pro.git] / t / t2030-hook-sequestration.sh
blob17b51391e8e30a82a7fe81c1129f5d241ea5a346
1 #!/bin/sh
3 test_description='verify hook sequestration works properly'
5 . ./test-lib.sh
7 test_plan 11
9 # makes sure tg_test_setup_topgit will work on non-bin-wrappers testees
10 PATH="${TG_TEST_FULL_PATH%/*}:$PATH" && export PATH
12 test_expect_success 'setup' '
13 tg_test_setup_topgit &&
14 test_commit base &&
15 git branch master2 &&
16 git branch master3 &&
17 git branch master4 &&
18 git branch master5 &&
19 git branch master6 &&
20 git branch master7 &&
21 tg_test_create_branch tgb1 master &&
22 tg_test_create_branch tgb2 tgb1 &&
23 test_tick && test_when_finished test_tick=$test_tick &&
24 git checkout tgb1
27 count_commits() {
28 git rev-list --count --first-parent HEAD --
31 test_expect_success '.topdeps only does not sequester' '
32 git reset --hard &&
33 cnt1="$(count_commits)" &&
34 echo master2 >> .topdeps &&
35 git add .topdeps &&
36 git commit -m "modify .topdeps" &&
37 cnt2="$(count_commits)" &&
38 test $(( $cnt1 + 1 )) -eq $cnt2
41 test_expect_success '.topmsg only does not sequester' '
42 git reset --hard &&
43 cnt1="$(count_commits)" &&
44 echo "do dah do dah do dah doo" >> .topmsg &&
45 git add .topmsg &&
46 git commit -m "modify .topmsg" &&
47 cnt2="$(count_commits)" &&
48 test $(( $cnt1 + 1 )) -eq $cnt2
51 test_expect_success '.topdeps & .topmsg only does not sequester' '
52 git reset --hard &&
53 cnt1="$(count_commits)" &&
54 echo master3 >> .topdeps &&
55 git add .topdeps &&
56 echo "doo dah doo do dah doo" >> .topmsg &&
57 git add .topmsg &&
58 git commit -m "modify .topdeps & .topmsg" &&
59 cnt2="$(count_commits)" &&
60 test $(( $cnt1 + 1 )) -eq $cnt2
63 test_expect_success 'non .top* commit does not sequester' '
64 git reset --hard &&
65 cnt1="$(count_commits)" &&
66 test_commit hello &&
67 cnt2="$(count_commits)" &&
68 test $(( $cnt1 + 1 )) -eq $cnt2
71 test_expect_success '.topdeps and other sequesters' '
72 git reset --hard &&
73 cnt1="$(count_commits)" &&
74 echo master4 >> .topdeps &&
75 git add .topdeps &&
76 echo other1 > other1 &&
77 git add other1 &&
78 test_must_fail git commit -m "modify .topdeps and add other1" &&
79 cnt2="$(count_commits)" &&
80 test $(( $cnt1 + 1 )) -eq $cnt2 &&
81 git commit -m "just add other1" &&
82 cnt3="$(count_commits)" &&
83 test $(( $cnt1 + 2 )) -eq $cnt3
86 test_expect_success '.topmsg and other sequesters' '
87 git reset --hard &&
88 git config --bool topgit.sequester true &&
89 cnt1="$(count_commits)" &&
90 echo "do dah do dah do dah do dah doo" >> .topmsg &&
91 git add .topmsg &&
92 echo other2 > other2 &&
93 git add other2 &&
94 test_must_fail git commit -m "modify .topdeps and add other2" &&
95 cnt2="$(count_commits)" &&
96 test $(( $cnt1 + 1 )) -eq $cnt2 &&
97 git commit -m "just add other2" &&
98 cnt3="$(count_commits)" &&
99 test $(( $cnt1 + 2 )) -eq $cnt3
102 test_expect_success '.topdeps and .topmsg and other sequesters' '
103 git reset --hard &&
104 cnt1="$(count_commits)" &&
105 echo master5 >> .topdeps &&
106 git add .topdeps &&
107 echo "do dah do dah do dah doo" >> .topmsg &&
108 git add .topmsg &&
109 echo other3 > other3 &&
110 git add other3 &&
111 test_must_fail git commit -m "modify .topdeps and add other3" &&
112 cnt2="$(count_commits)" &&
113 test $(( $cnt1 + 1 )) -eq $cnt2 &&
114 git commit -m "just add other3" &&
115 cnt3="$(count_commits)" &&
116 test $(( $cnt1 + 2 )) -eq $cnt3
119 test_expect_success '.topdeps and other sequester bypass' '
120 git reset --hard &&
121 git config --bool topgit.sequester false &&
122 cnt1="$(count_commits)" &&
123 echo master6 >> .topdeps &&
124 git add .topdeps &&
125 echo other4 > other4 &&
126 git add other4 &&
127 git commit -m "modify .topdeps and add other4" &&
128 cnt2="$(count_commits)" &&
129 test $(( $cnt1 + 1 )) -eq $cnt2
132 test_expect_success '.topmsg and other sequester bypass' '
133 git reset --hard &&
134 cnt1="$(count_commits)" &&
135 echo "doo dah doo do dah doo" >> .topmsg &&
136 git add .topmsg &&
137 echo other5 > other5 &&
138 git add other5 &&
139 git commit -m "modify .topmsg and add other5" &&
140 cnt2="$(count_commits)" &&
141 test $(( $cnt1 + 1 )) -eq $cnt2
144 test_expect_success '.topdeps and .topmsg and other sequester bypass' '
145 git reset --hard &&
146 cnt1="$(count_commits)" &&
147 echo master7 >> .topdeps &&
148 git add .topdeps &&
149 echo "do dah do dah do dah do dah doo" >> .topmsg &&
150 git add .topmsg &&
151 echo other6 > other6 &&
152 git add other6 &&
153 git commit -m "modify .topdeps and .topmsg and add other6" &&
154 cnt2="$(count_commits)" &&
155 test $(( $cnt1 + 1 )) -eq $cnt2
158 test_done