t / t4004-diff-rename-symlink.shon commit Merge branch 'bw/diff-metainfo-color' (448598b)
   1#!/bin/sh
   2#
   3# Copyright (c) 2005 Junio C Hamano
   4#
   5
   6test_description='More rename detection tests.
   7
   8The rename detection logic should be able to detect pure rename or
   9copy of symbolic links, but should not produce rename/copy followed
  10by an edit for them.
  11'
  12. ./test-lib.sh
  13. "$TEST_DIRECTORY"/diff-lib.sh
  14
  15if ! test_have_prereq SYMLINKS
  16then
  17        say 'Symbolic links not supported, skipping tests.'
  18        test_done
  19fi
  20
  21test_expect_success \
  22    'prepare reference tree' \
  23    'echo xyzzy | tr -d '\\\\'012 >yomin &&
  24     ln -s xyzzy frotz &&
  25    git update-index --add frotz yomin &&
  26    tree=$(git write-tree) &&
  27    echo $tree'
  28
  29test_expect_success \
  30    'prepare work tree' \
  31    'mv frotz rezrov &&
  32     rm -f yomin &&
  33     ln -s xyzzy nitfol &&
  34     ln -s xzzzy bozbar &&
  35    git update-index --add --remove frotz rezrov nitfol bozbar yomin'
  36
  37# tree has frotz pointing at xyzzy, and yomin that contains xyzzy to
  38# confuse things.  work tree has rezrov (xyzzy) nitfol (xyzzy) and
  39# bozbar (xzzzy).
  40# rezrov and nitfol are rename/copy of frotz and bozbar should be
  41# a new creation.
  42
  43GIT_DIFF_OPTS=--unified=0 git diff-index -M -p $tree >current
  44cat >expected <<\EOF
  45diff --git a/bozbar b/bozbar
  46new file mode 120000
  47--- /dev/null
  48+++ b/bozbar
  49@@ -0,0 +1 @@
  50+xzzzy
  51\ No newline at end of file
  52diff --git a/frotz b/nitfol
  53similarity index 100%
  54copy from frotz
  55copy to nitfol
  56diff --git a/frotz b/rezrov
  57similarity index 100%
  58rename from frotz
  59rename to rezrov
  60diff --git a/yomin b/yomin
  61deleted file mode 100644
  62--- a/yomin
  63+++ /dev/null
  64@@ -1 +0,0 @@
  65-xyzzy
  66\ No newline at end of file
  67EOF
  68
  69test_expect_success \
  70    'validate diff output' \
  71    'compare_diff_patch current expected'
  72
  73test_done