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 <gitster@pobox.com> Signed-off-by: Taylor Blau <me@ttaylorr.com> Signed-off-by: D. Ben Knoble <ben.knoble+github@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Junio C Hamano committed
Sep 28, 2025 at 17:29 UTC
666b29b58f7c95007fe0384737c1ff506b138136
1 file changed
+8
-8
t/t7500-commit-template-squash-signoff.sh
+8
-8
@@ -42,7 +42,7 @@ test_expect_success 'nonexistent template file in config should return error' '
42
(
43
GIT_EDITOR="echo hello >\"\$1\"" &&
44
export GIT_EDITOR &&
45
- test_must_fail git commit
45
+ test_must_fail git commit --allow-empty
46
)
47
'
48
@@ -50,33 +50,33 @@ test_expect_success 'nonexistent template file in config should return error' '
50
TEMPLATE="$PWD"/template
51
52
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"
55
'
56
57
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"
60
'
61
62
test_expect_success 'a Signed-off-by line by itself should not commit' '
63
(
64
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"
66
)
67
'
68
69
test_expect_success 'adding comments to a template should not commit' '
70
(
71
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"
73
)
74
'
75
76
test_expect_success 'adding real content to a template should commit' '
77
(
78
test_set_editor "$TEST_DIRECTORY"/t7500/add-content &&
79
- git commit --template "$TEMPLATE"
79
+ git commit --allow-empty --template "$TEMPLATE"
80
) &&
81
commit_msg_is "template linecommit message"
82
'