124
125
actual="$TRASH_DIRECTORY/actual"
126
127
+if test_have_prereq MINGW
128
+then
129
+ ROOT="$(pwd -W)"
130
+else
131
+ ROOT="$(pwd)"
132
+fi
133
+
134
test_expect_success 'setup for __gitdir tests' '
135
mkdir -p subdir/subsubdir &&
136
git init otherrepo
137
'
138
139
test_expect_success '__gitdir - from command line (through $__git_dir)' '
133
- echo "$TRASH_DIRECTORY/otherrepo/.git" >expected &&
140
+ echo "$ROOT/otherrepo/.git" >expected &&
141
(
135
- __git_dir="$TRASH_DIRECTORY/otherrepo/.git" &&
142
+ __git_dir="$ROOT/otherrepo/.git" &&
143
__gitdir >"$actual"
144
) &&
145
test_cmp expected "$actual"
164
'
165
166
test_expect_success '__gitdir - .git directory in parent' '
160
- echo "$(pwd -P)/.git" >expected &&
167
+ echo "$ROOT/.git" >expected &&
168
(
169
cd subdir/subsubdir &&
170
__gitdir >"$actual"
182
'
183
184
test_expect_success '__gitdir - parent is a .git directory' '
178
- echo "$(pwd -P)/.git" >expected &&
185
+ echo "$ROOT/.git" >expected &&
186
(
187
cd .git/refs/heads &&
188
__gitdir >"$actual"
191
'
192
193
test_expect_success '__gitdir - $GIT_DIR set while .git directory in cwd' '
187
- echo "$TRASH_DIRECTORY/otherrepo/.git" >expected &&
194
+ echo "$ROOT/otherrepo/.git" >expected &&
195
(
189
- GIT_DIR="$TRASH_DIRECTORY/otherrepo/.git" &&
196
+ GIT_DIR="$ROOT/otherrepo/.git" &&
197
export GIT_DIR &&
198
__gitdir >"$actual"
199
) &&
201
'
202
203
test_expect_success '__gitdir - $GIT_DIR set while .git directory in parent' '
197
- echo "$TRASH_DIRECTORY/otherrepo/.git" >expected &&
204
+ echo "$ROOT/otherrepo/.git" >expected &&
205
(
199
- GIT_DIR="$TRASH_DIRECTORY/otherrepo/.git" &&
206
+ GIT_DIR="$ROOT/otherrepo/.git" &&
207
export GIT_DIR &&
208
cd subdir &&
209
__gitdir >"$actual"
213
214
test_expect_success '__gitdir - non-existing $GIT_DIR' '
215
(
209
- GIT_DIR="$TRASH_DIRECTORY/non-existing" &&
216
+ GIT_DIR="$ROOT/non-existing" &&
217
export GIT_DIR &&
218
test_must_fail __gitdir
219
)
220
'
221
215
-function pwd_P_W () {
216
- if test_have_prereq MINGW
217
- then
218
- pwd -W
219
- else
220
- pwd -P
221
- fi
222
-}
223
-
222
test_expect_success '__gitdir - gitfile in cwd' '
225
- echo "$(pwd_P_W)/otherrepo/.git" >expected &&
226
- echo "gitdir: $(pwd_P_W)/otherrepo/.git" >subdir/.git &&
223
+ echo "$ROOT/otherrepo/.git" >expected &&
224
+ echo "gitdir: $ROOT/otherrepo/.git" >subdir/.git &&
225
test_when_finished "rm -f subdir/.git" &&
226
(
227
cd subdir &&
231
'
232
233
test_expect_success '__gitdir - gitfile in parent' '
236
- echo "$(pwd_P_W)/otherrepo/.git" >expected &&
237
- echo "gitdir: $(pwd_P_W)/otherrepo/.git" >subdir/.git &&
234
+ echo "$ROOT/otherrepo/.git" >expected &&
235
+ echo "gitdir: $ROOT/otherrepo/.git" >subdir/.git &&
236
test_when_finished "rm -f subdir/.git" &&
237
(
238
cd subdir/subsubdir &&
242
'
243
244
test_expect_success SYMLINKS '__gitdir - resulting path avoids symlinks' '
247
- echo "$(pwd -P)/otherrepo/.git" >expected &&
245
+ echo "$ROOT/otherrepo/.git" >expected &&
246
mkdir otherrepo/dir &&
247
test_when_finished "rm -rf otherrepo/dir" &&
248
ln -s otherrepo/dir link &&