Welcome to mirror list, hosted at ThFree Co, Russian Federation.

t0007-git-var.sh « t - git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: eeb8539c1bcb2df86a5aff1fa2c78fc555598d14 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
#!/bin/sh

test_description='basic sanity checks for git var'

TEST_PASSES_SANITIZE_LEAK=true
. ./test-lib.sh

sane_unset_all_editors () {
	sane_unset GIT_EDITOR &&
	sane_unset VISUAL &&
	sane_unset EDITOR
}

test_expect_success 'get GIT_AUTHOR_IDENT' '
	test_tick &&
	echo "$GIT_AUTHOR_NAME <$GIT_AUTHOR_EMAIL> $GIT_AUTHOR_DATE" >expect &&
	git var GIT_AUTHOR_IDENT >actual &&
	test_cmp expect actual
'

test_expect_success 'get GIT_COMMITTER_IDENT' '
	test_tick &&
	echo "$GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE" >expect &&
	git var GIT_COMMITTER_IDENT >actual &&
	test_cmp expect actual
'

test_expect_success !FAIL_PREREQS,!AUTOIDENT 'requested identities are strict' '
	(
		sane_unset GIT_COMMITTER_NAME &&
		sane_unset GIT_COMMITTER_EMAIL &&
		test_must_fail git var GIT_COMMITTER_IDENT
	)
'

test_expect_success 'get GIT_DEFAULT_BRANCH without configuration' '
	(
		sane_unset GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME &&
		git init defbranch &&
		git -C defbranch symbolic-ref --short HEAD >expect &&
		git var GIT_DEFAULT_BRANCH >actual &&
		test_cmp expect actual
	)
'

test_expect_success 'get GIT_DEFAULT_BRANCH with configuration' '
	test_config init.defaultbranch foo &&
	(
		sane_unset GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME &&
		echo foo >expect &&
		git var GIT_DEFAULT_BRANCH >actual &&
		test_cmp expect actual
	)
'

test_expect_success 'get GIT_EDITOR without configuration' '
	(
		sane_unset_all_editors &&
		test_expect_code 1 git var GIT_EDITOR >out &&
		test_must_be_empty out
	)
'

test_expect_success 'get GIT_EDITOR with configuration' '
	test_config core.editor foo &&
	(
		sane_unset_all_editors &&
		echo foo >expect &&
		git var GIT_EDITOR >actual &&
		test_cmp expect actual
	)
'

test_expect_success 'get GIT_EDITOR with environment variable GIT_EDITOR' '
	(
		sane_unset_all_editors &&
		echo bar >expect &&
		GIT_EDITOR=bar git var GIT_EDITOR >actual &&
		test_cmp expect actual
	)
'

test_expect_success 'get GIT_EDITOR with environment variable EDITOR' '
	(
		sane_unset_all_editors &&
		echo bar >expect &&
		EDITOR=bar git var GIT_EDITOR >actual &&
		test_cmp expect actual
	)
'

test_expect_success 'get GIT_EDITOR with configuration and environment variable GIT_EDITOR' '
	test_config core.editor foo &&
	(
		sane_unset_all_editors &&
		echo bar >expect &&
		GIT_EDITOR=bar git var GIT_EDITOR >actual &&
		test_cmp expect actual
	)
'

test_expect_success 'get GIT_EDITOR with configuration and environment variable EDITOR' '
	test_config core.editor foo &&
	(
		sane_unset_all_editors &&
		echo foo >expect &&
		EDITOR=bar git var GIT_EDITOR >actual &&
		test_cmp expect actual
	)
'

test_expect_success 'get GIT_SEQUENCE_EDITOR without configuration' '
	(
		sane_unset GIT_SEQUENCE_EDITOR &&
		git var GIT_EDITOR >expect &&
		git var GIT_SEQUENCE_EDITOR >actual &&
		test_cmp expect actual
	)
'

test_expect_success 'get GIT_SEQUENCE_EDITOR with configuration' '
	test_config sequence.editor foo &&
	(
		sane_unset GIT_SEQUENCE_EDITOR &&
		echo foo >expect &&
		git var GIT_SEQUENCE_EDITOR >actual &&
		test_cmp expect actual
	)
'

test_expect_success 'get GIT_SEQUENCE_EDITOR with environment variable' '
	(
		sane_unset GIT_SEQUENCE_EDITOR &&
		echo bar >expect &&
		GIT_SEQUENCE_EDITOR=bar git var GIT_SEQUENCE_EDITOR >actual &&
		test_cmp expect actual
	)
'

test_expect_success 'get GIT_SEQUENCE_EDITOR with configuration and environment variable' '
	test_config sequence.editor foo &&
	(
		sane_unset GIT_SEQUENCE_EDITOR &&
		echo bar >expect &&
		GIT_SEQUENCE_EDITOR=bar git var GIT_SEQUENCE_EDITOR >actual &&
		test_cmp expect actual
	)
'

# For git var -l, we check only a representative variable;
# testing the whole output would make our test too brittle with
# respect to unrelated changes in the test suite's environment.
test_expect_success 'git var -l lists variables' '
	git var -l >actual &&
	echo "$GIT_AUTHOR_NAME <$GIT_AUTHOR_EMAIL> $GIT_AUTHOR_DATE" >expect &&
	sed -n s/GIT_AUTHOR_IDENT=//p <actual >actual.author &&
	test_cmp expect actual.author
'

test_expect_success 'git var -l lists config' '
	git var -l >actual &&
	echo false >expect &&
	sed -n s/core\\.bare=//p <actual >actual.bare &&
	test_cmp expect actual.bare
'

test_expect_success 'listing and asking for variables are exclusive' '
	test_must_fail git var -l GIT_COMMITTER_IDENT
'

test_done