Sync with 'maint'
[alt-git.git] / t / t7518-ident-corner-cases.sh
blobb37de0af49ff400e89b86271dd9b63b894dad56e
1 #!/bin/sh
3 test_description='corner cases in ident strings'
5 TEST_PASSES_SANITIZE_LEAK=true
6 . ./test-lib.sh
8 # confirm that we do not segfault _and_ that we do not say "(null)", as
9 # glibc systems will quietly handle our NULL pointer
11 # Note also that we can't use "env" here because we need to unset a variable,
12 # and "-u" is not portable.
13 test_expect_success 'empty name and missing email' '
15 sane_unset GIT_AUTHOR_EMAIL &&
16 GIT_AUTHOR_NAME= &&
17 test_must_fail git commit --allow-empty -m foo 2>err &&
18 test_grep ! "(null)" err
22 test_expect_success 'commit rejects all-crud name' '
23 test_must_fail env GIT_AUTHOR_NAME=" ,;<>" \
24 git commit --allow-empty -m foo
27 test_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
36 # We must test the actual error message here, as an unwanted
37 # auto-detection could fail for other reasons.
38 test_expect_success 'empty configured name does not auto-detect' '
40 sane_unset GIT_AUTHOR_NAME &&
41 test_must_fail \
42 git -c user.name= commit --allow-empty -m foo 2>err &&
43 test_grep "empty ident name" err &&
44 test_grep "Author identity unknown" err
48 test_expect_success 'empty configured name does not auto-detect for committer' '
50 sane_unset GIT_COMMITTER_NAME &&
51 test_must_fail \
52 git -c user.name= commit --allow-empty -m foo 2>err &&
53 test_grep "empty ident name" err &&
54 test_grep "Committer identity unknown" err
58 test_done