]> git.ipfire.org Git - thirdparty/git.git/blob - t/t7518-ident-corner-cases.sh
ci: deprecate ci/config/allow-ref script
[thirdparty/git.git] / t / t7518-ident-corner-cases.sh
1 #!/bin/sh
2
3 test_description='corner cases in ident strings'
4
5 TEST_PASSES_SANITIZE_LEAK=true
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.
13 test_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 &&
18 test_i18ngrep ! "(null)" err
19 )
20 '
21
22 test_expect_success 'commit rejects all-crud name' '
23 test_must_fail env GIT_AUTHOR_NAME=" .;<>" \
24 git commit --allow-empty -m foo
25 '
26
27 # We must test the actual error message here, as an unwanted
28 # auto-detection could fail for other reasons.
29 test_expect_success 'empty configured name does not auto-detect' '
30 (
31 sane_unset GIT_AUTHOR_NAME &&
32 test_must_fail \
33 git -c user.name= commit --allow-empty -m foo 2>err &&
34 test_i18ngrep "empty ident name" err &&
35 test_i18ngrep "Author identity unknown" err
36 )
37 '
38
39 test_expect_success 'empty configured name does not auto-detect for committer' '
40 (
41 sane_unset GIT_COMMITTER_NAME &&
42 test_must_fail \
43 git -c user.name= commit --allow-empty -m foo 2>err &&
44 test_i18ngrep "empty ident name" err &&
45 test_i18ngrep "Committer identity unknown" err
46 )
47 '
48
49 test_done