Skip to content

Commit f9c0181

Browse files
committed
t7502: test commit.status, --status and --no-status
Make sure that the status information: - is shown as before without configuration nor command line option; - is shown if commit.status is set to true and no command line option is given, or --status is explicitly given; - is not shown if commit.status is set to false and no command line option is given, or --no-status is explicitly given. Also make sure that the way lines taken from the custom --template appear in the log message editor is not changed at all. Signed-off-by: Junio C Hamano <[email protected]>
1 parent bed575e commit f9c0181

File tree

1 file changed

+109
-0
lines changed

1 file changed

+109
-0
lines changed

t/t7502-commit.sh

Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -267,4 +267,113 @@ test_expect_success 'A single-liner subject with a token plus colon is not a foo
267267
268268
'
269269

270+
cat >.git/FAKE_EDITOR <<EOF
271+
#!$SHELL_PATH
272+
mv "\$1" "\$1.orig"
273+
(
274+
echo message
275+
cat "\$1.orig"
276+
) >"\$1"
277+
EOF
278+
279+
echo '## Custom template' >template
280+
281+
clear_config () {
282+
(
283+
git config --unset-all "$1"
284+
case $? in
285+
0|5) exit 0 ;;
286+
*) exit 1 ;;
287+
esac
288+
)
289+
}
290+
291+
try_commit () {
292+
git reset --hard &&
293+
echo >>negative &&
294+
GIT_EDITOR=.git/FAKE_EDITOR git commit -a $* $use_template &&
295+
case "$use_template" in
296+
'')
297+
! grep "^## Custom template" .git/COMMIT_EDITMSG ;;
298+
*)
299+
grep "^## Custom template" .git/COMMIT_EDITMSG ;;
300+
esac
301+
}
302+
303+
try_commit_status_combo () {
304+
305+
test_expect_success 'commit' '
306+
clear_config commit.status &&
307+
try_commit "" &&
308+
grep "^# Changes to be committed:" .git/COMMIT_EDITMSG
309+
'
310+
311+
test_expect_success 'commit' '
312+
clear_config commit.status &&
313+
try_commit "" &&
314+
grep "^# Changes to be committed:" .git/COMMIT_EDITMSG
315+
'
316+
317+
test_expect_success 'commit --status' '
318+
clear_config commit.status &&
319+
try_commit --status &&
320+
grep "^# Changes to be committed:" .git/COMMIT_EDITMSG
321+
'
322+
323+
test_expect_success 'commit --no-status' '
324+
clear_config commit.status &&
325+
try_commit --no-status
326+
! grep "^# Changes to be committed:" .git/COMMIT_EDITMSG
327+
'
328+
329+
test_expect_success 'commit with commit.status = yes' '
330+
clear_config commit.status &&
331+
git config commit.status yes &&
332+
try_commit "" &&
333+
grep "^# Changes to be committed:" .git/COMMIT_EDITMSG
334+
'
335+
336+
test_expect_success 'commit with commit.status = no' '
337+
clear_config commit.status &&
338+
git config commit.status no &&
339+
try_commit "" &&
340+
! grep "^# Changes to be committed:" .git/COMMIT_EDITMSG
341+
'
342+
343+
test_expect_success 'commit --status with commit.status = yes' '
344+
clear_config commit.status &&
345+
git config commit.status yes &&
346+
try_commit --status &&
347+
grep "^# Changes to be committed:" .git/COMMIT_EDITMSG
348+
'
349+
350+
test_expect_success 'commit --no-status with commit.status = yes' '
351+
clear_config commit.status &&
352+
git config commit.status yes &&
353+
try_commit --no-status &&
354+
! grep "^# Changes to be committed:" .git/COMMIT_EDITMSG
355+
'
356+
357+
test_expect_success 'commit --status with commit.status = no' '
358+
clear_config commit.status &&
359+
git config commit.status no &&
360+
try_commit --status &&
361+
grep "^# Changes to be committed:" .git/COMMIT_EDITMSG
362+
'
363+
364+
test_expect_success 'commit --no-status with commit.status = no' '
365+
clear_config commit.status &&
366+
git config commit.status no &&
367+
try_commit --no-status &&
368+
! grep "^# Changes to be committed:" .git/COMMIT_EDITMSG
369+
'
370+
371+
}
372+
373+
try_commit_status_combo
374+
375+
use_template="-t template"
376+
377+
try_commit_status_combo
378+
270379
test_done

0 commit comments

Comments
 (0)