Skip to content

Commit

Permalink
t3509, t4023, t4114: use test_ln_s_add to remove SYMLINKS prerequisite
Browse files Browse the repository at this point in the history
In t4023 and t4114, we have to remove the entries using 'git rm' because
otherwise the entries that must turn from symbolic links to regular files
would stay symbolic links in the index. For the same reason, we have to
use 'git mv' instead of plain 'mv' in t3509.

Signed-off-by: Johannes Sixt <j6t@kdbg.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
Johannes Sixt authored and Junio C Hamano committed Jun 7, 2013
1 parent e40db07 commit 622f98e
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 36 deletions.
12 changes: 5 additions & 7 deletions t/t3509-cherry-pick-merge-df.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,25 +10,23 @@ test_expect_success 'Initialize repository' '
git commit -m a
'

test_expect_success SYMLINKS 'Setup rename across paths each below D/F conflicts' '
test_expect_success 'Setup rename across paths each below D/F conflicts' '
mkdir b &&
ln -s ../a b/a &&
git add b &&
test_ln_s_add ../a b/a &&
git commit -m b &&
git checkout -b branch &&
rm b/a &&
mv a b/a &&
ln -s b/a a &&
git add . &&
git mv a b/a &&
test_ln_s_add b/a a &&
git commit -m swap &&
>f1 &&
git add f1 &&
git commit -m f1
'

test_expect_success SYMLINKS 'Cherry-pick succeeds with rename across D/F conflicts' '
test_expect_success 'Cherry-pick succeeds with rename across D/F conflicts' '
git reset --hard &&
git checkout master^0 &&
git cherry-pick branch
Expand Down
28 changes: 14 additions & 14 deletions t/t4023-diff-rename-typechange.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,44 +4,44 @@ test_description='typechange rename detection'

. ./test-lib.sh

test_expect_success SYMLINKS setup '
test_expect_success setup '
rm -f foo bar &&
cat "$TEST_DIRECTORY"/../COPYING >foo &&
ln -s linklink bar &&
git add foo bar &&
test_ln_s_add linklink bar &&
git add foo &&
git commit -a -m Initial &&
git tag one &&
rm -f foo bar &&
git rm -f foo bar &&
cat "$TEST_DIRECTORY"/../COPYING >bar &&
ln -s linklink foo &&
git add foo bar &&
test_ln_s_add linklink foo &&
git add bar &&
git commit -a -m Second &&
git tag two &&
rm -f foo bar &&
git rm -f foo bar &&
cat "$TEST_DIRECTORY"/../COPYING >foo &&
git add foo &&
git commit -a -m Third &&
git tag three &&
mv foo bar &&
ln -s linklink foo &&
git add foo bar &&
test_ln_s_add linklink foo &&
git add bar &&
git commit -a -m Fourth &&
git tag four &&
# This is purely for sanity check
rm -f foo bar &&
git rm -f foo bar &&
cat "$TEST_DIRECTORY"/../COPYING >foo &&
cat "$TEST_DIRECTORY"/../Makefile >bar &&
git add foo bar &&
git commit -a -m Fifth &&
git tag five &&
rm -f foo bar &&
git rm -f foo bar &&
cat "$TEST_DIRECTORY"/../Makefile >foo &&
cat "$TEST_DIRECTORY"/../COPYING >bar &&
git add foo bar &&
Expand All @@ -50,7 +50,7 @@ test_expect_success SYMLINKS setup '
'

