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