File tree 4 files changed +31
-16
lines changed
4 files changed +31
-16
lines changed Original file line number Diff line number Diff line change @@ -242,13 +242,6 @@ clean_mark () {
242
242
sort > $( basename " $1 " )
243
243
}
244
244
245
- cmp_marks () {
246
- test_when_finished " rm -rf git.marks testgit.marks" &&
247
- clean_mark " .git/testgit/$1 /git.marks" &&
248
- clean_mark " .git/testgit/$1 /testgit.marks" &&
249
- test_cmp git.marks testgit.marks
250
- }
251
-
252
245
test_expect_success ' proper failure checks for fetching' '
253
246
(cd local &&
254
247
test_must_fail env GIT_REMOTE_TESTGIT_FAILURE=1 git fetch 2>error &&
@@ -258,12 +251,15 @@ test_expect_success 'proper failure checks for fetching' '
258
251
'
259
252
260
253
test_expect_success ' proper failure checks for pushing' '
254
+ test_when_finished "rm -rf local/git.marks local/testgit.marks" &&
261
255
(cd local &&
262
256
git checkout -b crash master &&
263
257
echo crash >>file &&
264
258
git commit -a -m crash &&
265
259
test_must_fail env GIT_REMOTE_TESTGIT_FAILURE=1 git push --all &&
266
- cmp_marks origin
260
+ clean_mark ".git/testgit/origin/git.marks" &&
261
+ clean_mark ".git/testgit/origin/testgit.marks" &&
262
+ test_cmp git.marks testgit.marks
267
263
)
268
264
'
269
265
Original file line number Diff line number Diff line change @@ -174,9 +174,9 @@ test_expect_success 'mergetool skips autoresolved' '
174
174
'
175
175
176
176
test_expect_success ' mergetool merges all from subdir' '
177
+ test_config rerere.enabled false &&
177
178
(
178
179
cd subdir &&
179
- test_config rerere.enabled false &&
180
180
test_must_fail git merge master &&
181
181
( yes "r" | git mergetool ../submod ) &&
182
182
( yes "d" "d" | git mergetool --no-prompt ) &&
Original file line number Diff line number Diff line change @@ -492,12 +492,12 @@ test_expect_success PERL 'difftool --no-symlinks detects conflict ' '
492
492
493
493
test_expect_success PERL ' difftool properly honors gitlink and core.worktree' '
494
494
git submodule add ./. submod/ule &&
495
+ test_config -C submod/ule diff.tool checktrees &&
496
+ test_config -C submod/ule difftool.checktrees.cmd ' \' '
497
+ test -d "$LOCAL" && test -d "$REMOTE" && echo good
498
+ ' \' ' &&
495
499
(
496
500
cd submod/ule &&
497
- test_config diff.tool checktrees &&
498
- test_config difftool.checktrees.cmd ' \' '
499
- test -d "$LOCAL" && test -d "$REMOTE" && echo good
500
- ' \' ' &&
501
501
echo good >expect &&
502
502
git difftool --tool=checktrees --dir-diff HEAD~ >actual &&
503
503
test_cmp expect actual
Original file line number Diff line number Diff line change @@ -201,7 +201,14 @@ test_chmod () {
201
201
202
202
# Unset a configuration variable, but don't fail if it doesn't exist.
203
203
test_unconfig () {
204
- git config --unset-all " $@ "
204
+ config_dir=
205
+ if test " $1 " = -C
206
+ then
207
+ shift
208
+ config_dir=$1
209
+ shift
210
+ fi
211
+ git ${config_dir: +-C " $config_dir " } config --unset-all " $@ "
205
212
config_status=$?
206
213
case " $config_status " in
207
214
5) # ok, nothing to unset
@@ -213,8 +220,15 @@ test_unconfig () {
213
220
214
221
# Set git config, automatically unsetting it after the test is over.
215
222
test_config () {
216
- test_when_finished " test_unconfig '$1 '" &&
217
- git config " $@ "
223
+ config_dir=
224
+ if test " $1 " = -C
225
+ then
226
+ shift
227
+ config_dir=$1
228
+ shift
229
+ fi
230
+ test_when_finished " test_unconfig ${config_dir: +-C ' $config_dir' } '$1 '" &&
231
+ git ${config_dir: +-C " $config_dir " } config " $@ "
218
232
}
219
233
220
234
test_config_global () {
@@ -722,6 +736,11 @@ test_seq () {
722
736
# what went wrong.
723
737
724
738
test_when_finished () {
739
+ # We cannot detect when we are in a subshell in general, but by
740
+ # doing so on Bash is better than nothing (the test will
741
+ # silently pass on other shells).
742
+ test " ${BASH_SUBSHELL-0} " = 0 ||
743
+ error " bug in test script: test_when_finished does nothing in a subshell"
725
744
test_cleanup=" { $*
726
745
} && (exit \"\$ eval_ret\" ); eval_ret=\$ ?; $test_cleanup "
727
746
}
You can’t perform that action at this time.
0 commit comments