@@ -674,7 +674,6 @@ test_expect_success SYMLINKS 'difftool --dir-diff handles modified symlinks' '
674
674
rm c &&
675
675
ln -s d c &&
676
676
cat >expect <<-EOF &&
677
- b
678
677
c
679
678
680
679
c
@@ -710,7 +709,6 @@ test_expect_success SYMLINKS 'difftool --dir-diff handles modified symlinks' '
710
709
# Deleted symlinks
711
710
rm -f c &&
712
711
cat >expect <<-EOF &&
713
- b
714
712
c
715
713
716
714
EOF
@@ -723,6 +721,71 @@ test_expect_success SYMLINKS 'difftool --dir-diff handles modified symlinks' '
723
721
test_cmp expect actual
724
722
'
725
723
724
+ test_expect_success SYMLINKS ' difftool --dir-diff writes symlinks as raw text' '
725
+ # Start out on a branch called "branch-init".
726
+ git init -b branch-init symlink-files &&
727
+ (
728
+ cd symlink-files &&
729
+ # This test ensures that symlinks are written as raw text.
730
+ # The "cat" tools output link and file contents.
731
+ git config difftool.cat-left-link.cmd "cat \"\$LOCAL/link\"" &&
732
+ git config difftool.cat-left-a.cmd "cat \"\$LOCAL/file-a\"" &&
733
+ git config difftool.cat-right-link.cmd "cat \"\$REMOTE/link\"" &&
734
+ git config difftool.cat-right-b.cmd "cat \"\$REMOTE/file-b\"" &&
735
+
736
+ # Record the empty initial state so that we can come back here
737
+ # later and not have to consider the any cases where difftool
738
+ # will create symlinks back into the worktree.
739
+ test_tick &&
740
+ git commit --allow-empty -m init &&
741
+
742
+ # Create a file called "file-a" with a symlink pointing to it.
743
+ git switch -c branch-a &&
744
+ echo a >file-a &&
745
+ ln -s file-a link &&
746
+ git add file-a link &&
747
+ test_tick &&
748
+ git commit -m link-to-file-a &&
749
+
750
+ # Create a file called "file-b" and point the symlink to it.
751
+ git switch -c branch-b &&
752
+ echo b >file-b &&
753
+ rm link &&
754
+ ln -s file-b link &&
755
+ git add file-b link &&
756
+ git rm file-a &&
757
+ test_tick &&
758
+ git commit -m link-to-file-b &&
759
+
760
+ # Checkout the initial branch so that the --symlinks behavior is
761
+ # not activated. The two directories should be completely
762
+ # independent with no symlinks pointing back here.
763
+ git switch branch-init &&
764
+
765
+ # The left link must be "file-a" and "file-a" must contain "a".
766
+ echo file-a >expect &&
767
+ git difftool --symlinks --dir-diff --tool cat-left-link \
768
+ branch-a branch-b >actual &&
769
+ test_cmp expect actual &&
770
+
771
+ echo a >expect &&
772
+ git difftool --symlinks --dir-diff --tool cat-left-a \
773
+ branch-a branch-b >actual &&
774
+ test_cmp expect actual &&
775
+
776
+ # The right link must be "file-b" and "file-b" must contain "b".
777
+ echo file-b >expect &&
778
+ git difftool --symlinks --dir-diff --tool cat-right-link \
779
+ branch-a branch-b >actual &&
780
+ test_cmp expect actual &&
781
+
782
+ echo b >expect &&
783
+ git difftool --symlinks --dir-diff --tool cat-right-b \
784
+ branch-a branch-b >actual &&
785
+ test_cmp expect actual
786
+ )
787
+ '
788
+
726
789
test_expect_success ' add -N and difftool -d' '
727
790
test_when_finished git reset --hard &&
728
791
0 commit comments