1#!/bin/sh 2# 3# Copyright (c) 2005 Junio C Hamano 4# 5 6test_description='More rename detection 7 8' 9. ./test-lib.sh 10 11test_expect_success \ 12'prepare reference tree' \ 13'cat ../../COPYING >COPYING && 14 echo frotz >rezrov && 15 git-update-cache --add COPYING rezrov && 16 tree=$(git-write-tree)&& 17 echo$tree' 18 19test_expect_success \ 20'prepare work tree' \ 21'sed -e 's/HOWEVER/However/' <COPYING >COPYING.1 && 22 sed -e 's/GPL/G.P.L/g' <COPYING >COPYING.2 && 23 rm -f COPYING && 24 git-update-cache --add --remove COPYING COPYING.?' 25 26# tree has COPYING and rezrov. work tree has COPYING.1 and COPYING.2, 27# both are slightly edited, and unchanged rezrov. So we say you 28# copy-and-edit one, and rename-and-edit the other. We do not say 29# anything about rezrov. 30 31GIT_DIFF_OPTS=--unified=0 git-diff-cache -M -p$tree| 32sed-e's/\([0-9][0-9]*\)/#/g'>current && 33cat>expected <<\EOF 34diff--git a/COPYING b/COPYING.# 35similarity index #% 36copy from COPYING 37copy to COPYING.# 38--- a/COPYING 39+++ b/COPYING.# 40@@ -# +# @@ 41- HOWEVER,in order to allow a migration to GPLv# if that seems like 42+ However,in order to allow a migration to GPLv# if that seems like 43diff--git a/COPYING b/COPYING.# 44similarity index #% 45rename old COPYING 46rename new COPYING.# 47--- a/COPYING 48+++ b/COPYING.# 49@@ -# +# @@ 50- Note that the only valid version of the GPL as far as this project 51+ Note that the only valid version of the G.P.L as far as this project 52@@ -# +# @@ 53- HOWEVER,in order to allow a migration to GPLv# if that seems like 54+ HOWEVER,in order to allow a migration to G.P.Lv# if that seems like 55@@ -# +# @@ 56- This file is licensed under the GPL v#, or a later version 57+ This file is licensed under the G.P.L v#, or a later version 58EOF 59 60test_expect_success \ 61'validate output from rename/copy detection' \ 62'diff -u current expected' 63 64test_expect_success \ 65'prepare work tree again' \ 66'mv COPYING.2 COPYING && 67 git-update-cache --add --remove COPYING COPYING.1 COPYING.2' 68 69# tree has COPYING and rezrov. work tree has COPYING and COPYING.1, 70# both are slightly edited, and unchanged rezrov. So we say you 71# edited one, and copy-and-edit the other. We do not say 72# anything about rezrov. 73 74GIT_DIFF_OPTS=--unified=0 git-diff-cache -C -p$tree| 75sed-e's/\([0-9][0-9]*\)/#/g'>current 76cat>expected <<\EOF 77diff--git a/COPYING b/COPYING.# 78similarity index #% 79copy from COPYING 80copy to COPYING.# 81--- a/COPYING 82+++ b/COPYING.# 83@@ -# +# @@ 84- HOWEVER,in order to allow a migration to GPLv# if that seems like 85+ However,in order to allow a migration to GPLv# if that seems like 86diff--git a/COPYING b/COPYING 87--- a/COPYING 88+++ b/COPYING 89@@ -# +# @@ 90- Note that the only valid version of the GPL as far as this project 91+ Note that the only valid version of the G.P.L as far as this project 92@@ -# +# @@ 93- HOWEVER,in order to allow a migration to GPLv# if that seems like 94+ HOWEVER,in order to allow a migration to G.P.Lv# if that seems like 95@@ -# +# @@ 96- This file is licensed under the GPL v#, or a later version 97+ This file is licensed under the G.P.L v#, or a later version 98EOF 99 100test_expect_success \ 101'validate output from rename/copy detection' \ 102'diff -u current expected' 103 104test_expect_success \ 105'prepare work tree once again' \ 106'cat ../../COPYING >COPYING && 107 git-update-cache --add --remove COPYING COPYING.1' 108 109# tree has COPYING and rezrov. work tree has COPYING and COPYING.1, 110# but COPYING is not edited. We say you copy-and-edit COPYING.1; this 111# is only possible because -C mode now reports the unmodified file to 112# the diff-core. Unchanged rezrov, although being fed to 113# git-diff-cache as well, should not be mentioned. 114 115GIT_DIFF_OPTS=--unified=0 git-diff-cache -C -p$tree| 116sed-e's/\([0-9][0-9]*\)/#/g'>current 117cat>expected <<\EOF 118diff--git a/COPYING b/COPYING.# 119similarity index #% 120copy from COPYING 121copy to COPYING.# 122--- a/COPYING 123+++ b/COPYING.# 124@@ -# +# @@ 125- HOWEVER,in order to allow a migration to GPLv# if that seems like 126+ However,in order to allow a migration to GPLv# if that seems like 127EOF 128 129test_expect_success \ 130'validate output from rename/copy detection' \ 131'diff -u current expected' 132 133test_done