Skip to content

Commit 6ddc862

Browse files
committed
Merge branch 'js/test-ln-s-add' into maint
* js/test-ln-s-add: t4011: remove SYMLINKS prerequisite t6035: use test_ln_s_add to remove SYMLINKS prerequisite t3509, t4023, t4114: use test_ln_s_add to remove SYMLINKS prerequisite t3100: use test_ln_s_add to remove SYMLINKS prerequisite t3030: use test_ln_s_add to remove SYMLINKS prerequisite t0000: use test_ln_s_add to remove SYMLINKS prerequisite tests: use test_ln_s_add to remove SYMLINKS prerequisite (trivial cases) tests: introduce test_ln_s_add t3010: modernize style test-chmtime: Fix exit code on Windows
2 parents 211e76d + 70836a6 commit 6ddc862

30 files changed

+351
-333
lines changed

t/README

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -595,6 +595,20 @@ library for your script to use.
595595
test_cmp expected actual
596596
'
597597

598+
- test_ln_s_add <path1> <path2>
599+
600+
This function helps systems whose filesystem does not support symbolic
601+
links. Use it to add a symbolic link entry to the index when it is not
602+
important that the file system entry is a symbolic link, i.e., instead
603+
of the sequence
604+
605+
ln -s foo bar &&
606+
git add bar
607+
608+
Sometimes it is possible to split a test in a part that does not need
609+
the symbolic link in the file system and a part that does; then only
610+
the latter part need be protected by a SYMLINKS prerequisite (see below).
611+
598612
Prerequisites
599613
-------------
600614

t/t0000-basic.sh

Lines changed: 10 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -367,33 +367,14 @@ test_expect_success 'validate object ID of a known tree' '
367367

368368
# Various types of objects
369369

370-
# Some filesystems do not support symblic links; on such systems
371-
# some expected values are different
372-
if test_have_prereq SYMLINKS
373-
then
374-
expectfilter=cat
375-
expectedtree=087704a96baf1c2d1c869a8b084481e121c88b5b
376-
expectedptree1=21ae8269cacbe57ae09138dcc3a2887f904d02b3
377-
expectedptree2=3c5e5399f3a333eddecce7a9b9465b63f65f51e2
378-
else
379-
expectfilter='grep -v sym'
380-
expectedtree=8e18edf7d7edcf4371a3ac6ae5f07c2641db7c46
381-
expectedptree1=cfb8591b2f65de8b8cc1020cd7d9e67e7793b325
382-
expectedptree2=ce580448f0148b985a513b693fdf7d802cacb44f
383-
fi
384-
385-
386370
test_expect_success 'adding various types of objects with git update-index --add' '
387371
mkdir path2 path3 path3/subp3 &&
388372
paths="path0 path2/file2 path3/file3 path3/subp3/file3" &&
389373
(
390374
for p in $paths
391375
do
392376
echo "hello $p" >$p || exit 1
393-
if test_have_prereq SYMLINKS
394-
then
395-
ln -s "hello $p" ${p}sym || exit 1
396-
fi
377+
test_ln_s_add "hello $p" ${p}sym || exit 1
397378
done
398379
) &&
399380
find path* ! -type d -print | xargs git update-index --add
@@ -405,7 +386,7 @@ test_expect_success 'showing stage with git ls-files --stage' '
405386
'
406387

407388
test_expect_success 'validate git ls-files output for a known tree' '
408-
$expectfilter >expected <<-\EOF &&
389+
cat >expected <<-\EOF &&
409390
100644 f87290f8eb2cbbea7857214459a0739927eab154 0 path0
410391
120000 15a98433ae33114b085f3eb3bb03b832b3180a01 0 path0sym
411392
100644 3feff949ed00a62d9f7af97c15cd8a30595e7ac7 0 path2/file2
@@ -423,14 +404,14 @@ test_expect_success 'writing tree out with git write-tree' '
423404
'
424405

425406
test_expect_success 'validate object ID for a known tree' '
426-
test "$tree" = "$expectedtree"
407+
test "$tree" = 087704a96baf1c2d1c869a8b084481e121c88b5b
427408
'
428409

429410
test_expect_success 'showing tree with git ls-tree' '
430411
git ls-tree $tree >current
431412
'
432413

