]>
Commit | Line | Data |
---|---|---|
879ed753 JK |
1 | #!/bin/sh |
2 | ||
3 | test_description='basic sanity checks for git var' | |
c150064d ÆAB |
4 | |
5 | TEST_PASSES_SANITIZE_LEAK=true | |
879ed753 JK |
6 | . ./test-lib.sh |
7 | ||
8 | test_expect_success 'get GIT_AUTHOR_IDENT' ' | |
9 | test_tick && | |
10 | echo "$GIT_AUTHOR_NAME <$GIT_AUTHOR_EMAIL> $GIT_AUTHOR_DATE" >expect && | |
11 | git var GIT_AUTHOR_IDENT >actual && | |
12 | test_cmp expect actual | |
13 | ' | |
14 | ||
15 | test_expect_success 'get GIT_COMMITTER_IDENT' ' | |
16 | test_tick && | |
17 | echo "$GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE" >expect && | |
18 | git var GIT_COMMITTER_IDENT >actual && | |
19 | test_cmp expect actual | |
20 | ' | |
21 | ||
a1aba0c9 | 22 | test_expect_success !FAIL_PREREQS,!AUTOIDENT 'requested identities are strict' ' |
879ed753 JK |
23 | ( |
24 | sane_unset GIT_COMMITTER_NAME && | |
25 | sane_unset GIT_COMMITTER_EMAIL && | |
26 | test_must_fail git var GIT_COMMITTER_IDENT | |
27 | ) | |
28 | ' | |
29 | ||
e06c9e1d TW |
30 | test_expect_success 'get GIT_DEFAULT_BRANCH without configuration' ' |
31 | ( | |
32 | sane_unset GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME && | |
33 | git init defbranch && | |
34 | git -C defbranch symbolic-ref --short HEAD >expect && | |
35 | git var GIT_DEFAULT_BRANCH >actual && | |
36 | test_cmp expect actual | |
37 | ) | |
38 | ' | |
39 | ||
40 | test_expect_success 'get GIT_DEFAULT_BRANCH with configuration' ' | |
41 | test_config init.defaultbranch foo && | |
42 | ( | |
43 | sane_unset GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME && | |
44 | echo foo >expect && | |
45 | git var GIT_DEFAULT_BRANCH >actual && | |
46 | test_cmp expect actual | |
47 | ) | |
48 | ' | |
49 | ||
879ed753 JK |
50 | # For git var -l, we check only a representative variable; |
51 | # testing the whole output would make our test too brittle with | |
52 | # respect to unrelated changes in the test suite's environment. | |
53 | test_expect_success 'git var -l lists variables' ' | |
54 | git var -l >actual && | |
55 | echo "$GIT_AUTHOR_NAME <$GIT_AUTHOR_EMAIL> $GIT_AUTHOR_DATE" >expect && | |
56 | sed -n s/GIT_AUTHOR_IDENT=//p <actual >actual.author && | |
57 | test_cmp expect actual.author | |
58 | ' | |
59 | ||
60 | test_expect_success 'git var -l lists config' ' | |
61 | git var -l >actual && | |
62 | echo false >expect && | |
63 | sed -n s/core\\.bare=//p <actual >actual.bare && | |
64 | test_cmp expect actual.bare | |
65 | ' | |
66 | ||
67 | test_expect_success 'listing and asking for variables are exclusive' ' | |
68 | test_must_fail git var -l GIT_COMMITTER_IDENT | |
69 | ' | |
70 | ||
71 | test_done |