]> git.ipfire.org Git - thirdparty/git.git/blame - t/t7518-ident-corner-cases.sh
Merge branch 'mg/editorconfig-makefile'
[thirdparty/git.git] / t / t7518-ident-corner-cases.sh
CommitLineData
862e80a4
JK
1#!/bin/sh
2
3test_description='corner cases in ident strings'
288a4806
ÆAB
4
5TEST_PASSES_SANITIZE_LEAK=true
862e80a4
JK
6. ./test-lib.sh
7
8# confirm that we do not segfault _and_ that we do not say "(null)", as
9# glibc systems will quietly handle our NULL pointer
10#
11# Note also that we can't use "env" here because we need to unset a variable,
12# and "-u" is not portable.
13test_expect_success 'empty name and missing email' '
14 (
15 sane_unset GIT_AUTHOR_EMAIL &&
16 GIT_AUTHOR_NAME= &&
17 test_must_fail git commit --allow-empty -m foo 2>err &&
6789275d 18 test_grep ! "(null)" err
862e80a4
JK
19 )
20'
21
13b9a24e 22test_expect_success 'commit rejects all-crud name' '
1c04cb07 23 test_must_fail env GIT_AUTHOR_NAME=" ,;<>" \
13b9a24e
JK
24 git commit --allow-empty -m foo
25'
26
1c04cb07 27test_expect_success 'commit does not strip trailing dot' '
28 author_name="Pat Doe Jr." &&
29 env GIT_AUTHOR_NAME="$author_name" \
30 git commit --allow-empty -m foo &&
31 git log -1 --format=%an >actual &&
32 echo "$author_name" >expected &&
33 test_cmp actual expected
34'
35
94425552
JK
36# We must test the actual error message here, as an unwanted
37# auto-detection could fail for other reasons.
38test_expect_success 'empty configured name does not auto-detect' '
39 (
40 sane_unset GIT_AUTHOR_NAME &&
41 test_must_fail \
42 git -c user.name= commit --allow-empty -m foo 2>err &&
6789275d
JH
43 test_grep "empty ident name" err &&
44 test_grep "Author identity unknown" err
9ed104e5
JH
45 )
46'
47
48test_expect_success 'empty configured name does not auto-detect for committer' '
49 (
50 sane_unset GIT_COMMITTER_NAME &&
51 test_must_fail \
52 git -c user.name= commit --allow-empty -m foo 2>err &&
6789275d
JH
53 test_grep "empty ident name" err &&
54 test_grep "Committer identity unknown" err
94425552
JK
55 )
56'
57
862e80a4 58test_done