blob: b22f631261f0a666ff5c4dc226be4f758f002709 [file] [log] [blame]
Jeff King862e80a2017-02-23 03:13:53 -05001#!/bin/sh
2
3test_description='corner cases in ident strings'
4. ./test-lib.sh
5
6# confirm that we do not segfault _and_ that we do not say "(null)", as
7# glibc systems will quietly handle our NULL pointer
8#
9# Note also that we can't use "env" here because we need to unset a variable,
10# and "-u" is not portable.
11test_expect_success 'empty name and missing email' '
12 (
13 sane_unset GIT_AUTHOR_EMAIL &&
14 GIT_AUTHOR_NAME= &&
15 test_must_fail git commit --allow-empty -m foo 2>err &&
16 test_i18ngrep ! null err
17 )
18'
19
Jeff King13b9a242017-02-23 03:15:55 -050020test_expect_success 'commit rejects all-crud name' '
21 test_must_fail env GIT_AUTHOR_NAME=" .;<>" \
22 git commit --allow-empty -m foo
23'
24
Jeff King94425552017-02-23 03:17:08 -050025# We must test the actual error message here, as an unwanted
26# auto-detection could fail for other reasons.
27test_expect_success 'empty configured name does not auto-detect' '
28 (
29 sane_unset GIT_AUTHOR_NAME &&
30 test_must_fail \
31 git -c user.name= commit --allow-empty -m foo 2>err &&
32 test_i18ngrep "empty ident name" err
33 )
34'
35
Jeff King862e80a2017-02-23 03:13:53 -050036test_done