test_expect_success SYMLINKS 'cross renames to be detected for regular files' '
test_expect_success 'cross renames to be detected for regular files' '
git diff-tree five six -r --name-status -B -M | sort >actual &&
{
Expand All @@ -61,7 +61,7 @@ test_expect_success SYMLINKS 'cross renames to be detected for regular files' '
'

test_expect_success SYMLINKS 'cross renames to be detected for typechange' '
test_expect_success 'cross renames to be detected for typechange' '
git diff-tree one two -r --name-status -B -M | sort >actual &&
{
Expand All @@ -72,7 +72,7 @@ test_expect_success SYMLINKS 'cross renames to be detected for typechange' '
'

test_expect_success SYMLINKS 'moves and renames' '
test_expect_success 'moves and renames' '
git diff-tree three four -r --name-status -B -M | sort >actual &&
{
Expand Down
29 changes: 14 additions & 15 deletions t/t4114-apply-typechange.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,19 @@ test_description='git apply should not get confused with type changes.

. ./test-lib.sh

test_expect_success SYMLINKS 'setup repository and commits' '
test_expect_success 'setup repository and commits' '
echo "hello world" > foo &&
echo "hi planet" > bar &&
git update-index --add foo bar &&
git commit -m initial &&
git branch initial &&
rm -f foo &&
ln -s bar foo &&
git update-index foo &&
test_ln_s_add bar foo &&
git commit -m "foo symlinked to bar" &&
git branch foo-symlinked-to-bar &&
rm -f foo &&
git rm -f foo &&
echo "how far is the sun?" > foo &&
git update-index foo &&
git update-index --add foo &&
git commit -m "foo back to file" &&
git branch foo-back-to-file &&
printf "\0" > foo &&
Expand All @@ -42,77 +41,77 @@ test_expect_success SYMLINKS 'setup repository and commits' '
git branch foo-baz-renamed-from-foo
'

test_expect_success SYMLINKS 'file renamed from foo to foo/baz' '
test_expect_success 'file renamed from foo to foo/baz' '
git checkout -f initial &&
git diff-tree -M -p HEAD foo-baz-renamed-from-foo > patch &&
git apply --index < patch
'
test_debug 'cat patch'


test_expect_success SYMLINKS 'file renamed from foo/baz to foo' '
test_expect_success 'file renamed from foo/baz to foo' '
git checkout -f foo-baz-renamed-from-foo &&
git diff-tree -M -p HEAD initial > patch &&
git apply --index < patch
'
test_debug 'cat patch'


test_expect_success SYMLINKS 'directory becomes file' '
test_expect_success 'directory becomes file' '
git checkout -f foo-becomes-a-directory &&
git diff-tree -p HEAD initial > patch &&
git apply --index < patch
'
test_debug 'cat patch'


test_expect_success SYMLINKS 'file becomes directory' '
test_expect_success 'file becomes directory' '
git checkout -f initial &&
git diff-tree -p HEAD foo-becomes-a-directory > patch &&
git apply --index < patch
'
test_debug 'cat patch'


test_expect_success SYMLINKS 'file becomes symlink' '
test_expect_success 'file becomes symlink' '
git checkout -f initial &&
git diff-tree -p HEAD foo-symlinked-to-bar > patch &&
git apply --index < patch
'
test_debug 'cat patch'


test_expect_success SYMLINKS 'symlink becomes file' '
test_expect_success 'symlink becomes file' '
git checkout -f foo-symlinked-to-bar &&
git diff-tree -p HEAD foo-back-to-file > patch &&
git apply --index < patch
'
test_debug 'cat patch'

test_expect_success SYMLINKS 'binary file becomes symlink' '
test_expect_success 'binary file becomes symlink' '
git checkout -f foo-becomes-binary &&
git diff-tree -p --binary HEAD foo-symlinked-to-bar > patch &&
git apply --index < patch
'
test_debug 'cat patch'

test_expect_success SYMLINKS 'symlink becomes binary file' '
test_expect_success 'symlink becomes binary file' '
git checkout -f foo-symlinked-to-bar &&
git diff-tree -p --binary HEAD foo-becomes-binary > patch &&
git apply --index < patch
'
test_debug 'cat patch'


test_expect_success SYMLINKS 'symlink becomes directory' '
test_expect_success 'symlink becomes directory' '
git checkout -f foo-symlinked-to-bar &&
git diff-tree -p HEAD foo-becomes-a-directory > patch &&
git apply --index < patch
'
test_debug 'cat patch'


test_expect_success SYMLINKS 'directory becomes symlink' '
test_expect_success 'directory becomes symlink' '
git checkout -f foo-becomes-a-directory &&
git diff-tree -p HEAD foo-symlinked-to-bar > patch &&
git apply --index < patch
Expand Down

0 comments on commit 622f98e

Please sign in to comment.