433-
test_expect_success SYMLINKS 'git ls-tree output for a known tree' '
414+
test_expect_success 'git ls-tree output for a known tree' '
434415
cat >expected <<-\EOF &&
435416
100644 blob f87290f8eb2cbbea7857214459a0739927eab154 path0
436417
120000 blob 15a98433ae33114b085f3eb3bb03b832b3180a01 path0sym
@@ -447,7 +428,7 @@ test_expect_success 'showing tree with git ls-tree -r' '
447428
'
448429

449430
test_expect_success 'git ls-tree -r output for a known tree' '
450-
$expectfilter >expected <<-\EOF &&
431+
cat >expected <<-\EOF &&
451432
100644 blob f87290f8eb2cbbea7857214459a0739927eab154 path0
452433
120000 blob 15a98433ae33114b085f3eb3bb03b832b3180a01 path0sym
453434
100644 blob 3feff949ed00a62d9f7af97c15cd8a30595e7ac7 path2/file2
@@ -465,7 +446,7 @@ test_expect_success 'showing tree with git ls-tree -r -t' '
465446
git ls-tree -r -t $tree >current
466447
'
467448

468-
test_expect_success SYMLINKS 'git ls-tree -r output for a known tree' '
449+
test_expect_success 'git ls-tree -r output for a known tree' '
469450
cat >expected <<-\EOF &&
470451
100644 blob f87290f8eb2cbbea7857214459a0739927eab154 path0
471452
120000 blob 15a98433ae33114b085f3eb3bb03b832b3180a01 path0sym
@@ -487,15 +468,15 @@ test_expect_success 'writing partial tree out with git write-tree --prefix' '
487468
'
488469

489470
test_expect_success 'validate object ID for a known tree' '
490-
test "$ptree" = "$expectedptree1"
471+
test "$ptree" = 21ae8269cacbe57ae09138dcc3a2887f904d02b3
491472
'
492473

493474
test_expect_success 'writing partial tree out with git write-tree --prefix' '
494475
ptree=$(git write-tree --prefix=path3/subp3)
495476
'
496477

497478
test_expect_success 'validate object ID for a known tree' '
498-
test "$ptree" = "$expectedptree2"
479+
test "$ptree" = 3c5e5399f3a333eddecce7a9b9465b63f65f51e2
499480
'
500481

501482
test_expect_success 'put invalid objects into the index' '
@@ -529,7 +510,7 @@ test_expect_success 'git read-tree followed by write-tree should be idempotent'
529510
'
530511

531512
test_expect_success 'validate git diff-files output for a know cache/work tree state' '
532-
$expectfilter >expected <<\EOF &&
513+
cat >expected <<\EOF &&
533514
:100644 100644 f87290f8eb2cbbea7857214459a0739927eab154 0000000000000000000000000000000000000000 M path0
534515
:120000 120000 15a98433ae33114b085f3eb3bb03b832b3180a01 0000000000000000000000000000000000000000 M path0sym
535516
:100644 100644 3feff949ed00a62d9f7af97c15cd8a30595e7ac7 0000000000000000000000000000000000000000 M path2/file2
@@ -553,7 +534,7 @@ test_expect_success 'no diff after checkout and git update-index --refresh' '
553534
'
554535

555536
################################################################
556-
P=$expectedtree
537+
P=087704a96baf1c2d1c869a8b084481e121c88b5b
557538

558539
test_expect_success 'git commit-tree records the correct tree in a commit' '
559540
commit0=$(echo NO | git commit-tree $P) &&

t/t1004-read-tree-m-u-wf.sh

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ test_expect_success '3-way not overwriting local changes (their side)' '
158158
159159
'
160160

161-
test_expect_success SYMLINKS 'funny symlink in work tree' '
161+
test_expect_success 'funny symlink in work tree' '
162162
163163
git reset --hard &&
164164
git checkout -b sym-b side-b &&
@@ -170,15 +170,14 @@ test_expect_success SYMLINKS 'funny symlink in work tree' '
170170
rm -fr a &&
171171
git checkout -b sym-a side-a &&
172172
mkdir -p a &&
173-
ln -s ../b a/b &&
174-
git add a/b &&
173+
test_ln_s_add ../b a/b &&
175174
git commit -m "we add a/b" &&
176175
177176
read_tree_u_must_succeed -m -u sym-a sym-a sym-b
178177
179178
'
180179

181-
test_expect_success SYMLINKS,SANITY 'funny symlink in work tree, un-unlink-able' '
180+
test_expect_success SANITY 'funny symlink in work tree, un-unlink-able' '
182181
183182
rm -fr a b &&
184183
git reset --hard &&

