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