Skip to content

Commit

Permalink
Merge branch 'js/test-ln-s-add' into maint
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
Junio C Hamano committed Jul 19, 2013
2 parents 211e76d + 70836a6 commit 6ddc862
Show file tree
Hide file tree
Showing 30 changed files with 351 additions and 333 deletions.
14 changes: 14 additions & 0 deletions t/README
Original file line number Diff line number Diff line change
Expand Up @@ -595,6 +595,20 @@ library for your script to use.
test_cmp expected actual
'

- test_ln_s_add <path1> <path2>

This function helps systems whose filesystem does not support symbolic
links. Use it to add a symbolic link entry to the index when it is not
important that the file system entry is a symbolic link, i.e., instead
of the sequence

ln -s foo bar &&
git add bar

Sometimes it is possible to split a test in a part that does not need
the symbolic link in the file system and a part that does; then only
the latter part need be protected by a SYMLINKS prerequisite (see below).

Prerequisites
-------------

Expand Down
39 changes: 10 additions & 29 deletions t/t0000-basic.sh
Original file line number Diff line number Diff line change
Expand Up @@ -367,33 +367,14 @@ test_expect_success 'validate object ID of a known tree' '

# Various types of objects

# Some filesystems do not support symblic links; on such systems
# some expected values are different
if test_have_prereq SYMLINKS
then
expectfilter=cat
expectedtree=087704a96baf1c2d1c869a8b084481e121c88b5b
expectedptree1=21ae8269cacbe57ae09138dcc3a2887f904d02b3
expectedptree2=3c5e5399f3a333eddecce7a9b9465b63f65f51e2
else
expectfilter='grep -v sym'
expectedtree=8e18edf7d7edcf4371a3ac6ae5f07c2641db7c46
expectedptree1=cfb8591b2f65de8b8cc1020cd7d9e67e7793b325
expectedptree2=ce580448f0148b985a513b693fdf7d802cacb44f
fi


test_expect_success 'adding various types of objects with git update-index --add' '
mkdir path2 path3 path3/subp3 &&
paths="path0 path2/file2 path3/file3 path3/subp3/file3" &&
(
for p in $paths
do
echo "hello $p" >$p || exit 1
if test_have_prereq SYMLINKS
then
ln -s "hello $p" ${p}sym || exit 1
fi
test_ln_s_add "hello $p" ${p}sym || exit 1
done
) &&
find path* ! -type d -print | xargs git update-index --add
Expand All @@ -405,7 +386,7 @@ test_expect_success 'showing stage with git ls-files --stage' '
'

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

test_expect_success 'validate object ID for a known tree' '
test "$tree" = "$expectedtree"
test "$tree" = 087704a96baf1c2d1c869a8b084481e121c88b5b
'

test_expect_success 'showing tree with git ls-tree' '
git ls-tree $tree >current
'

test_expect_success SYMLINKS 'git ls-tree output for a known tree' '
test_expect_success 'git ls-tree output for a known tree' '
cat >expected <<-\EOF &&
100644 blob f87290f8eb2cbbea7857214459a0739927eab154 path0
120000 blob 15a98433ae33114b085f3eb3bb03b832b3180a01 path0sym
Expand All @@ -447,7 +428,7 @@ test_expect_success 'showing tree with git ls-tree -r' '
'

test_expect_success 'git ls-tree -r output for a known tree' '
$expectfilter >expected <<-\EOF &&
cat >expected <<-\EOF &&
100644 blob f87290f8eb2cbbea7857214459a0739927eab154 path0
120000 blob 15a98433ae33114b085f3eb3bb03b832b3180a01 path0sym
100644 blob 3feff949ed00a62d9f7af97c15cd8a30595e7ac7 path2/file2
Expand All @@ -465,7 +446,7 @@ test_expect_success 'showing tree with git ls-tree -r -t' '
git ls-tree -r -t $tree >current
'

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

test_expect_success 'validate object ID for a known tree' '
test "$ptree" = "$expectedptree1"
test "$ptree" = 21ae8269cacbe57ae09138dcc3a2887f904d02b3
'

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

test_expect_success 'validate object ID for a known tree' '
test "$ptree" = "$expectedptree2"
test "$ptree" = 3c5e5399f3a333eddecce7a9b9465b63f65f51e2
'

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

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

################################################################
P=$expectedtree
P=087704a96baf1c2d1c869a8b084481e121c88b5b

test_expect_success 'git commit-tree records the correct tree in a commit' '
commit0=$(echo NO | git commit-tree $P) &&
Expand Down
7 changes: 3 additions & 4 deletions t/t1004-read-tree-m-u-wf.sh
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ test_expect_success '3-way not overwriting local changes (their side)' '
'

