t / t4004-diff-rename-symlink.shon commit Merge branch 'jc/maint-1.6.0-keep-pack' (3c91bf6)
   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
  19        exit
  20fi
  21
  22test_expect_success \
  23    'prepare reference tree' \
  24    'echo xyzzy | tr -d '\\\\'012 >yomin &&
  25     ln -s xyzzy frotz &&
  26    git update-index --add frotz yomin &&
  27    tree=$(git write-tree) &&
  28    echo $tree'
  29
  30test_expect_success \
  31    'prepare work tree' \
  32    'mv frotz rezrov &&
  33     rm -f yomin &&
  34     ln -s xyzzy nitfol &&
  35     ln -s xzzzy bozbar &&
  36    git update-index --add --remove frotz rezrov nitfol bozbar yomin'
  37
  38# tree has frotz pointing at xyzzy, and yomin that contains xyzzy to
  39# confuse things.  work tree has rezrov (xyzzy) nitfol (xyzzy) and
  40# bozbar (xzzzy).
  41# rezrov and nitfol are rename/copy of frotz and bozbar should be
  42# a new creation.
  43
  44GIT_DIFF_OPTS=--unified=0 git diff-index -M -p $tree >current
  45cat >expected <<\EOF
  46diff --git a/bozbar b/bozbar
  47new file mode 120000
  48--- /dev/null
  49+++ b/bozbar
  50@@ -0,0 +1 @@
  51+xzzzy
  52\ No newline at end of file
  53diff --git a/frotz b/nitfol
  54similarity index 100%
  55copy from frotz
  56copy to nitfol
  57diff --git a/frotz b/rezrov
  58similarity index 100%
  59rename from frotz
  60rename to rezrov
  61diff --git a/yomin b/yomin
  62deleted file mode 100644
  63--- a/yomin
  64+++ /dev/null
  65@@ -1 +0,0 @@
  66-xyzzy
  67\ No newline at end of file
  68EOF
  69
  70test_expect_success \
  71    'validate diff output' \
  72    'compare_diff_patch current expected'
  73
  74test_done