1#!/bin/sh 2# 3# Copyright (c) 2005 Junio C Hamano 4# 5 6test_description='Same rename detection as t4003 but testing diff-raw -z. 7 8' 9. ./test-lib.sh 10. ../diff-lib.sh ;# test-lib chdir's into trash 11 12test_expect_success \ 13'prepare reference tree' \ 14'cat ../../COPYING >COPYING && 15 echo frotz >rezrov && 16 git-update-cache --add COPYING rezrov && 17 tree=$(git-write-tree)&& 18 echo$tree' 19 20test_expect_success \ 21'prepare work tree' \ 22'sed -e 's/HOWEVER/However/' <COPYING >COPYING.1 && 23 sed -e 's/GPL/G.P.L/g' <COPYING >COPYING.2 && 24 rm -f COPYING && 25 git-update-cache --add --remove COPYING COPYING.?' 26 27# tree has COPYING and rezrov. work tree has COPYING.1 and COPYING.2, 28# both are slightly edited, and unchanged rezrov. We say COPYING.1 29# and COPYING.2 are based on COPYING, and do not say anything about 30# rezrov. 31 32git-diff-cache -z -M$tree>current 33 34cat>expected <<\EOF 35:100644 100644 6ff87c4664981e4397625791c8ea3bbb5f2279a3 0603b3238a076dc6c8022aedc6648fa523a17178 C1234 36COPYING 37COPYING.1 38:100644 100644 6ff87c4664981e4397625791c8ea3bbb5f2279a3 06c67961bbaed34a127f76d261f4c0bf73eda471 R1234 39COPYING 40COPYING.2 41EOF 42 43test_expect_success \ 44'validate output from rename/copy detection (#1)' \ 45'compare_diff_raw_z current expected' 46 47# make sure diff-helper can grok it. 48mv current diff-raw 49GIT_DIFF_OPTS=--unified=0 git-diff-helper -z<diff-raw>current 50cat>expected <<\EOF 51diff--git a/COPYING b/COPYING.1 52copy from COPYING 53copy to COPYING.1 54--- a/COPYING 55+++ b/COPYING.1 56@@ -6+6 @@ 57- HOWEVER,in order to allow a migration to GPLv3 if that seems like 58+ However,in order to allow a migration to GPLv3 if that seems like 59diff--git a/COPYING b/COPYING.2 60rename old COPYING 61rename new COPYING.2 62--- a/COPYING 63+++ b/COPYING.2 64@@ -2+2 @@ 65- Note that the only valid version of the GPL as far as this project 66+ Note that the only valid version of the G.P.L as far as this project 67@@ -6+6 @@ 68- HOWEVER,in order to allow a migration to GPLv3 if that seems like 69+ HOWEVER,in order to allow a migration to G.P.Lv3 if that seems like 70@@ -12+12 @@ 71- This file is licensed under the GPL v2, or a later version 72+ This file is licensed under the G.P.L v2, or a later version 73EOF 74 75test_expect_success \ 76'validate output from diff-helper (#1)' \ 77'compare_diff_patch current expected' 78 79################################################################ 80 81test_expect_success \ 82'prepare work tree again' \ 83'mv COPYING.2 COPYING && 84 git-update-cache --add --remove COPYING COPYING.1 COPYING.2' 85 86# tree has COPYING and rezrov. work tree has COPYING and COPYING.1, 87# both are slightly edited, and unchanged rezrov. We say COPYING.1 88# is based on COPYING and COPYING is still there, and do not say anything 89# about rezrov. 90 91git-diff-cache -z -C$tree>current 92cat>expected <<\EOF 93:100644 100644 6ff87c4664981e4397625791c8ea3bbb5f2279a3 06c67961bbaed34a127f76d261f4c0bf73eda471 M 94COPYING 95:100644 100644 6ff87c4664981e4397625791c8ea3bbb5f2279a3 0603b3238a076dc6c8022aedc6648fa523a17178 C1234 96COPYING 97COPYING.1 98EOF 99 100test_expect_success \ 101'validate output from rename/copy detection (#2)' \ 102'compare_diff_raw_z current expected' 103 104# make sure diff-helper can grok it. 105mv current diff-raw 106GIT_DIFF_OPTS=--unified=0 git-diff-helper -z<diff-raw>current 107cat>expected <<\EOF 108diff--git a/COPYING b/COPYING 109--- a/COPYING 110+++ b/COPYING 111@@ -2+2 @@ 112- Note that the only valid version of the GPL as far as this project 113+ Note that the only valid version of the G.P.L as far as this project 114@@ -6+6 @@ 115- HOWEVER,in order to allow a migration to GPLv3 if that seems like 116+ HOWEVER,in order to allow a migration to G.P.Lv3 if that seems like 117@@ -12+12 @@ 118- This file is licensed under the GPL v2, or a later version 119+ This file is licensed under the G.P.L v2, or a later version 120diff--git a/COPYING b/COPYING.1 121copy from COPYING 122copy to COPYING.1 123--- a/COPYING 124+++ b/COPYING.1 125@@ -6+6 @@ 126- HOWEVER,in order to allow a migration to GPLv3 if that seems like 127+ However,in order to allow a migration to GPLv3 if that seems like 128EOF 129 130test_expect_success \ 131'validate output from diff-helper (#2)' \ 132'compare_diff_patch current expected' 133 134################################################################ 135 136# tree has COPYING and rezrov. work tree has the same COPYING and 137# copy-edited COPYING.1, and unchanged rezrov. We should not say 138# anything about rezrov nor COPYING, since the revised again diff-raw 139# nows how to say Copy. 140 141test_expect_success \ 142'prepare work tree once again' \ 143'cat ../../COPYING >COPYING && 144 git-update-cache --add --remove COPYING COPYING.1' 145 146git-diff-cache -z -C$tree>current 147cat>expected <<\EOF 148:100644 100644 6ff87c4664981e4397625791c8ea3bbb5f2279a3 0603b3238a076dc6c8022aedc6648fa523a17178 C1234 149COPYING 150COPYING.1 151EOF 152 153test_expect_success \ 154'validate output from rename/copy detection (#3)' \ 155'compare_diff_raw_z current expected' 156 157# make sure diff-helper can grok it. 158mv current diff-raw 159GIT_DIFF_OPTS=--unified=0 git-diff-helper -z<diff-raw>current 160cat>expected <<\EOF 161diff--git a/COPYING b/COPYING.1 162copy from COPYING 163copy to COPYING.1 164--- a/COPYING 165+++ b/COPYING.1 166@@ -6+6 @@ 167- HOWEVER,in order to allow a migration to GPLv3 if that seems like 168+ However,in order to allow a migration to GPLv3 if that seems like 169EOF 170 171test_expect_success \ 172'validate output from diff-helper (#3)' \ 173'compare_diff_patch current expected' 174 175test_done