test_expect_success SYMLINKS 'funny symlink in work tree' '
test_expect_success 'funny symlink in work tree' '
git reset --hard &&
git checkout -b sym-b side-b &&
Expand All @@ -170,15 +170,14 @@ test_expect_success SYMLINKS 'funny symlink in work tree' '
rm -fr a &&
git checkout -b sym-a side-a &&
mkdir -p a &&
ln -s ../b a/b &&
git add a/b &&
test_ln_s_add ../b a/b &&
git commit -m "we add a/b" &&
read_tree_u_must_succeed -m -u sym-a sym-a sym-b
'

test_expect_success SYMLINKS,SANITY 'funny symlink in work tree, un-unlink-able' '
test_expect_success SANITY 'funny symlink in work tree, un-unlink-able' '
rm -fr a b &&
git reset --hard &&
Expand Down
7 changes: 3 additions & 4 deletions t/t2001-checkout-cache-clash.sh
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,9 @@ test_expect_success \
'git read-tree -m $tree1 && git checkout-index -f -a'
test_debug 'show_files $tree1'

test_expect_success SYMLINKS \
'git update-index --add a symlink.' \
'ln -s path0 path1 &&
git update-index --add path1'
test_expect_success \
'add a symlink' \
'test_ln_s_add path0 path1'
test_expect_success \
'writing tree out with git write-tree' \
'tree3=$(git write-tree)'
Expand Down
5 changes: 2 additions & 3 deletions t/t2004-checkout-cache-temp.sh
Original file line number Diff line number Diff line change
Expand Up @@ -194,11 +194,10 @@ test_expect_success \
test $(cat ../$s1) = tree1asubdir/path5)
)'

test_expect_success SYMLINKS \
test_expect_success \
'checkout --temp symlink' '
rm -f path* .merge_* out .git/index &&
ln -s b a &&
git update-index --add a &&
test_ln_s_add b a &&
t4=$(git write-tree) &&
rm -f .git/index &&
git read-tree $t4 &&
Expand Down
12 changes: 6 additions & 6 deletions t/t2007-checkout-symlink.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ test_description='git checkout to switch between branches with symlink<->dir'

. ./test-lib.sh

test_expect_success SYMLINKS setup '
test_expect_success setup '
mkdir frotz &&
echo hello >frotz/filfre &&
Expand All @@ -25,25 +25,25 @@ test_expect_success SYMLINKS setup '
git rm --cached frotz/filfre &&
mv frotz xyzzy &&
ln -s xyzzy frotz &&
git add xyzzy/filfre frotz &&
test_ln_s_add xyzzy frotz &&
git add xyzzy/filfre &&
test_tick &&
git commit -m "side moves frotz/ to xyzzy/ and adds frotz->xyzzy/"
'

test_expect_success SYMLINKS 'switch from symlink to dir' '
test_expect_success 'switch from symlink to dir' '
git checkout master
'

test_expect_success SYMLINKS 'Remove temporary directories & switch to master' '
test_expect_success 'Remove temporary directories & switch to master' '
rm -fr frotz xyzzy nitfol &&
git checkout -f master
'

test_expect_success SYMLINKS 'switch from dir to symlink' '
test_expect_success 'switch from dir to symlink' '
git checkout side
Expand Down
12 changes: 8 additions & 4 deletions t/t2021-checkout-overwrite.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,21 +29,25 @@ test_expect_success 'checkout commit with dir must not remove untracked a/b' '
test -f a/b
'

test_expect_success SYMLINKS 'create a commit where dir a/b changed to symlink' '
test_expect_success 'create a commit where dir a/b changed to symlink' '
rm -rf a/b && # cleanup if previous test failed
git checkout -f -b symlink start &&
rm -rf a/b &&
ln -s foo a/b &&
git add -A &&
test_ln_s_add foo a/b &&
git commit -m "dir to symlink"
'

test_expect_success SYMLINKS 'checkout commit with dir must not remove untracked a/b' '
test_expect_success 'checkout commit with dir must not remove untracked a/b' '
git rm --cached a/b &&
git commit -m "un-track the symlink" &&
test_must_fail git checkout start &&
test_must_fail git checkout start
'

test_expect_success SYMLINKS 'the symlink remained' '
test -h a/b
'

Expand Down
5 changes: 2 additions & 3 deletions t/t2200-add-update.sh
Original file line number Diff line number Diff line change
Expand Up @@ -96,11 +96,10 @@ test_expect_success 'non-limited update in subdir leaves root alone' '
test_cmp expect actual
'

test_expect_success SYMLINKS 'replace a file with a symlink' '
test_expect_success 'replace a file with a symlink' '
rm foo &&
ln -s top foo &&
git add -u -- foo
test_ln_s_add top foo
'

Expand Down
Loading

0 comments on commit 6ddc862

Please sign in to comment.