Do not rely on the exit status of "unset" for unset variables
POSIX says that exit status "0" means that "unset" successfully unset the variable. However, it is kind of ambiguous if an environment variable which was not set could be successfully unset. At least the default shell on HP-UX insists on reporting an error in such a case, so just ignore the exit status of "unset". [Dscho: extended the patch to git-submodule.sh, as Junio realized that this is the only other place where we check the exit status of "unset".] Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
H.Merijn Brand committed
Dec 4, 2007 at 22:45 UTC
5188408057b31a604f00496582aa873054ad6746
2 files changed
+13
-13
git-submodule.sh
+5
-5
@@ -158,7 +158,7 @@ module_add()
158
die "'$path' already exists in the index"
159
160
module_clone "$path" "$realrepo" || exit
161
- (unset GIT_DIR && cd "$path" && git checkout -q ${branch:+-b "$branch" "origin/$branch"}) ||
161
+ (unset GIT_DIR; cd "$path" && git checkout -q ${branch:+-b "$branch" "origin/$branch"}) ||
162
die "Unable to checkout submodule '$path'"
163
git add "$path" ||
164
die "Failed to add submodule '$path'"
@@ -228,14 +228,14 @@ modules_update()
228
module_clone "$path" "$url" || exit
229
subsha1=
230
else
231
- subsha1=$(unset GIT_DIR && cd "$path" &&
231
+ subsha1=$(unset GIT_DIR; cd "$path" &&
232
git rev-parse --verify HEAD) ||
233
die "Unable to find current revision in submodule path '$path'"
234
fi
235
236
if test "$subsha1" != "$sha1"
237
then
238
- (unset GIT_DIR && cd "$path" && git-fetch &&
238
+ (unset GIT_DIR; cd "$path" && git-fetch &&
239
git-checkout -q "$sha1") ||
240
die "Unable to checkout '$sha1' in submodule path '$path'"
241
@@ -246,7 +246,7 @@ modules_update()
246
247
set_name_rev () {
248
revname=$( (
249
- unset GIT_DIR &&
249
+ unset GIT_DIR
250
cd "$1" && {
251
git describe "$2" 2>/dev/null ||
252
git describe --tags "$2" 2>/dev/null ||
@@ -285,7 +285,7 @@ modules_list()
285
else
286
if test -z "$cached"
287
then
288
- sha1=$(unset GIT_DIR && cd "$path" && git rev-parse --verify HEAD)
288
+ sha1=$(unset GIT_DIR; cd "$path" && git rev-parse --verify HEAD)
289
set_name_rev "$path" "$sha1"
290
fi
291
say "+$sha1 $path$revname"
t/t0001-init.sh
+8
-8
@@ -25,7 +25,7 @@ check_config () {
25
26
test_expect_success 'plain' '
27
(
28
- unset GIT_DIR GIT_WORK_TREE &&
28
+ unset GIT_DIR GIT_WORK_TREE
29
mkdir plain &&
30
cd plain &&
31
git init
@@ -35,7 +35,7 @@ test_expect_success 'plain' '
35
36
test_expect_success 'plain with GIT_WORK_TREE' '
37
if (
38
- unset GIT_DIR &&
38
+ unset GIT_DIR
39
mkdir plain-wt &&
40
cd plain-wt &&
41
GIT_WORK_TREE=$(pwd) git init
@@ -48,7 +48,7 @@ test_expect_success 'plain with GIT_WORK_TREE' '
48
49
test_expect_success 'plain bare' '
50
(
51
- unset GIT_DIR GIT_WORK_TREE GIT_CONFIG &&
51
+ unset GIT_DIR GIT_WORK_TREE GIT_CONFIG
52
mkdir plain-bare-1 &&
53
cd plain-bare-1 &&
54
git --bare init
@@ -58,7 +58,7 @@ test_expect_success 'plain bare' '
58
59
test_expect_success 'plain bare with GIT_WORK_TREE' '
60
if (
61
- unset GIT_DIR GIT_CONFIG &&
61
+ unset GIT_DIR GIT_CONFIG
62
mkdir plain-bare-2 &&
63
cd plain-bare-2 &&
64
GIT_WORK_TREE=$(pwd) git --bare init
@@ -72,7 +72,7 @@ test_expect_success 'plain bare with GIT_WORK_TREE' '
72
test_expect_success 'GIT_DIR bare' '
73
74
(
75
- unset GIT_CONFIG &&
75
+ unset GIT_CONFIG
76
mkdir git-dir-bare.git &&
77
GIT_DIR=git-dir-bare.git git init
78
) &&
@@ -82,7 +82,7 @@ test_expect_success 'GIT_DIR bare' '
82
test_expect_success 'GIT_DIR non-bare' '
83
84
(
85
- unset GIT_CONFIG &&
85
+ unset GIT_CONFIG
86
mkdir non-bare &&
87
cd non-bare &&
88
GIT_DIR=.git git init
@@ -93,7 +93,7 @@ test_expect_success 'GIT_DIR non-bare' '
93
test_expect_success 'GIT_DIR & GIT_WORK_TREE (1)' '
94
95
(
96
- unset GIT_CONFIG &&
96
+ unset GIT_CONFIG
97
mkdir git-dir-wt-1.git &&
98
GIT_WORK_TREE=$(pwd) GIT_DIR=git-dir-wt-1.git git init
99
) &&
@@ -103,7 +103,7 @@ test_expect_success 'GIT_DIR & GIT_WORK_TREE (1)' '
103
test_expect_success 'GIT_DIR & GIT_WORK_TREE (2)' '
104
105
if (
106
- unset GIT_CONFIG &&
106
+ unset GIT_CONFIG
107
mkdir git-dir-wt-2.git &&
108
GIT_WORK_TREE=$(pwd) GIT_DIR=git-dir-wt-2.git git --bare init
109
)