@ -9,7 +9,8 @@ test_description='Test diff of symlinks.
@@ -9,7 +9,8 @@ test_description='Test diff of symlinks.
. ./test-lib.sh
. "$TEST_DIRECTORY"/diff-lib.sh
cat > expected << EOF
test_expect_success SYMLINKS 'diff new symlink' '
cat >expected <<-\EOF &&
diff --git a/frotz b/frotz
new file mode 120000
index 0000000..7c465af
@ -19,23 +20,22 @@ index 0000000..7c465af
@@ -19,23 +20,22 @@ index 0000000..7c465af
+xyzzy
\ No newline at end of file
EOF
test_expect_success SYMLINKS \
'diff new symlink' \
'ln -s xyzzy frotz &&
ln -s xyzzy frotz &&
git update-index &&
tree=$(git write-tree) &&
git update-index --add frotz &&
GIT_DIFF_OPTS=--unified=0 git diff-index -M -p $tree >current &&
compare_diff_patch current expected'
compare_diff_patch expected current
'
test_expect_success SYMLINKS \
'diff unchanged symlink' \
'tree=$(git write-tree) &&
test_expect_success SYMLINKS 'diff unchanged symlink' '
tree=$(git write-tree) &&
git update-index frotz &&
test -z "$(git diff-index --name-only $tree)"'
test -z "$(git diff-index --name-only $tree)"
'
cat > expected << EOF
test_expect_success SYMLINKS 'diff removed symlink' '
cat >expected <<-\EOF &&
diff --git a/frotz b/frotz
deleted file mode 120000
index 7c465af..0000000
@ -45,24 +45,22 @@ index 7c465af..0000000
@@ -45,24 +45,22 @@ index 7c465af..0000000
-xyzzy
\ No newline at end of file
EOF
test_expect_success SYMLINKS \
'diff removed symlink' \
'mv frotz frotz2 &&
mv frotz frotz2 &&
git diff-index -M -p $tree >current &&
compare_diff_patch current expected'
compare_diff_patch expected current
'
cat > expected << EOF
test_expect_success SYMLINKS 'diff identical, but newly created symlink' '
cat >expected <<-\EOF &&
diff --git a/frotz b/frotz
EOF
test_expect_success SYMLINKS \
'diff identical, but newly created symlink' \
'ln -s xyzzy frotz &&
ln -s xyzzy frotz &&
git diff-index -M -p $tree >current &&
compare_diff_patch current expected'
compare_diff_patch expected current
'
cat > expected << EOF
test_expect_success SYMLINKS 'diff different symlink' '
cat >expected <<-\EOF &&
diff --git a/frotz b/frotz
index 7c465af..df1db54 120000
--- a/frotz
@ -73,21 +71,19 @@ index 7c465af..df1db54 120000
@@ -73,21 +71,19 @@ index 7c465af..df1db54 120000
+yxyyz
\ No newline at end of file
EOF
test_expect_success SYMLINKS \
'diff different symlink' \
'rm frotz &&
rm -f frotz &&
ln -s yxyyz frotz &&
git diff-index -M -p $tree >current &&
compare_diff_patch current expected'
compare_diff_patch expected current
'
test_expect_success SYMLINKS \
'diff symlinks with non-existing targets' \
'ln -s narf pinky &&
test_expect_success SYMLINKS 'diff symlinks with non-existing targets' '
ln -s narf pinky &&
ln -s take\ over brain &&
test_must_fail git diff --no-index pinky brain >output 2>output.err &&
grep narf output &&
! grep error output.err'
! test -s output.err
'
test_expect_success SYMLINKS 'setup symlinks with attributes' '
echo "*.bin diff=bin" >>.gitattributes &&
@ -96,7 +92,8 @@ test_expect_success SYMLINKS 'setup symlinks with attributes' '
@@ -96,7 +92,8 @@ test_expect_success SYMLINKS 'setup symlinks with attributes' '
git add -N file.bin link.bin
'
cat >expect <<'EOF'
test_expect_success SYMLINKS 'symlinks do not respect userdiff config by path' '
cat >expect <<-\EOF &&
diff --git a/file.bin b/file.bin
index e69de29..d95f3ad 100644
Binary files a/file.bin and b/file.bin differ
@ -108,7 +105,6 @@ index e69de29..dce41ec 120000
@@ -108,7 +105,6 @@ index e69de29..dce41ec 120000
+file.bin
\ No newline at end of file
EOF
test_expect_success SYMLINKS 'symlinks do not respect userdiff config by path' '
git config diff.bin.binary true &&
git diff file.bin link.bin >actual &&
test_cmp expect actual