Skip to content

Commit 666b29b

Browse files
committed
t7500: make each piece more independent
These tests prepare the working tree & index state to have something to be committed, and try a sequence of "test_must_fail git commit". If an earlier one did not fail by a bug, a later one will fail for a wrong reason (namely, "nothing to commit"). Give them "--allow-empty" to make sure that they would work even when there is nothing to commit by accident. Signed-off-by: Junio C Hamano <[email protected]> Signed-off-by: Taylor Blau <[email protected]> Signed-off-by: D. Ben Knoble <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent c44beea commit 666b29b

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

t/t7500-commit-template-squash-signoff.sh

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -42,41 +42,41 @@ test_expect_success 'nonexistent template file in config should return error' '
4242
(
4343
GIT_EDITOR="echo hello >\"\$1\"" &&
4444
export GIT_EDITOR &&
45-
test_must_fail git commit
45+
test_must_fail git commit --allow-empty
4646
)
4747
'
4848

4949
# From now on we'll use a template file that exists.
5050
TEMPLATE="$PWD"/template
5151

5252
test_expect_success 'unedited template should not commit' '
53-
echo "template line" > "$TEMPLATE" &&
54-
test_must_fail git commit --template "$TEMPLATE"
53+
echo "template line" >"$TEMPLATE" &&
54+
test_must_fail git commit --allow-empty --template "$TEMPLATE"
5555
'
5656

5757
test_expect_success 'unedited template with comments should not commit' '
58-
echo "# comment in template" >> "$TEMPLATE" &&
59-
test_must_fail git commit --template "$TEMPLATE"
58+
echo "# comment in template" >>"$TEMPLATE" &&
59+
test_must_fail git commit --allow-empty --template "$TEMPLATE"
6060
'
6161

6262
test_expect_success 'a Signed-off-by line by itself should not commit' '
6363
(
6464
test_set_editor "$TEST_DIRECTORY"/t7500/add-signed-off &&
65-
test_must_fail git commit --template "$TEMPLATE"
65+
test_must_fail git commit --allow-empty --template "$TEMPLATE"
6666
)
6767
'
6868

6969
test_expect_success 'adding comments to a template should not commit' '
7070
(
7171
test_set_editor "$TEST_DIRECTORY"/t7500/add-comments &&
72-
test_must_fail git commit --template "$TEMPLATE"
72+
test_must_fail git commit --allow-empty --template "$TEMPLATE"
7373
)
7474
'
7575

7676
test_expect_success 'adding real content to a template should commit' '
7777
(
7878
test_set_editor "$TEST_DIRECTORY"/t7500/add-content &&
79-
git commit --template "$TEMPLATE"
79+
git commit --allow-empty --template "$TEMPLATE"
8080
) &&
8181
commit_msg_is "template linecommit message"
8282
'

0 commit comments

Comments
 (0)