]>
Commit | Line | Data |
---|---|---|
862e80a4 JK |
1 | #!/bin/sh |
2 | ||
3 | test_description='corner cases in ident strings' | |
288a4806 ÆAB |
4 | |
5 | TEST_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. | |
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 && | |
6789275d | 18 | test_grep ! "(null)" err |
862e80a4 JK |
19 | ) |
20 | ' | |
21 | ||
13b9a24e | 22 | test_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 | 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 | |
34 | ' | |
35 | ||
94425552 JK |
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' ' | |
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 | ||
48 | test_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 | 58 | test_done |