Skip to content

Commit 69ae92b

Browse files
committed
shell portability: no "export VAR=VAL"
It is more portable to say "VAR=VAL && export VAR" instead. Noticed by Ævar. Signed-off-by: Junio C Hamano <[email protected]>
1 parent bc97994 commit 69ae92b

File tree

6 files changed

+23
-23
lines changed

6 files changed

+23
-23
lines changed

git-am.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ It does not apply to blobs recorded in its index."
137137
export GITHEAD_$his_tree
138138
if test -n "$GIT_QUIET"
139139
then
140-
export GIT_MERGE_VERBOSITY=0
140+
GIT_MERGE_VERBOSITY=0 && export GIT_MERGE_VERBOSITY
141141
fi
142142
git-merge-recursive $orig_tree -- HEAD $his_tree || {
143143
git rerere $allow_rerere_autoupdate

git-rebase.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ call_merge () {
111111
export GITHEAD_$cmt GITHEAD_$hd
112112
if test -n "$GIT_QUIET"
113113
then
114-
export GIT_MERGE_VERBOSITY=1
114+
GIT_MERGE_VERBOSITY=1 && export GIT_MERGE_VERBOSITY
115115
fi
116116
eval 'git-merge-$strategy' $strategy_opts '"$cmt^" -- "$hd" "$cmt"'
117117
rv=$?

git-stash.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -373,7 +373,7 @@ apply_stash () {
373373

374374
if test -n "$GIT_QUIET"
375375
then
376-
export GIT_MERGE_VERBOSITY=0
376+
GIT_MERGE_VERBOSITY=0 && export GIT_MERGE_VERBOSITY
377377
fi
378378
if git merge-recursive $b_tree -- $c_tree $w_tree
379379
then

t/t1509-root-worktree.sh

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -134,8 +134,8 @@ cat >ls.expected <<EOF
134134
100644 $ONE_SHA1 0 me
135135
EOF
136136

137-
export GIT_DIR="$TRASH_DIRECTORY/.git"
138-
export GIT_WORK_TREE=/
137+
GIT_DIR="$TRASH_DIRECTORY/.git" && export GIT_DIR
138+
GIT_WORK_TREE=/ && export GIT_WORK_TREE
139139

140140
test_vars 'abs gitdir, root' "$GIT_DIR" "/" ""
141141
test_foobar_root
@@ -154,24 +154,24 @@ say "GIT_DIR relative, GIT_WORK_TREE set"
154154

155155
test_expect_success 'go to /' 'cd /'
156156

157-
export GIT_DIR="$(echo $TRASH_DIRECTORY|sed 's,^/,,')/.git"
158-
export GIT_WORK_TREE=/
157+
GIT_DIR="$(echo $TRASH_DIRECTORY|sed 's,^/,,')/.git" && export GIT_DIR
158+
GIT_WORK_TREE=/ && export GIT_WORK_TREE
159159

160160
test_vars 'rel gitdir, root' "$GIT_DIR" "/" ""
161161
test_foobar_root
162162

163163
test_expect_success 'go to /foo' 'cd /foo'
164164

165-
export GIT_DIR="../$TRASH_DIRECTORY/.git"
166-
export GIT_WORK_TREE=/
165+
GIT_DIR="../$TRASH_DIRECTORY/.git" && export GIT_DIR
166+
GIT_WORK_TREE=/ && export GIT_WORK_TREE
167167

168168
test_vars 'rel gitdir, foo' "$TRASH_DIRECTORY/.git" "/" "foo/"
169169
test_foobar_foo
170170

171171
test_expect_success 'go to /foo/bar' 'cd /foo/bar'
172172

173-
export GIT_DIR="../../$TRASH_DIRECTORY/.git"
174-
export GIT_WORK_TREE=/
173+
GIT_DIR="../../$TRASH_DIRECTORY/.git" && export GIT_DIR
174+
GIT_WORK_TREE=/ && export GIT_WORK_TREE
175175

176176
test_vars 'rel gitdir, foo/bar' "$TRASH_DIRECTORY/.git" "/" "foo/bar/"
177177
test_foobar_foobar
@@ -180,24 +180,24 @@ say "GIT_DIR relative, GIT_WORK_TREE relative"
180180

181181
test_expect_success 'go to /' 'cd /'
182182

183-
export GIT_DIR="$(echo $TRASH_DIRECTORY|sed 's,^/,,')/.git"
184-
export GIT_WORK_TREE=.
183+
GIT_DIR="$(echo $TRASH_DIRECTORY|sed 's,^/,,')/.git" && export GIT_DIR
184+
GIT_WORK_TREE=. && export GIT_WORK_TREE
185185

186186
test_vars 'rel gitdir, root' "$GIT_DIR" "/" ""
187187
test_foobar_root
188188

189189
test_expect_success 'go to /' 'cd /foo'
190190

191-
export GIT_DIR="../$TRASH_DIRECTORY/.git"
192-
export GIT_WORK_TREE=..
191+
GIT_DIR="../$TRASH_DIRECTORY/.git" && export GIT_DIR
192+
GIT_WORK_TREE=.. && export GIT_WORK_TREE
193193

194194
test_vars 'rel gitdir, foo' "$TRASH_DIRECTORY/.git" "/" "foo/"
195195
test_foobar_foo
196196

197197
test_expect_success 'go to /foo/bar' 'cd /foo/bar'
198198

199-
export GIT_DIR="../../$TRASH_DIRECTORY/.git"
200-
export GIT_WORK_TREE=../..
199+
GIT_DIR="../../$TRASH_DIRECTORY/.git" && export GIT_DIR
200+
GIT_WORK_TREE=../.. && export GIT_WORK_TREE
201201

202202
test_vars 'rel gitdir, foo/bar' "$TRASH_DIRECTORY/.git" "/" "foo/bar/"
203203
test_foobar_foobar

t/t5560-http-backend-noserver.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ run_backend() {
1414
}
1515

1616
GET() {
17-
export REQUEST_METHOD="GET" &&
17+
REQUEST_METHOD="GET" && export REQUEST_METHOD &&
1818
run_backend "/repo.git/$1" &&
1919
unset REQUEST_METHOD &&
2020
if ! grep "Status" act.out >act
@@ -26,8 +26,8 @@ GET() {
2626
}
2727

2828
POST() {
29-
export REQUEST_METHOD="POST" &&
30-
export CONTENT_TYPE="application/x-$1-request" &&
29+
REQUEST_METHOD="POST" && export REQUEST_METHOD &&
30+
CONTENT_TYPE="application/x-$1-request" && export CONTENT_TYPE &&
3131
run_backend "/repo.git/$1" "$2" &&
3232
unset REQUEST_METHOD &&
3333
unset CONTENT_TYPE &&
@@ -46,7 +46,7 @@ log_div() {
4646
. "$TEST_DIRECTORY"/t556x_common
4747

4848
expect_aliased() {
49-
export REQUEST_METHOD="GET" &&
49+
REQUEST_METHOD="GET" && export REQUEST_METHOD &&
5050
if test $1 = 0; then
5151
run_backend "$2"
5252
else

t/t556x_common

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ get_static_files() {
5050
}
5151

5252
SMART=smart
53-
export GIT_HTTP_EXPORT_ALL=1
53+
GIT_HTTP_EXPORT_ALL=1 && export GIT_HTTP_EXPORT_ALL
5454
test_expect_success 'direct refs/heads/master not found' '
5555
log_div "refs/heads/master"
5656
GET refs/heads/master "404 Not Found"
@@ -73,7 +73,7 @@ test_expect_success 'export if git-daemon-export-ok' '
7373
get_static_files "200 OK"
7474
'
7575
SMART=smart
76-
export GIT_HTTP_EXPORT_ALL=1
76+
GIT_HTTP_EXPORT_ALL=1 && export GIT_HTTP_EXPORT_ALL
7777
test_expect_success 'static file if http.getanyfile true is ok' '
7878
log_div "getanyfile true"
7979
config http.getanyfile true &&

0 commit comments

Comments
 (0)