t/t2001-checkout-cache-clash.sh

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,9 @@ test_expect_success \
5959
'git read-tree -m $tree1 && git checkout-index -f -a'
6060
test_debug 'show_files $tree1'
6161

62-
test_expect_success SYMLINKS \
63-
'git update-index --add a symlink.' \
64-
'ln -s path0 path1 &&
65-
git update-index --add path1'
62+
test_expect_success \
63+
'add a symlink' \
64+
'test_ln_s_add path0 path1'
6665
test_expect_success \
6766
'writing tree out with git write-tree' \
6867
'tree3=$(git write-tree)'

t/t2004-checkout-cache-temp.sh

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -194,11 +194,10 @@ test_expect_success \
194194
test $(cat ../$s1) = tree1asubdir/path5)
195195
)'
196196

197-
test_expect_success SYMLINKS \
197+
test_expect_success \
198198
'checkout --temp symlink' '
199199
rm -f path* .merge_* out .git/index &&
200-
ln -s b a &&
201-
git update-index --add a &&
200+
test_ln_s_add b a &&
202201
t4=$(git write-tree) &&
203202
rm -f .git/index &&
204203
git read-tree $t4 &&

t/t2007-checkout-symlink.sh

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ test_description='git checkout to switch between branches with symlink<->dir'
66

77
. ./test-lib.sh
88

9-
test_expect_success SYMLINKS setup '
9+
test_expect_success setup '
1010
1111
mkdir frotz &&
1212
echo hello >frotz/filfre &&
@@ -25,25 +25,25 @@ test_expect_success SYMLINKS setup '
2525
2626
git rm --cached frotz/filfre &&
2727
mv frotz xyzzy &&
28-
ln -s xyzzy frotz &&
29-
git add xyzzy/filfre frotz &&
28+
test_ln_s_add xyzzy frotz &&
29+
git add xyzzy/filfre &&
3030
test_tick &&
3131
git commit -m "side moves frotz/ to xyzzy/ and adds frotz->xyzzy/"
3232
3333
'
3434

35-
test_expect_success SYMLINKS 'switch from symlink to dir' '
35+
test_expect_success 'switch from symlink to dir' '
3636
3737
git checkout master
3838
3939
'
4040

41-
test_expect_success SYMLINKS 'Remove temporary directories & switch to master' '
41+
test_expect_success 'Remove temporary directories & switch to master' '
4242
rm -fr frotz xyzzy nitfol &&
4343
git checkout -f master
4444
'
4545

46-
test_expect_success SYMLINKS 'switch from dir to symlink' '
46+
test_expect_success 'switch from dir to symlink' '
4747
4848
git checkout side
4949

t/t2021-checkout-overwrite.sh

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,21 +29,25 @@ test_expect_success 'checkout commit with dir must not remove untracked a/b' '
2929
test -f a/b
3030
'
3131

32-
test_expect_success SYMLINKS 'create a commit where dir a/b changed to symlink' '
32+
test_expect_success 'create a commit where dir a/b changed to symlink' '
3333
3434
rm -rf a/b && # cleanup if previous test failed
3535
git checkout -f -b symlink start &&
3636
rm -rf a/b &&
37-
ln -s foo a/b &&
3837
git add -A &&
38+
test_ln_s_add foo a/b &&
3939
git commit -m "dir to symlink"
4040
'
4141

42-
test_expect_success SYMLINKS 'checkout commit with dir must not remove untracked a/b' '
42+
test_expect_success 'checkout commit with dir must not remove untracked a/b' '
4343
4444
git rm --cached a/b &&
4545
git commit -m "un-track the symlink" &&
46-
test_must_fail git checkout start &&
46+
test_must_fail git checkout start
47+
'
48+
49+
test_expect_success SYMLINKS 'the symlink remained' '
50+
4751
test -h a/b
4852
'
4953

t/t2200-add-update.sh

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,11 +96,10 @@ test_expect_success 'non-limited update in subdir leaves root alone' '
9696
test_cmp expect actual
9797
'
9898

99-
test_expect_success SYMLINKS 'replace a file with a symlink' '
99+
test_expect_success 'replace a file with a symlink' '
100100
101101
rm foo &&
102-
ln -s top foo &&
103-
git add -u -- foo
102+
test_ln_s_add top foo
104103
105104
'
106105

0 commit comments

Comments
 (0)