unit-tests: do not mistake `.pdb` files for being executable
[git.git] / t / t0007-git-var.sh
blobeeb8539c1bcb2df86a5aff1fa2c78fc555598d14
1 #!/bin/sh
3 test_description='basic sanity checks for git var'
5 TEST_PASSES_SANITIZE_LEAK=true
6 . ./test-lib.sh
8 sane_unset_all_editors () {
9 sane_unset GIT_EDITOR &&
10 sane_unset VISUAL &&
11 sane_unset EDITOR
14 test_expect_success 'get GIT_AUTHOR_IDENT' '
15 test_tick &&
16 echo "$GIT_AUTHOR_NAME <$GIT_AUTHOR_EMAIL> $GIT_AUTHOR_DATE" >expect &&
17 git var GIT_AUTHOR_IDENT >actual &&
18 test_cmp expect actual
21 test_expect_success 'get GIT_COMMITTER_IDENT' '
22 test_tick &&
23 echo "$GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE" >expect &&
24 git var GIT_COMMITTER_IDENT >actual &&
25 test_cmp expect actual
28 test_expect_success !FAIL_PREREQS,!AUTOIDENT 'requested identities are strict' '
30 sane_unset GIT_COMMITTER_NAME &&
31 sane_unset GIT_COMMITTER_EMAIL &&
32 test_must_fail git var GIT_COMMITTER_IDENT
36 test_expect_success 'get GIT_DEFAULT_BRANCH without configuration' '
38 sane_unset GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME &&
39 git init defbranch &&
40 git -C defbranch symbolic-ref --short HEAD >expect &&
41 git var GIT_DEFAULT_BRANCH >actual &&
42 test_cmp expect actual
46 test_expect_success 'get GIT_DEFAULT_BRANCH with configuration' '
47 test_config init.defaultbranch foo &&
49 sane_unset GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME &&
50 echo foo >expect &&
51 git var GIT_DEFAULT_BRANCH >actual &&
52 test_cmp expect actual
56 test_expect_success 'get GIT_EDITOR without configuration' '
58 sane_unset_all_editors &&
59 test_expect_code 1 git var GIT_EDITOR >out &&
60 test_must_be_empty out
64 test_expect_success 'get GIT_EDITOR with configuration' '
65 test_config core.editor foo &&
67 sane_unset_all_editors &&
68 echo foo >expect &&
69 git var GIT_EDITOR >actual &&
70 test_cmp expect actual
74 test_expect_success 'get GIT_EDITOR with environment variable GIT_EDITOR' '
76 sane_unset_all_editors &&
77 echo bar >expect &&
78 GIT_EDITOR=bar git var GIT_EDITOR >actual &&
79 test_cmp expect actual
83 test_expect_success 'get GIT_EDITOR with environment variable EDITOR' '
85 sane_unset_all_editors &&
86 echo bar >expect &&
87 EDITOR=bar git var GIT_EDITOR >actual &&
88 test_cmp expect actual
92 test_expect_success 'get GIT_EDITOR with configuration and environment variable GIT_EDITOR' '
93 test_config core.editor foo &&
95 sane_unset_all_editors &&
96 echo bar >expect &&
97 GIT_EDITOR=bar git var GIT_EDITOR >actual &&
98 test_cmp expect actual
102 test_expect_success 'get GIT_EDITOR with configuration and environment variable EDITOR' '
103 test_config core.editor foo &&
105 sane_unset_all_editors &&
106 echo foo >expect &&
107 EDITOR=bar git var GIT_EDITOR >actual &&
108 test_cmp expect actual
112 test_expect_success 'get GIT_SEQUENCE_EDITOR without configuration' '
114 sane_unset GIT_SEQUENCE_EDITOR &&
115 git var GIT_EDITOR >expect &&
116 git var GIT_SEQUENCE_EDITOR >actual &&
117 test_cmp expect actual
121 test_expect_success 'get GIT_SEQUENCE_EDITOR with configuration' '
122 test_config sequence.editor foo &&
124 sane_unset GIT_SEQUENCE_EDITOR &&
125 echo foo >expect &&
126 git var GIT_SEQUENCE_EDITOR >actual &&
127 test_cmp expect actual
131 test_expect_success 'get GIT_SEQUENCE_EDITOR with environment variable' '
133 sane_unset GIT_SEQUENCE_EDITOR &&
134 echo bar >expect &&
135 GIT_SEQUENCE_EDITOR=bar git var GIT_SEQUENCE_EDITOR >actual &&
136 test_cmp expect actual
140 test_expect_success 'get GIT_SEQUENCE_EDITOR with configuration and environment variable' '
141 test_config sequence.editor foo &&
143 sane_unset GIT_SEQUENCE_EDITOR &&
144 echo bar >expect &&
145 GIT_SEQUENCE_EDITOR=bar git var GIT_SEQUENCE_EDITOR >actual &&
146 test_cmp expect actual
150 # For git var -l, we check only a representative variable;
151 # testing the whole output would make our test too brittle with
152 # respect to unrelated changes in the test suite's environment.
153 test_expect_success 'git var -l lists variables' '
154 git var -l >actual &&
155 echo "$GIT_AUTHOR_NAME <$GIT_AUTHOR_EMAIL> $GIT_AUTHOR_DATE" >expect &&
156 sed -n s/GIT_AUTHOR_IDENT=//p <actual >actual.author &&
157 test_cmp expect actual.author
160 test_expect_success 'git var -l lists config' '
161 git var -l >actual &&
162 echo false >expect &&
163 sed -n s/core\\.bare=//p <actual >actual.bare &&
164 test_cmp expect actual.bare
167 test_expect_success 'listing and asking for variables are exclusive' '
168 test_must_fail git var -l GIT_COMMITTER_IDENT
171 test_done