merge hook tests: fix and update tests
- update 'no editor' hook test and add 'editor' hook test - make sure the tree is reset to a clean state after running a test (using test_when_finished) so later tests are not impacted Signed-off-by: Benoit Pierre <benoit.pierre@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Benoit Pierre committed
Mar 18, 2014 at 11:00 UTC
1fc4f97d570c97471202ff561c7e3697e2faee6a
1 file changed
+21
-6
t/t7505-prepare-commit-msg-hook.sh
+21
-6
@@ -134,14 +134,26 @@ test_expect_success 'with hook (-c)' '
134
135
test_expect_success 'with hook (merge)' '
136
137
- head=`git rev-parse HEAD` &&
138
- git checkout -b other HEAD@{1} &&
139
- echo "more" >> file &&
137
+ test_when_finished "git checkout -f master" &&
138
+ git checkout -B other HEAD@{1} &&
139
+ echo "more" >>file &&
140
+ git add file &&
141
+ git commit -m other &&
142
+ git checkout - &&
143
+ git merge --no-ff other &&
144
+ test "`git log -1 --pretty=format:%s`" = "merge (no editor)"
145
+'
146
+
147
+test_expect_success 'with hook and editor (merge)' '
148
+
149
+ test_when_finished "git checkout -f master" &&
150
+ git checkout -B other HEAD@{1} &&
151
+ echo "more" >>file &&
152
git add file &&
153
git commit -m other &&
154
git checkout - &&
143
- git merge other &&
144
- test "`git log -1 --pretty=format:%s`" = merge
155
+ env GIT_EDITOR="\"\$FAKE_EDITOR\"" git merge --no-ff -e other &&
156
+ test "`git log -1 --pretty=format:%s`" = "merge"
157
'
158
159
cat > "$HOOK" <<'EOF'
@@ -151,6 +163,7 @@ EOF
163
164
test_expect_success 'with failing hook' '
165
166
+ test_when_finished "git checkout -f master" &&
167
head=`git rev-parse HEAD` &&
168
echo "more" >> file &&
169
git add file &&
@@ -160,6 +173,7 @@ test_expect_success 'with failing hook' '
173
174
test_expect_success 'with failing hook (--no-verify)' '
175
176
+ test_when_finished "git checkout -f master" &&
177
head=`git rev-parse HEAD` &&
178
echo "more" >> file &&
179
git add file &&
@@ -169,6 +183,7 @@ test_expect_success 'with failing hook (--no-verify)' '
183
184
test_expect_success 'with failing hook (merge)' '
185
186
+ test_when_finished "git checkout -f master" &&
187
git checkout -B other HEAD@{1} &&
188
echo "more" >> file &&
189
git add file &&
@@ -178,7 +193,7 @@ test_expect_success 'with failing hook (merge)' '
193
exit 1
194
EOF
195
git checkout - &&
181
- test_must_fail git merge other
196
+ test_must_fail git merge --no-ff other
197
198
'
199